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

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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        }