Exemple #1
0
 public function init()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model();
         $currentUser = $user->findByPk(Yii::app()->user->id);
         if ($currentUser instanceof User) {
             $this->acl = new AccessControlList($currentUser);
             // Logout user if he was disabled or his role was changed by admin
             if ($this->acl->canAuthenticate()) {
                 $user->flash_messages = false;
                 //$user->last_login = new CDbExpression('NOW()');
                 //$user->save();
             } else {
                 Yii::app()->user->logout();
             }
         }
     }
 }
Exemple #2
0
 public static function getSiteAccessControlLists()
 {
     $config = ConfigFile::factory('acls', 'site', ConfigFile::OPTION_CREATE_EMPTY);
     $acls = array();
     foreach ($config->getSectionVars() as $aclArray) {
         if ($acl = AccessControlList::createFromArray($aclArray)) {
             $acls[] = $acl;
         }
     }
     return $acls;
 }
 protected function getAccessControlLists($type)
 {
     return array(AccessControlList::allAccess());
 }
Exemple #4
0
 /**
  * Returns the access control lists
  * @return array
  */
 protected function getModuleAccessControlLists()
 {
     $acls = array();
     if ($config = $this->getConfig('acls', ConfigFile::OPTION_DO_NOT_CREATE)) {
         foreach ($config->getSectionVars() as $aclArray) {
             if ($acl = AccessControlList::createFromArray($aclArray)) {
                 $acls[] = $acl;
             }
         }
     }
     return $acls;
 }
Exemple #5
0
 /**
  * Returns the access control lists
  * @return array
  */
 protected function getModuleAccessControlLists()
 {
     $acls = array();
     if ($aclData = $this->getOptionalModuleSections('acls')) {
         foreach ($aclData as $aclArray) {
             if ($acl = AccessControlList::createFromArray($aclArray)) {
                 $acls[] = $acl;
             }
         }
     }
     return $acls;
 }
Exemple #6
0
 public static function getSiteAccessControlLists()
 {
     $aclData = self::getOptionalSiteSections('acls');
     $acls = array();
     foreach ($aclData as $aclArray) {
         if ($acl = AccessControlList::createFromArray($aclArray)) {
             $acls[] = $acl;
         }
     }
     return $acls;
 }
 protected function getAccessControlLists($type) {
   return array(AccessControlList::factory(AccessControlList::RULE_ACTION_ALLOW, 
                                           AccessControlList::RULE_TYPE_EVERYONE,
                                           AccessControlList::RULE_VALUE_ALL));
 }
 public function getAccessControlLists()
 {
   $acls = array();
   $aclStrings = $this->getModuleVar('acl', array(), Config::SUPRESS_ERRORS);
   foreach ($aclStrings as $aclString) {
       if ($acl = AccessControlList::createFromString($aclString)) {
           $acls[] = $acl;
       } else {
           throw new Exception("Invalid ACL $aclString in $this->id");
       }
   }
   
   return $acls;
 }
 /**
   * Returns an access control list based on a string
   * @param string Should be in format ACTION:RULE:VALUE
   * @return AccessControlList or false if the string is invalid
   */
 public static function createFromString($aclString)
 {
     $values = explode(':', $aclString);
     if (count($values)==3) {
         return AccessControlList::factory($values[0], $values[1], $values[2]);
     } else {
         return false;
     }
 }
 public function getAccessControlLists($admin=false) {
     $acls = array();
     $var = $admin ? 'adminacl' : 'acl';
     
     $aclStrings = array_merge(
         $this->getSiteVar($var, array(), Config::SUPRESS_ERRORS),
         $this->getModuleVar($var, array(), Config::SUPRESS_ERRORS)
     );
     
     foreach ($aclStrings as $aclString) {
         if ($acl = AccessControlList::createFromString($aclString)) {
             $acls[] = $acl;
         } else {
             throw new Exception("Invalid $var $aclString in $this->id");
         }
     }
     
     return $acls;
 }
Exemple #11
0
 /**
   * Retrieves the access control lists 
   * @param bool $admin if true evaluate the admin acls
   * @return array of access control lists
   */
 protected function getAccessControlLists($type) {
     $acls = array();
     
     $aclStrings = array_merge(
         $this->getSiteVar($type, array(), Config::SUPRESS_ERRORS),
         $this->getModuleVar($type, array(), Config::SUPRESS_ERRORS)
     );
     
     foreach ($aclStrings as $aclString) {
         if ($acl = AccessControlList::createFromString($aclString)) {
             $acls[] = $acl;
         } else {
             throw new Exception("Invalid $var $aclString in $this->configModule");
         }
     }
     
     return $acls;
 }