示例#1
0
 /**
  * @return array of all module rights data
  */
 public static function getAllModuleRightsDataByPermitable(Permitable $permitable)
 {
     $data = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module instanceof SecurableModule) {
             $moduleClassName = get_class($module);
             $rights = $moduleClassName::getRightsNames();
             $rightLabels = $moduleClassName::getTranslatedRightsLabels();
             $reflectionClass = new ReflectionClass($moduleClassName);
             if (!empty($rights)) {
                 $rightsData = array();
                 foreach ($rights as $right) {
                     if (!isset($rightLabels[$right])) {
                         throw new NotSupportedException($right);
                     }
                     $explicit = $permitable->getExplicitActualRight($moduleClassName, $right);
                     $inherited = $permitable->getInheritedActualRight($moduleClassName, $right);
                     $effective = $permitable->getEffectiveRight($moduleClassName, $right);
                     $constants = $reflectionClass->getConstants();
                     $constantId = array_search($right, $constants);
                     $rightsData[$constantId] = array('displayName' => $rightLabels[$right], 'explicit' => RightsUtil::getRightStringFromRight($explicit), 'inherited' => RightsUtil::getRightStringFromRight($inherited), 'effective' => RightsUtil::getRightStringFromRight($effective));
                 }
                 $data[$moduleClassName] = ArrayUtil::subValueSort($rightsData, 'displayName', 'asort');
             }
         }
     }
     return $data;
 }
示例#2
0
 public function getInheritedActualRight($moduleName, $rightName)
 {
     assert('is_string($moduleName)');
     assert('is_string($rightName)');
     assert('$moduleName != ""');
     assert('$rightName  != ""');
     if ($this->isEveryone) {
         return Right::NONE;
     }
     if (!SECURITY_OPTIMIZED) {
         return parent::getInheritedActualRight($moduleName, $rightName);
     } else {
         // Optimizations work on the database,
         // anything not saved will not work.
         assert('$this->id > 0');
         return intval(ZurmoDatabaseCompatibilityUtil::callFunction("get_group_inherited_actual_right({$this->id}, '{$moduleName}', '{$rightName}')"));
     }
 }