Changeset 2864

Show
Ignore:
Timestamp:
11/24/08 04:54:57 (7 weeks ago)
Author:
ringmaster
Message:

Add special permission cases 'full' and 'any'. Default User::can() to 'any'. Make Bitmasks return a full bitmask for ->full

Location:
trunk/htdocs/system/classes
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/classes/acl.php

    r2862 r2864  
    3636        $bitmask = new Bitmask( self::$access_names, $permission ); 
    3737 
    38         if ( $access == 'full' ) { 
    39             return $bitmask->read && $bitmask->write; 
    40         } 
    41         return $bitmask->$access; 
     38        switch($access) { 
     39            case 'full': 
     40                return $bitmask->value == $bitmask->full; 
     41            case 'any': 
     42                return $bitmask->value != 0; 
     43            default: 
     44                return $bitmask->$access; 
     45        } 
    4246    } 
    4347 
  • trunk/htdocs/system/classes/bitmask.php

    r2862 r2864  
    6868    { 
    6969        if ( is_string( $bit ) ) { 
    70             $bit = array_search( $bit, $this->flags ); 
     70            if($bit == 'full') { 
     71                return (1 << (count($this->flags) - 1)) - 1; 
     72            } 
     73            else { 
     74                $bit = array_search( $bit, $this->flags ); 
     75            } 
    7176        } 
    7277        if ( $bit === false ) 
     
    7782} 
    7883?> 
    79  
  • trunk/htdocs/system/classes/user.php

    r2862 r2864  
    411411     * @return boolean True if this user has the requested permission, false if not 
    412412     */ 
    413     public function can( $permission, $access = 'full' ) 
     413    public function can( $permission, $access = 'any' ) 
    414414    { 
    415415        return ACL::user_can( $this, $permission, $access );