Changeset 2451

Show
Ignore:
Timestamp:
09/06/08 21:46:19 (3 months ago)
Author:
bjohnson
Message:

schema06: Fixing a bunch of syntax errors in recent commits. Habari
successfully installs now.

Location:
branches/schema06/system
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • branches/schema06/system/admin/groups.php

    r2404 r2451  
    5454        echo '<form method="post" action="">'; 
    5555        echo '<input type="hidden" name="group" value="' . $group_edit->name . '">'; 
    56         echo '<table><tr><th>' . _t('Granted') . '</th><th>' . _t('Permission') . '</th><th>' . _t('Denied') . '</th></tr>'; 
     56        echo '<table><tr><th>' . _t('Permission') . '</th><th>' . _t('Denied') . '</th><th>' . _t('Read') . '</th><th>' . _t('Write') . '</th><th>' . _t('Full') . '</th></tr>'; 
    5757        foreach( $permissions as $perm ) { 
    58             echo '<tr>'; 
    59             if(  isset( $permissions_granted[ $perm->id ] ) ) { 
    60                 // indicate that this permission is granted 
    61             } elseif ( isset( $permissions_denied[ $perm->id ] ) ) { 
    62                 // indicate that this permission is denied 
     58            echo "<tr><td> {$perm->description} </td>"; 
     59            foreach ( ACL::permission_ids() as $access_name => $access_id ) { 
     60                echo "<td><input type='checkbox' name='perm_{$perm->id}' value='{$access_name}'"; 
     61                if ( isset( $permissions_granted[$perm->id] ) && $permissions_granted[$perm->id] == $access_id ) { 
     62                    echo ' checked'; 
     63                } 
     64                echo "></td><td>"; 
    6365            } 
    64             echo "<td><input type='checkbox' name='grant[]' value='{$perm->id}'"; 
    65             if ( in_array( $perm->id, $permissions_granted ) ) { 
    66                 echo ' checked'; 
    67             } 
    68             echo "></td><td> {$perm->description} </td><td>"; 
    69             echo "<input type='checkbox' name='deny[]' value='{$perm->id}'"; 
    70             if ( in_array( $perm->id, $permissions_denied ) ) { 
    71                 echo ' checked'; 
    72             } 
    73             echo '></td></tr>'; 
    7466        } 
    7567        echo '<tr><td colspan="3"><input type="submit" name="permissions" value="' . _t('Submit') . '"></td>'; 
  • branches/schema06/system/classes/acl.php

    r2445 r2451  
    3131    public static function __static() 
    3232    { 
    33         $result = DB::get_results( 'SELECT id, name FROM {permissions};' ); 
    34         foreach ( $result as $r ) { 
    35             self::$permission_ids[$r->name] = $r->id; 
     33        self::$permission_ids = DB::get_keyvalue( 'SELECT name, id FROM {permissions};' ); 
     34        if ( self::$permission_ids === FALSE ) { 
     35            self::$permission_ids = array(); 
    3636        } 
    3737    } 
     
    4444    public static function permission_id( $name ) 
    4545    { 
    46         return ( isset( self::$permission_ids[$name] ) ? self::$permission_ids[$name] : FALSE; 
     46        return isset( self::$permission_ids[$name] ) ? self::$permission_ids[$name] : FALSE; 
     47    } 
     48     
     49    /** 
     50     * Return all possible access names 
     51     * @return array An associative array of access names and ids 
     52     */ 
     53    public static function permission_ids() 
     54    { 
     55        return self::$$permission_ids; 
    4756    } 
    4857 
     
    230239 
    231240        $result = DB::get_value( $sql ); 
    232         if ( $result !== FALSE && self::$permission_ids[$result] == $access ) { 
     241        if ( isset( $result ) && self::$permission_ids[$result] == $access ) { 
    233242            // the permission has been granted to this group 
    234243            return true; 
     
    249258    { 
    250259        // Use only numeric ids internally 
    251         $permission= self::token_id( $permission ); 
     260        $permission = self::token_id( $permission ); 
    252261        // if we were given a user ID, use that to fetch the group membership from the DB 
    253262        if ( is_int( $user) ) { 
     
    301310LIMIT 1;  
    302311SQL; 
    303         $result = DB::get_value( $sql, array( ':user_id' => $user_id, ':token_id' => $permission ); 
    304  
    305         if ( $result !== FALSE && self::permission_ids[$result] == $access ) { 
     312        $result = DB::get_value( $sql, array( ':user_id' => $user_id, ':token_id' => $permission ) ); 
     313 
     314        if ( isset( $result ) && self::$permission_ids[$result] == $access ) { 
    306315            return true; 
    307316        } 
  • branches/schema06/system/classes/adminhandler.php

    r2434 r2451  
    19021902                $this->theme->users= Users::get_all(); 
    19031903                $this->theme->permissions= ACL::all_permissions( 'description' ); 
    1904                 $this->theme->permissions_granted= $group->granted; 
    1905                 $this->theme->permissions_denied= $group->denied; 
     1904                $this->theme->permissions_granted= $group->permissions; 
    19061905            } 
    19071906        } 
     
    19481947            else { 
    19491948                $grant= array(); 
    1950                 $deny= array(); 
    19511949                $revoke= array(); 
    1952                 if ( isset( $this->handler_vars['grant'] ) ) { 
    1953                     $form_grant= $this->handler_vars['grant']; 
    1954                 } 
    1955                 else { 
    1956                     $form_grant= array(); 
    1957                 } 
    1958                 if ( isset( $this->handler_vars['deny'] ) ) { 
    1959                     $form_deny= $this->handler_vars['deny']; 
    1960                 } 
    1961                 else { 
    1962                     $form_deny= array(); 
    1963                 } 
    19641950                $group= UserGroup::get( $group_name ); 
     1951 
    19651952                foreach( ACL::all_permissions() as $permission ) { 
    1966                     if ( in_array( $permission->id, $form_grant ) ) { 
    1967                         $grant[]= (int) $permission->id; 
     1953                    // grab the type of access for each permission 
     1954                    if ( isset( $this->handler_vars['perm' + $permission->id] ) ) { 
     1955                        $grant[$permission->id] = $this->handler_vars['perm' + $permission->id]; 
    19681956                    } 
    1969                     elseif ( in_array( $permission->id, $form_deny ) ) { 
    1970                         $deny[]= (int) $permission->id; 
     1957                    // if it isn't set, then revoke it 
     1958                    else { 
     1959                        $revoke[] = (int) $permission->id; 
    19711960                    } 
    1972                     else { 
    1973                         $revoke[]= (int) $permission->id; 
    1974                     } 
    1975                 } 
    1976                 if ( ! empty( $grant ) ){ 
     1961                } 
     1962                if ( ! empty( $grant ) ) { 
     1963                    /* the following call does not yet work as used 
     1964                     * need to re-write UserGroup::grant() */ 
    19771965                    $group->grant( $grant ); 
    1978                 } 
    1979                 if ( ! empty( $deny ) ) { 
    1980                     $group->deny( $deny ); 
    19811966                } 
    19821967                if ( ! empty( $revoke ) ) { 
  • branches/schema06/system/classes/databaseconnection.php

    r2404 r2451  
    2626        'crontab', 
    2727        'groups', 
    28         'groups_permissions', 
     28        'group_token_permissions', 
    2929        'log', 
    3030        'log_types', 
     31        'object_terms', 
     32        'object_types', 
    3133        'options', 
    3234        'permissions', 
     35        'post_tokens', 
    3336        'postinfo', 
    3437        'posts', 
     
    3942        'tag2post', 
    4043        'tags', 
     44        'terms', 
     45        'tokens', 
    4146        'userinfo', 
    4247        'users', 
     48        'user_token_permissions', 
    4349        'users_groups', 
     50        'vocabularies', 
    4451    ); 
    4552 
  • branches/schema06/system/classes/post.php

    r2448 r2451  
    10061006    { 
    10071007        $token_id = ACL::token_id( $permission ); 
    1008         if ( $token_id !== FALSE ) { 
     1008        if ( isset( $token_id ) ) { 
    10091009            DB::insert( '{post_tokens}', array( 'post_id' => $this->id, 'token_id' => $token_id ) ); 
    10101010        } 
     
    10161016    public function delete_permissions() 
    10171017    { 
    1018         DB::delete( '{post_tokens}', array( 'post_id', => $this->id ) ); 
     1018        DB::delete( '{post_tokens}', array( 'post_id' => $this->id ) ); 
    10191019    } 
    10201020} 
  • branches/schema06/system/classes/user.php

    r2448 r2451  
    406406 
    407407    /** 
     408     * Assign one or more new permissions to this user 
     409     * @param mixed A permission token ID, name, or array of the same 
     410    **/ 
     411    public function grant( $permissions, $access = 'full' ) 
     412    { 
     413        $permissions = Utils::single_array( $permissions ); 
     414        // Use ids internally for all permissions 
     415        $permissions = array_map(array('ACL', 'token_id'), $permissions); 
     416 
     417        foreach ( $permissions as $permission ) { 
     418            ACL::grant_user( $this->id, $permission, $access ); 
     419        } 
     420    } 
     421 
     422    /** 
     423     * Deny one or more permissions to this user 
     424     * @param mixed The permission ID or name to be denied, or an array of the same 
     425    **/ 
     426    public function deny( $permissions ) 
     427    { 
     428        $this->grant( $permissions, 'deny' ); 
     429    } 
     430 
     431    /** 
     432     * Remove one or more permissions from a user 
     433     * @param mixed a permission ID, name, or array of the same 
     434    **/ 
     435    public function revoke( $permissions ) 
     436    { 
     437        $permissions = Utils::single_array( $permissions ); 
     438        // get token IDs 
     439        $permissions = array_map(array('ACL', 'token_id'), $permissions); 
     440        foreach ( $permissions as $permission ) { 
     441            ACL::revoke_user_permission( $this->id, $permission ); 
     442        } 
     443    } 
     444 
     445    /** 
    408446     * function groups 
    409447     * Returns an array of groups to which this user belongs 
  • branches/schema06/system/classes/usergroup.php

    r2445 r2451  
    235235    { 
    236236        $permissions = Utils::single_array( $permissions ); 
     237        $permissions = array_map(array('ACL', 'token_id'), $permissions); 
    237238        // Remove permissions from the granted list 
    238239        $this->permissions = array_diff_key( $this->permissions, $permissions );