/**
  * @param string $moduleClassName
  * @return bool
  */
 public static function canCurrentUserCanAccessModule($moduleClassName)
 {
     assert('is_string($moduleClassName)');
     if ($moduleClassName::getStateMetadataAdapterClassName() != null) {
         $workflowRules = WorkflowRules::makeByModuleClassName($moduleClassName);
         return $workflowRules->canUserAccessModuleInAVariableState(Yii::app()->user->userModel);
     } else {
         return RightsUtil::canUserAccessModule($moduleClassName, Yii::app()->user->userModel);
     }
 }
 /**
  * @return array
  */
 public static function getDefaultMetadata()
 {
     $metadata = array('SecurableItem' => array('cannotTrigger' => array('permissions')));
     return array_merge(parent::getDefaultMetadata(), $metadata);
 }
 /**
  * @return array
  */
 public static function getDefaultMetadata()
 {
     $metadata = array('Permitable' => array('cannotTrigger' => array('policies', 'rights')));
     return array_merge(parent::getDefaultMetadata(), $metadata);
 }
Beispiel #4
0
 /**
  * Based on the current user, return the workflow supported modules and their display labels.  Only include modules
  * that the user has a right to access.
  * @return array of module class names and display labels.
  */
 public static function getWorkflowSupportedModulesAndLabelsForCurrentUser()
 {
     $moduleClassNamesAndLabels = array();
     $modules = Module::getModuleObjects();
     foreach (self::getWorkflowSupportedModulesClassNamesCurrentUserHasAccessTo() as $moduleClassName) {
         if ($moduleClassName::getStateMetadataAdapterClassName() != null) {
             $workflowRules = WorkflowRules::makeByModuleClassName($moduleClassName);
             $label = $workflowRules->getVariableStateModuleLabel(Yii::app()->user->userModel);
         } else {
             $label = $moduleClassName::getModuleLabelByTypeAndLanguage('Plural');
         }
         if ($label != null) {
             $moduleClassNamesAndLabels[$moduleClassName] = $label;
         }
     }
     return $moduleClassNamesAndLabels;
 }
 /**
  * @param boolean $includeRequired
  * @param boolean $includeNonRequired
  * @param $includeReadOnly
  * @return array
  */
 protected function resolveDynamicallyDerivedAttributesForActionsOrTimeTriggerData($includeRequired = false, $includeNonRequired = false, $includeReadOnly = false)
 {
     assert('is_bool($includeRequired)');
     assert('is_bool($includeNonRequired)');
     assert('is_bool($includeReadOnly)');
     $attributes = array();
     foreach ($this->model->getAttributes() as $attribute => $notUsed) {
         if (!$this->model instanceof User && $this->model->isRelation($attribute) && (!$this->model->isAttributeReadOnly($attribute) || $includeReadOnly) && $this->model->getRelationModelClassName($attribute) == 'User') {
             $attributeIsRequired = $this->model->isAttributeRequired($attribute);
             if ($includeNonRequired && !$attributeIsRequired || $includeRequired && $attributeIsRequired) {
                 $attributes[$attribute . FormModelUtil::DELIMITER . self::DYNAMIC_ATTRIBUTE_USER] = array('label' => $this->model->getAttributeLabel($attribute));
             }
         }
         if ($this->model->isRelation($attribute) && $this->model->isOwnedRelation($attribute) && $this->isRelationASingularRelation($attribute) && ($this->model->getRelationModelClassName($attribute) == 'Address' || $this->model->getRelationModelClassName($attribute) == 'Email')) {
             $relatedModel = $this->model->{$attribute};
             //Assumes only Email or Address are possible owned models here
             $zurmoRules = WorkflowRules::makeByModuleClassName('ZurmoModule');
             foreach ($relatedModel->getAttributes() as $relatedAttribute => $notUsed) {
                 if (!$relatedModel->isAttributeReadOnly($relatedAttribute) && !$relatedModel->isRelation($relatedAttribute) && $zurmoRules->attributeCanBeTriggered($relatedModel, $relatedAttribute)) {
                     $relatedAttributeIsRequired = $relatedModel->isAttributeRequired($relatedAttribute);
                     if ($includeNonRequired && !$relatedAttributeIsRequired || $includeRequired && $relatedAttributeIsRequired) {
                         $attributes[$attribute . FormModelUtil::RELATION_DELIMITER . $relatedAttribute] = array('label' => $this->model->getAttributeLabel($attribute) . ' ' . ComponentForWorkflowForm::DISPLAY_LABEL_RELATION_DIVIDER . ' ' . $relatedModel->getAttributeLabel($relatedAttribute));
                     }
                 }
             }
         }
     }
     return $attributes;
 }