Location: PHPKode > projects > Blackwolf CMF > projectBlackWolf/lib/Permission/Subsystem.class.php
<?php
/* Please see the README and LICENSE files. */


/**
 * This class acts as an API or Facade to allow permissions to be integrated
 * into system operation
 */

// Bitflags
define("READ_PERM",1);
define("WRITE_PERM",2);
define("EXECUTE_PERM",4);


class Permission_Subsystem implements System_Subsystem {

    /**
     * Check if the current user has the READ_PERM for the provided attribute
     * @param Data_Attribute $attribute The attribute to check 
     * @return Boolean true if flag is set 
     */
    public static function can_read_attribute($attribute) {
        #TODO
        return rand(0,1);
    }

    /**
     * Check if the current user has WRITE_PERM enabled for provided attribute
     * @param Data_Attribute $attribute The attribute to check 
     * @return Boolean true if flag is set
     */
    public static function can_write_attribute($attribute) {
        #TODO
        return true;
    }

    /**
     * Check if the current user has the EXECUTE_PERM for the command
     * @param Module_Command $module_command The command to check 
     * @return Boolean true if flag is set
     */
    public static function can_exec_cmd($module_command) {
        #TODO
        return true;
    }

    /**
     * Check if the current user has the READ_PERM for the current page
     * @param String $url If provided, the url to check instead
     * @return Boolean true if can read
     */
    public static function can_read_page($url=NULL) {
        $url = is_null($url) ? 
                parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH) : 
                $url;
        return self::check_permission("internal","pages",$url,READ_PERM);
    }
    
    /**
     * Check for the existance of the perm (flag) in the permission storage
     * @param String $system
     * @param String $model
     * @param String $attribute
     * @param int $perm
     * @return Boolean true if flag is set 
     */
    public static function check_permission($system,$model,$attribute,$perm){
        #TODO
        return true;
    }
    
    /**
     * Get the permissions from the storage for the provided element
     * @param type $system
     * @param type $model
     * @param type $attribute
     * @return int The perm int in binary
     */
    public static function get_perms($system,$model,$attribute){
        #TODO;
        return 11111111;
    }
    
    public static function set_perms($system,$model,$attribute,$perms){
        return false;
    }
}

?>
Return current item: Blackwolf CMF