private function displayTransitionDetails(TrackerManager $engine, Codendi_Request $request, PFUser $current_user, Transition $transition) { $hp = Codendi_HTMLPurifier::instance(); $this->displayHeader($engine); if ($transition->getFieldValueFrom()) { $from_label = $transition->getFieldValueFrom()->getLabel(); } else { $from_label = $GLOBALS['Language']->getText('workflow_admin', 'new_artifact'); } $to_label = $transition->getFieldValueTo()->getLabel(); echo '<h3>'; echo $GLOBALS['Language']->getText('workflow_admin', 'title_define_transition_details', array($hp->purify($from_label), $hp->purify($to_label))); echo '</h3>'; $form_action = TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => Workflow::FUNC_ADMIN_TRANSITIONS, 'transition' => $transition->getId())); echo '<form action="' . $form_action . '" method="POST">'; echo '<table><tr><td>'; $section_conditions = new Widget_Static($GLOBALS['Language']->getText('workflow_admin', 'under_the_following_condition')); $section_conditions->setContent($transition->fetchConditions()); $section_conditions->display(); $actions = ''; $actions .= $transition->fetchPostActions(); $actions .= $this->post_action_factory->fetchPostActions(); $section_postactions = new Widget_Static($GLOBALS['Language']->getText('workflow_admin', 'following_action_performed')); $section_postactions->setContent($actions); $section_postactions->display(); $back_to_transitions_link = TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => Workflow::FUNC_ADMIN_TRANSITIONS)); echo '<p>'; echo '<a href="' . $back_to_transitions_link . '">←' . $GLOBALS['Language']->getText('plugin_tracker_admin', 'clean_cancel') . '</a>'; echo ' '; echo '<input type="submit" name="workflow_details" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; echo '</p>'; echo '</td></tr></table>'; echo '</form>'; $this->displayFooter($engine); }
/** * Creates transition in the database * * @param int $workflow_id The workflow_id of the transitions to save * @param Transition $transition The transition * * @return void */ public function saveObject($workflow_id, $transition) { $dao = $this->getDao(); if ($transition->getFieldValueFrom() == null) { $from_id = null; } else { $from_id = $transition->getFieldValueFrom()->getId(); } $to_id = $transition->getFieldValueTo()->getId(); $transition_id = $dao->addTransition($workflow_id, $from_id, $to_id); $transition->setTransitionId($transition_id); //Save postactions $postactions = $transition->getAllPostActions(); foreach ($postactions as $postaction) { $tpaf = $this->getPostActionFactory(); $tpaf->saveObject($postaction); } //Save conditions $transition->getConditions()->saveObject(); }
protected function displayTransitionDetails(TrackerManager $engine, Codendi_Request $request, User $current_user, Transition $transition) { $hp = Codendi_HTMLPurifier::instance(); $this->tracker->displayAdminItemHeader($engine, 'editworkflow'); echo '<h3>' . $GLOBALS['Language']->getText('workflow_admin', 'title') . '</h3>'; if ($transition->getFieldValueFrom()) { $from_label = $transition->getFieldValueFrom()->getLabel(); } else { $from_label = $GLOBALS['Language']->getText('workflow_admin', 'new_artifact'); } $to_label = $transition->getFieldValueTo()->getLabel(); echo '<p>'; echo $GLOBALS['Language']->getText('workflow_admin', 'title_define_transition_details', array($from_label, $to_label)); echo '</p>'; $form_action = TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow', 'transition' => $transition->getTransitionId())); echo '<form action="' . $form_action . '" method="POST">'; echo '<table><tr><td>'; $section_conditions = new Widget_Static($GLOBALS['Language']->getText('workflow_admin', 'under_the_following_condition')); $section_conditions->setContent($this->fetchWorkflowPermissions($transition)); $section_conditions->display(); $tpaf = $this->getPostActionFactory(); $actions = ''; $actions .= $transition->fetchPostActions(); $actions .= $tpaf->fetchPostActions(); $section_postactions = new Widget_Static($GLOBALS['Language']->getText('workflow_admin', 'following_action_performed')); $section_postactions->setContent($actions); $section_postactions->display(); echo '<p><input type="submit" name="workflow_details" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" /></p>'; echo '</td></tr></table>'; echo '</form>'; $this->tracker->displayFooter($engine); }
/** * Says if this transition is equals to another transtion * * @param Transition $transition The transition to compare * * @return bool */ public function equals(Transition $transition) { $source_from = $this->getFieldValueFrom(); $source_to = $this->getFieldValueTo(); $target_from = $transition->getFieldValueFrom(); $target_to = $transition->getFieldValueTo(); return is_null($source_from) && is_null($target_from) && is_null($source_to) && is_null($target_to) || is_null($source_from) && is_null($target_from) && !is_null($source_to) && !is_null($target_to) && $source_to->getId() === $target_to->getId() || !is_null($source_from) && !is_null($target_from) && is_null($source_to) && is_null($target_to) && $source_from->getId() === $target_from->getId() || !is_null($source_from) && !is_null($target_from) && !is_null($source_to) && !is_null($target_to) && $source_from->getId() === $target_from->getId() && $source_to->getId() === $target_to->getId(); }