Example #1
0
 public function getActualRight($moduleName, $rightName)
 {
     assert('is_string($moduleName)');
     assert('is_string($rightName)');
     assert('$moduleName != ""');
     assert('$rightName  != ""');
     $identifier = $this->id . $moduleName . $rightName . 'ActualRight';
     if (!SECURITY_OPTIMIZED) {
         // The slow way will remain here as documentation
         // for what the optimized way is doing.
         try {
             // not using default value to save cpu cycles on requests that follow the first exception.
             return RightsCache::getEntry($identifier);
         } catch (NotFoundException $e) {
             if (Group::getByName(Group::SUPER_ADMINISTRATORS_GROUP_NAME)->contains($this)) {
                 $actualRight = Right::ALLOW;
             } else {
                 $actualRight = parent::getActualRight($moduleName, $rightName);
             }
             RightsCache::cacheEntry($identifier, $actualRight);
         }
     } else {
         try {
             // not using default value to save cpu cycles on requests that follow the first exception.
             return RightsCache::getEntry($identifier);
         } catch (NotFoundException $e) {
             // Optimizations work on the database,
             // anything not saved will not work.
             assert('$this->id > 0');
             $actualRight = intval(ZurmoDatabaseCompatibilityUtil::callFunction("get_user_actual_right({$this->id}, '{$moduleName}', '{$rightName}')"));
             RightsCache::cacheEntry($identifier, $actualRight);
         }
     }
     return $actualRight;
 }