Advertisement
fernandezekiel

Untitled

Oct 22nd, 2013
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. class WebModule extends CWebModule{
  2.     public function __call($name, $arguments)
  3.     {
  4.         if(array_key_exists($name, $this->accessibleFunctions))
  5.         {
  6.             if(!Yii::app()->user->hasState('__' . $name))
  7.             {
  8.                 $state = Yii::app()->user->checkAccess($this->accessibleFunctions[$name]);
  9.                 Yii::app()->user->setState('__' . $name, $state);
  10.             }
  11.             return Yii::app()->user->getState('__' . $name);
  12.         }
  13.  
  14.         throw new RuntimeException('Method does not exist!');
  15.  
  16.     }
  17.     public function isAccessible() {
  18.         foreach($this->accessibleFunctions as $name=>$authItem)
  19.         {
  20.             if($this->$name() == true)
  21.                 return true;
  22.         }
  23.         return false;
  24.     }
  25. }
  26.  
  27. class CrmModule extends WebModule
  28. {
  29.     public $accessibleFunctions = array(
  30.         'isCustomerAccessible'=>'view.own.customer',
  31.         'isContactAccessible'=> 'view.own.contact',
  32.         'isLeadAccessible' => 'view.own.lead',
  33.         'isSlaAccessible' => 'view.own.sla',
  34.     );
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement