Changeset 2859
- Timestamp:
- 11/24/08 03:10:34 (7 weeks ago)
- Location:
- trunk/htdocs/system/classes
- Files:
-
- 2 modified
-
acl.php (modified) (3 diffs)
-
bitmask.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htdocs/system/classes/acl.php
r2850 r2859 29 29 * Check the permission bitmask for a particular access type. 30 30 * @param mixed $permission The permission bitmask 31 * @param mixed $access The name of the access to check against (read, write, delete)31 * @param mixed $access The name of the access to check against (read, write, full) 32 32 * @return bool Returns true if the given access meets exceeds the access to check against 33 33 */ 34 public static function access_check( $permission _flag, $access )34 public static function access_check( $permission, $access ) 35 35 { 36 36 $bitmask = new Bitmask( self::$access_names, $permission ); 37 37 38 if ( $access == 'full' ) { 39 return $bitmask->read && $bitmask->write; 40 } 38 41 return $bitmask->$access; 39 42 } … … 277 280 AND ug.user_id = :user_id 278 281 AND gp.token_id = :token_id 279 ORDER BY gp.permission_id282 ORDER BY permission_id ASC 280 283 LIMIT 1; 281 284 SQL; … … 376 379 public static function grant_user( $user_id, $token_id, $access = 'full' ) 377 380 { 378 $permission_id = DB::get_value( 'SELECT permission_id FROM {user_token_permissions} WHERE group_id=? AND token_id=?',381 $permission_id = DB::get_value( 'SELECT permission_id FROM {user_token_permissions} WHERE user_id=? AND token_id=?', 379 382 array( $user_id, $token_id ) ); 380 383 if ( $permission_id === false ) { -
trunk/htdocs/system/classes/bitmask.php
r2850 r2859 64 64 */ 65 65 public function __get( $bit ) { 66 if ( is_ int( $bit ) ) {67 $ flags = array_values($this->flags );66 if ( is_string( $bit ) ) { 67 $bit = array_search( $bit, $this->flags ); 68 68 } 69 else { 70 $flags = $this->flags; 71 } 72 if ( ! isset( $flags[$bit] ) ) { 69 if ( $bit === false ) 73 70 return false; 74 } 75 return ( ( $this->value & $this->flags[$bit] ) == $this->flags[$bit] ); 71 return $this->value & pow(2, $bit); 76 72 } 77 73 78 74 } 79 75 ?> 76
