Changeset 2451 for branches/schema06/system/classes/acl.php
- Timestamp:
- 09/06/08 21:46:19 (4 months ago)
- Files:
-
- 1 modified
-
branches/schema06/system/classes/acl.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/schema06/system/classes/acl.php
r2445 r2451 31 31 public static function __static() 32 32 { 33 $result = DB::get_results( 'SELECT id, nameFROM {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(); 36 36 } 37 37 } … … 44 44 public static function permission_id( $name ) 45 45 { 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; 47 56 } 48 57 … … 230 239 231 240 $result = DB::get_value( $sql ); 232 if ( $result !== FALSE&& self::$permission_ids[$result] == $access ) {241 if ( isset( $result ) && self::$permission_ids[$result] == $access ) { 233 242 // the permission has been granted to this group 234 243 return true; … … 249 258 { 250 259 // Use only numeric ids internally 251 $permission = self::token_id( $permission );260 $permission = self::token_id( $permission ); 252 261 // if we were given a user ID, use that to fetch the group membership from the DB 253 262 if ( is_int( $user) ) { … … 301 310 LIMIT 1; 302 311 SQL; 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 ) { 306 315 return true; 307 316 }
