public static function getFromString($perm)
    {
        list ($app, $code) = explode('.', trim($perm));
        $sql = new Pluf_SQL('code_name=%s AND application=%s', array(
            $code,
            $app
        ));
        $permModel = new User_Role();
        $perms = $permModel->getList(array(
            'filter' => $sql->gen()
        ));
        if ($perms->count() != 1) { // permission does not exist
            if(Pluf::f('core_permession_autoCreate', true)){
                $permModel->code_name = $code;
                $permModel->application = $app;
                if($permModel->create()){
                    return $permModel;
                }
            }
            return false;
        }
        return $perms[0];
    }
public static function getFromString($perm)
    {
        list ($app, $code) = explode('.', trim($perm));
        $sql = new Pluf_SQL('code_name=%s AND application=%s', array(
            $code,
            $app
        ));
        $permModel = new User_Role();
        $perms = $permModel->getList(array(
            'filter' => $sql->gen()
        ));
        if ($perms->count() != 1) { // permission does not exist
            if(Pluf::f('core_permession_autoCreate', true)){
                $permModel->code_name = $code;
                $permModel->application = $app;
                if($permModel->create()){
                    return $permModel;
                }
            }
            return false;
        }
        return $perms[0];
    }
public static function getFromString ( $ perm ) { list ( $ app , $ code ) = explode ( '.' , trim ( $ perm ) ) ; $ sql = new Pluf_SQL ( 'code_name=%s AND application=%s' , array ( $ code , $ app ) ) ; $ permModel = new User_Role ( ) ; $ perms = $ permModel -> getList ( array ( 'filter' => $ sql -> gen ( ) ) ) ; if ( $ perms -> count ( ) != 1 ) { // permission does not exist if ( Pluf :: f ( 'core_permession_autoCreate' , true ) ) { $ permModel -> code_name = $ code ; $ permModel -> application = $ app ; if ( $ permModel -> create ( ) ) { return $ permModel ; } } return false ; } return $ perms [ 0 ] ; }
Get the matching permission object from the permission string.

@param
string Permission string, for example 'User.create'.
@return false|User_Role The matching permission or false.
Get the matching permission object from the permission string .