Development

Changeset 20508

You must first sign up to be able to contribute.

Changeset 20508

Show
Ignore:
Timestamp:
07/26/09 22:19:59 (4 years ago)
Author:
henrik
Message:

Added User contextual checking (authenticated and credentials) that only depends on sfUser. And mocked up the planned changes for the matching algoritm

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfTabMenuPeytzPlugin/lib/sfTabMenuPeytz.class.php

    r20450 r20508  
    4343        'route' => '@homepage', 
    4444        'default' => false, 
     45        'security' => array( 
     46            'is_secure' => false, 
     47            'credentials' => array() 
     48            /* 
     49                This is run before anything else, and will determaine if the user got access to this, if u set a permission the 
     50                is_secure it not needed since the user will be check for authenticated before checking for is_secure. 
     51            */ 
     52        ), 
     53        'matches' => array( //Must match one of these 
     54            'module/action?get=asdad&get=sadasd', 
     55            /* 
     56                Written in the same syntax as routes, if a parameter has a value specified, that value will be check 
     57                else it will just verify that the parameter is availible by sfWebRequest. 
     58                This makes a tab able to match different things. the match with highest score for that tab 
     59                will be used in the overall score matching. 
     60            */ 
     61        ), 
    4562        'match' => array( 
    4663            'module' => null, 
     
    87104     
    88105    /** 
     106     * Holds the user object 
     107     * 
     108     * @var sfUser 
     109     */ 
     110    private $_User; 
     111     
     112    /** 
    89113     * Renders tabs, uses sf_app_dir to determaine the location of the tabs.yml file. 
    90114     * The params array is appended to the routes 
     
    105129            self::$_ParsedYamlFile = sfYaml::load($configFile); 
    106130        } 
     131         
     132        $this->_User = sfContext::getInstance()->getUser(); 
    107133         
    108134        $config = self::$_ParsedYamlFile; 
     
    213239        //Generate the tab parameters 
    214240        $config = self::merge($this->_DefaultTabConfig, $this->config['tabs'][$index]); 
     241         
     242        //Check the user can access this else just return; 
     243        if ($config['security']['is_secure'] === true || count($config['security']['credentials'])) { 
     244            //Is the user authenticated 
     245            if (!$this->_User->isAuthenticated()) { 
     246                return; 
     247            } 
     248             
     249            //Credentials checking 
     250            if (count($config['security']['credentials'])) { 
     251                if ($this->_User->hasCredential((array) $config['security']['credentials'])) { 
     252                    return; 
     253                } 
     254            } 
     255        } 
    215256         
    216257        //Generate the correct name