Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WebModule extends CWebModule{
- public function __call($name, $arguments)
- {
- if(array_key_exists($name, $this->accessibleFunctions))
- {
- if(!Yii::app()->user->hasState('__' . $name))
- {
- $state = Yii::app()->user->checkAccess($this->accessibleFunctions[$name]);
- Yii::app()->user->setState('__' . $name, $state);
- }
- return Yii::app()->user->getState('__' . $name);
- }
- throw new RuntimeException('Method does not exist!');
- }
- public function isAccessible() {
- foreach($this->accessibleFunctions as $name=>$authItem)
- {
- if($this->$name() == true)
- return true;
- }
- return false;
- }
- }
- class CrmModule extends WebModule
- {
- public $accessibleFunctions = array(
- 'isCustomerAccessible'=>'view.own.customer',
- 'isContactAccessible'=> 'view.own.contact',
- 'isLeadAccessible' => 'view.own.lead',
- 'isSlaAccessible' => 'view.own.sla',
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement