Example #1
0
 /**
  * Refresh the privileges
  *
  * Refreshes the privileges of this module. If $privilege is not defined,
  * gets the proper privilege using the default TIP_Privilege instance.
  *
  * @param TIP_PRIVILEGE_... $privilege The new privilege level
  */
 protected function refreshPrivileges($privilege = null)
 {
     isset($privilege) || ($privilege = TIP::getPrivilege($this->id));
     $this->privilege = $privilege;
     $this->keys['IS_MANAGER'] = false;
     $this->keys['IS_ADMIN'] = false;
     $this->keys['IS_TRUSTED'] = false;
     $this->keys['IS_UNTRUSTED'] = false;
     switch ($this->privilege) {
         case TIP_PRIVILEGE_MANAGER:
             $this->keys['IS_MANAGER'] = true;
         case TIP_PRIVILEGE_ADMIN:
             $this->keys['IS_ADMIN'] = true;
         case TIP_PRIVILEGE_TRUSTED:
             $this->keys['IS_TRUSTED'] = true;
         case TIP_PRIVILEGE_UNTRUSTED:
             $this->keys['IS_UNTRUSTED'] = true;
     }
 }
Example #2
0
 /**
  * Refresh module privileges
  *
  * Called by _refreshUser() to recursively refresh the privilege of the
  * yet loaded modules.
  *
  * @param array|TIP_Module &$module A module or an array of modules
  */
 private function _refreshModule(&$module)
 {
     if (is_array($module)) {
         array_walk($module, array(&$this, '_refreshModule'));
     } else {
         $module->refreshPrivileges(TIP::getPrivilege($module, $this->keys['CID']));
     }
 }