Пример #1
0
 /**
  * @return Workflow_Transition_Condition_Permissions
  */
 public function getInstanceFromXML($xml, &$xmlMapping, Transition $transition)
 {
     $authorized_ugroups_keyname = array();
     if (isset($xml->permissions)) {
         foreach ($xml->permissions->permission as $perm) {
             $ugroup = (string) $perm['ugroup'];
             if (isset($GLOBALS['UGROUPS'][$ugroup])) {
                 $authorized_ugroups_keyname[] = $GLOBALS['UGROUPS'][$ugroup];
             }
         }
     }
     $condition = new Workflow_Transition_Condition_Permissions($transition);
     $condition->setAuthorizedUgroupsKeyname($authorized_ugroups_keyname);
     return $condition;
 }
Пример #2
0
 /**
  * @param PFUser $user
  * @return Tuleap\Tracker\REST\WorkflowRepresentation | null
  */
 private function getWorkflowRepresentation(Workflow $workflow, PFUser $user, $project_id)
 {
     if (!$workflow->isUsed() || !$workflow->getField()->userCanRead($user)) {
         return;
     }
     $transitions = array();
     foreach ($workflow->getTransitions() as $transition) {
         $condition_permission = new Workflow_Transition_Condition_Permissions($transition);
         if ($condition_permission->isUserAllowedToSeeTransition($user, $project_id)) {
             $transitions[] = $this->getWorkflowTransitionRepresentation($transition);
         }
     }
     $workflow_representation = new WorkflowRepresentation();
     $workflow_representation->build($workflow->getFieldId(), $workflow->getIsUsed(), $this->getWorkflowRulesRepresentation($workflow), $transitions);
     return $workflow_representation;
 }