/**
  * Return the cached description of the roles
  * that have access to this controller
  * 
  * @param string $controllerClassName
  * @return array
  */
 public static function getControllerAccess($controllerClassName)
 {
     try {
         $returnValue = self::getCacheImplementation()->get(self::SERIAL_PREFIX_MODULE . $controllerClassName);
     } catch (common_cache_Exception $e) {
         $extId = funcAcl_helpers_Map::getExtensionFromController($controllerClassName);
         $extension = funcAcl_helpers_Map::getUriForExtension($extId);
         $module = funcAcl_helpers_Map::getUriForController($controllerClassName);
         $serial = self::buildModuleSerial(new core_kernel_classes_Resource($module));
         $roleClass = new core_kernel_classes_Class(CLASS_ROLE);
         $accessProperty = new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS);
         $actionIdentifierProperty = new core_kernel_classes_Property(PROPERTY_ACL_COMPONENT_ID);
         $memberOfProperty = new core_kernel_classes_Property(PROPERTY_ACL_ACTION_MEMBEROF);
         $returnValue = array('module' => array(), 'actions' => array());
         // roles by extensions
         $roles = $roleClass->searchInstances(array($accessProperty->getUri() => $extension), array('recursive' => true, 'like' => false));
         foreach ($roles as $grantedRole) {
             $returnValue['module'][] = $grantedRole->getUri();
         }
         // roles by controller
         $filters = array($accessProperty->getUri() => $module);
         $options = array('recursive' => true, 'like' => false);
         foreach ($roleClass->searchInstances($filters, $options) as $grantedRole) {
             $returnValue['module'][] = $grantedRole->getUri();
         }
         // roles by action
         foreach (ControllerHelper::getActions($controllerClassName) as $actionName) {
             $actionUri = funcAcl_helpers_Map::getUriForAction($controllerClassName, $actionName);
             $rolesForAction = $roleClass->searchInstances(array($accessProperty->getUri() => $actionUri), array('recursive' => true, 'like' => false));
             if (!empty($rolesForAction)) {
                 $actionName = funcAcl_helpers_Map::getActionFromUri($actionUri);
                 $returnValue['actions'][$actionName] = array();
                 foreach ($rolesForAction as $roleResource) {
                     $returnValue['actions'][$actionName][] = $roleResource->getUri();
                 }
             }
         }
         self::getCacheImplementation()->put($returnValue, self::SERIAL_PREFIX_MODULE . $controllerClassName);
     }
     return $returnValue;
 }
 /**
  * Evaluate the mask to ACL components
  * 
  * @param mixed $mask
  * @return string[] tao ACL components
  */
 public function evalFilterMask($mask)
 {
     // string masks
     if (is_string($mask)) {
         if (strpos($mask, '@') !== false) {
             list($controller, $action) = explode('@', $mask, 2);
         } else {
             $controller = $mask;
             $action = null;
         }
         if (class_exists($controller)) {
             $extension = funcAcl_helpers_Map::getExtensionFromController($controller);
             $shortName = strpos($controller, '\\') !== false ? substr($controller, strrpos($controller, '\\') + 1) : substr($controller, strrpos($controller, '_') + 1);
             if (is_null($action)) {
                 // grant controller
                 return array($extension, $shortName);
             } else {
                 // grant action
                 return array($extension, $shortName, $action);
             }
         } else {
             common_Logger::w('Unknown controller ' . $controller);
         }
         /// array masks
     } elseif (is_array($mask)) {
         if (isset($mask['act']) && isset($mask['mod']) && isset($mask['ext'])) {
             return array($mask['ext'], $mask['mod'], $mask['act']);
         } elseif (isset($mask['mod']) && isset($mask['ext'])) {
             return array($mask['ext'], $mask['mod']);
         } elseif (isset($mask['ext'])) {
             return array($mask['ext']);
         } elseif (isset($mask['controller'])) {
             $extension = funcAcl_helpers_Map::getExtensionFromController($mask['controller']);
             $shortName = strpos($mask['controller'], '\\') !== false ? substr($mask['controller'], strrpos($mask['controller'], '\\') + 1) : substr($mask['controller'], strrpos($mask['controller'], '_') + 1);
             return array($extension, $shortName);
         } elseif (isset($mask['act']) && strpos($mask['act'], '@') !== false) {
             list($controller, $action) = explode('@', $mask['act'], 2);
             $extension = funcAcl_helpers_Map::getExtensionFromController($controller);
             $shortName = strpos($controller, '\\') !== false ? substr($controller, strrpos($controller, '\\') + 1) : substr($controller, strrpos($controller, '_') + 1);
             return array($extension, $shortName, $action);
         } else {
             common_Logger::w('Uninterpretable filter in ' . __CLASS__);
         }
     } else {
         common_Logger::w('Uninterpretable filtertype ' . gettype($mask));
     }
     return array();
 }
 public function revokeRule(AccessRule $rule)
 {
     if ($rule->isGrant()) {
         $accessService = funcAcl_models_classes_AccessService::singleton();
         $filter = $rule->getMask();
         if (isset($filter['act']) && isset($filter['mod']) && isset($filter['ext'])) {
             $accessService->revokeActionAccess($rule->getRole(), $filter['ext'], $filter['mod'], $filter['act']);
         } elseif (isset($filter['mod']) && isset($filter['ext'])) {
             $accessService->revokeModuleAccess($rule->getRole(), $filter['ext'], $filter['mod']);
         } elseif (isset($filter['ext'])) {
             $accessService->revokeExtensionAccess($rule->getRole(), $filter['ext']);
         } elseif (isset($filter['controller'])) {
             $extension = funcAcl_helpers_Map::getExtensionFromController($filter['controller']);
             $shortName = strpos($filter['controller'], '\\') !== false ? substr($filter['controller'], strrpos($filter['controller'], '\\') + 1) : substr($filter['controller'], strrpos($filter['controller'], '_') + 1);
             $accessService->revokeModuleAccess($rule->getRole(), $extension, $shortName);
         } elseif (isset($filter['act']) && strpos($filter['act'], '@') !== false) {
             list($controller, $action) = explode('@', $mask['act'], 2);
             $extension = funcAcl_helpers_Map::getExtensionFromController($controller);
             $shortName = strpos($controller, '\\') !== false ? substr($controller, strrpos($controller, '\\') + 1) : substr($controller, strrpos($controller, '_') + 1);
             $accessService->revokeActionAccess($rule->getRole(), $extension, $shortName, $action);
         } else {
             common_Logger::w('Uninterpretable filter in ' . __CLASS__);
         }
     } else {
         common_Logger::w('Only grant rules accepted in ' . __CLASS__);
     }
 }