public function fetchTypeForUpdate() { $html = ''; $html .= '<p><label for="formElement_type">' . $GLOBALS['Language']->getText('plugin_tracker_include_type', 'type') . ': </label><br />'; $html .= '<img width="16" height="16" alt="" src="' . $this->formElement->getFactoryIconUseIt() . '" style="vertical-align:middle"/> ' . $this->formElement->getFactoryLabel(); //do not change from SB to MSB if the field is used to define the workflow $wf = WorkflowFactory::instance(); if (!$wf->isWorkflowField($this->formElement)) { $html .= ' (<a href="' . TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => $this->formElement->tracker_id, 'func' => 'admin-formElement-update', 'formElement' => $this->formElement->id, 'change-type' => 'msb')) . '" onclick="return confirm(\'' . $GLOBALS['Language']->getText('plugin_tracker_formelement_admin', 'switch_type_confirm') . '\');">' . $GLOBALS['Language']->getText('plugin_tracker_formelement_admin', 'switch_msb') . '</a>)'; } $html .= '</p>'; return $html; }
public function process(TrackerManager $engine, Codendi_Request $request, PFUser $current_user) { $workflow_factory = WorkflowFactory::instance(); if ($request->get('func') == Workflow::FUNC_ADMIN_RULES) { $token = new CSRFSynchronizerToken(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => Workflow::FUNC_ADMIN_RULES))); $rule_date_factory = new Tracker_Rule_Date_Factory(new Tracker_Rule_Date_Dao(), Tracker_FormElementFactory::instance()); $action = new Tracker_Workflow_Action_Rules_EditRules($this->tracker, $rule_date_factory, $token); } elseif ($request->get('func') == Workflow::FUNC_ADMIN_CROSS_TRACKER_TRIGGERS) { $token = new CSRFSynchronizerToken(TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => Workflow::FUNC_ADMIN_CROSS_TRACKER_TRIGGERS))); $renderer = TemplateRendererFactory::build()->getRenderer(TRACKER_BASE_DIR . '/../templates'); $action = new Tracker_Workflow_Action_Triggers_EditTriggers($this->tracker, $token, $renderer, $workflow_factory->getTriggerRulesManager()); } else { if ($request->get('func') == Workflow::FUNC_ADMIN_GET_TRIGGERS_RULES_BUILDER_DATA) { $action = new Tracker_Workflow_Action_Triggers_GetTriggersRulesBuilderData($this->tracker, Tracker_FormElementFactory::instance()); } else { if ($request->get('func') == Workflow::FUNC_ADMIN_ADD_TRIGGER) { $action = new Tracker_Workflow_Action_Triggers_AddTrigger($this->tracker, Tracker_FormElementFactory::instance(), $workflow_factory->getTriggerRulesManager()); } else { if ($request->get('func') == Workflow::FUNC_ADMIN_DELETE_TRIGGER) { $action = new Tracker_Workflow_Action_Triggers_DeleteTrigger($this->tracker, $workflow_factory->getTriggerRulesManager()); } else { if ($request->get('create')) { $action = new Tracker_Workflow_Action_Transitions_Create($this->tracker, $workflow_factory); } else { if ($request->get('edit_transition')) { $action = new Tracker_Workflow_Action_Transitions_EditTransition($this->tracker, TransitionFactory::instance(), new Transition_PostActionFactory()); } else { if ($request->get('delete')) { $action = new Tracker_Workflow_Action_Transitions_Delete($this->tracker, $workflow_factory); } else { if ($request->get('transitions')) { $action = new Tracker_Workflow_Action_Transitions_CreateMatrix($this->tracker, $workflow_factory, Tracker_FormElementFactory::instance()); } else { if ($request->get('workflow_details')) { $action = new Tracker_Workflow_Action_Transitions_Details($this->tracker, TransitionFactory::instance()); } else { $action = new Tracker_Workflow_Action_Transitions_DefineWorkflow($this->tracker, WorkflowFactory::instance(), Tracker_FormElementFactory::instance()); } } } } } } } } } $action->process($engine, $request, $current_user); }
/** * Build a Transition instance * * @param Array $row The data describing the transition * @param Workflow $workflow Workflow the transition belongs to * * @return Transition */ public function getInstanceFromRow($row, Workflow $workflow = null) { if (!$workflow) { $workflow = WorkflowFactory::instance()->getWorkflow($row['workflow_id']); } $field_values = $workflow->getAllFieldValues(); $from = null; $to = null; if (isset($field_values[$row['from_id']])) { $from = $field_values[$row['from_id']]; } if (isset($field_values[$row['to_id']])) { $to = $field_values[$row['to_id']]; } $transition = new Transition($row['transition_id'], $row['workflow_id'], $from, $to); $this->getPostActionFactory()->loadPostActions($transition); return $transition; }
public function testImport() { $xml = simplexml_load_file(dirname(__FILE__) . '/_fixtures/importWorkflow.xml'); $tracker = new MockTracker(); $mapping = array('F1' => 110, 'F32' => 111, 'F32-V0' => 801, 'F32-V1' => 802); $workflow = WorkflowFactory::instance()->getInstanceFromXML($xml, $mapping, $tracker); $this->assertEqual($workflow->getIsUsed(), 1); $this->assertEqual($workflow->getFieldId(), 111); $this->assertEqual(count($workflow->getTransitions()), 3); // Test post actions $transitions = $workflow->getTransitions(); $this->assertEqual(count($transitions[0]->getPostActions()), 0); $this->assertEqual(count($transitions[1]->getPostActions()), 0); $this->assertEqual(count($transitions[2]->getPostActions()), 1); // There is one post action on last transition $postactions = $transitions[2]->getPostActions(); $this->assertEqual($postactions[0]->getField(), 110); $this->assertEqual($postactions[0]->getValueType(), 1); //Test permissions $permissions = $transitions[2]->getPermissions(); $this->assertEqual($permissions[0], 3); }
/** * @return TrackerXmlImport */ public static function build() { $builder = new Tracker_Artifact_XMLImportBuilder(); $tracker_factory = TrackerFactory::instance(); return new TrackerXmlImport($tracker_factory, EventManager::instance(), new Tracker_Hierarchy_Dao(), Tracker_CannedResponseFactory::instance(), Tracker_FormElementFactory::instance(), Tracker_SemanticFactory::instance(), new Tracker_RuleFactory(new Tracker_RuleDao()), Tracker_ReportFactory::instance(), WorkflowFactory::instance(), new XML_RNGValidator(), $tracker_factory->getTriggerRulesManager(), $builder->build()); }
/** * Get the workflow of the tracker. * @return Workflow Object */ public function getWorkflow() { return WorkflowFactory::instance()->getWorkflowByTrackerId($this->tracker_id); }
/** * Saves a Tracker object into the DataBase * * @param Tracker $tracker object to save * @return int id of the newly created tracker */ public function saveObject($tracker) { // create tracker $tracker_id = $this->getDao()->create($tracker->group_id, $tracker->name, $tracker->description, $tracker->item_name, $tracker->allow_copy, $tracker->submit_instructions, $tracker->browse_instructions, '', '', $tracker->instantiate_for_new_projects, $tracker->stop_notification); if ($tracker_id) { $trackerDB = $this->getTrackerById($tracker_id); //create cannedResponses $response_factory = $tracker->getCannedResponseFactory(); foreach ($tracker->cannedResponses as $response) { $response_factory->saveObject($tracker_id, $response); } //create formElements foreach ($tracker->formElements as $formElement) { // these fields have no parent Tracker_FormElementFactory::instance()->saveObject($trackerDB, $formElement, 0); } //create report foreach ($tracker->reports as $report) { Tracker_ReportFactory::instance()->saveObject($tracker_id, $report); } //create semantics if (isset($tracker->semantics)) { foreach ($tracker->semantics as $semantic) { Tracker_SemanticFactory::instance()->saveObject($semantic, $trackerDB); } } //create workflow if (isset($tracker->workflow)) { WorkflowFactory::instance()->saveObject($tracker->workflow, $trackerDB); } //tracker permissions if ($tracker->permissionsAreCached()) { $pm = PermissionsManager::instance(); foreach ($tracker->getPermissions() as $ugroup => $permissions) { foreach ($permissions as $permission) { $pm->addPermission($permission, $tracker_id, $ugroup); } } } else { $this->saveTrackerDefaultPermission($tracker_id); } $this->postCreateActions($trackerDB); } return $tracker_id; }
/** * Is the field used in workflow? * * @return boolean returns true if the field is used in workflow, false otherwise */ public function isUsedInWorkflow() { $wf = WorkflowFactory::instance(); return $wf->isFieldUsedInWorkflow($this); }
/** * Change the type of the button * @param string $type the new type * * @return boolean true if the change is allowed and successful */ public function changeType($type) { if (in_array($type, array('msb', 'cb'))) { //do not change from SB to MSB if the field is used to define the workflow $wf = WorkflowFactory::instance(); return !$wf->isWorkflowField($this); } elseif ($type === 'sb') { return true; } return false; }
/** * Return Workflow the artifact should respect * * @return Workflow */ public function getWorkflow() { $workflow = WorkflowFactory::instance()->getWorkflowByTrackerId($this->getTrackerId()); if ($workflow) { $workflow->setArtifact($this); } return $workflow; }
/** * Get WorkflowFactory instance * * @return WorkflowFactory */ protected function getWorkflowFactory() { return WorkflowFactory::instance(); }
protected function displayAdminDefineWorkflow($engine, $request, $current_user) { $hp = Codendi_HTMLPurifier::instance(); $this->tracker->displayAdminItemHeader($engine, 'editworkflow'); echo '<h3>' . $GLOBALS['Language']->getText('workflow_admin', 'title') . '</h3>'; $workflow = WorkflowFactory::instance()->getWorkflowByTrackerId($this->tracker->id); if (count($workflow)) { $this->displayAdminWorkflow($engine, $request, $current_user, $workflow); } else { //Display creation form echo '<p>'; echo $GLOBALS['Language']->getText('workflow_admin', 'choose_field'); echo '<p>'; $aff = Tracker_FormElementFactory::instance(); echo '<form action="' . TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => 'admin-workflow')) . '" method="POST">'; echo '<SELECT name="field_id">'; //We display only the 'sb' static type field foreach ($aff->getUsedFormElementsByType($this->tracker, 'sb') as $field) { $bf = new Tracker_FormElement_Field_List_BindFactory(); if ($bf->getType($field->getBind()) == 'static') { echo '<OPTION value=' . $field->id . '>' . $field->label . '</OPTION>'; } } echo '</SELECT>'; echo '<input type="submit" name="create" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; echo '</from>'; $this->tracker->displayFooter($engine); } }
/** * Get parent workflow * * @return Workflow */ public function getWorkflow() { if (!$this->workflow) { $this->workflow = WorkflowFactory::instance()->getWorkflow($this->workflow_id); } return $this->workflow; }
/** * Change the type of the select box * * @param string $type the new type * * @return boolean true if the change is allowed and successful */ public function changeType($type) { // only "msb" available at the moment. if ($type === 'msb') { //do not change from SB to MSB if the field is used to define the workflow $wf = WorkflowFactory::instance(); return !$wf->isWorkflowField($this); } return false; }
public function getTransitionIdFromTo($field_value_from, $field_value_to) { $res = WorkflowFactory::instance()->getTransitionIdFromTo($this->workflow_id, $field_value_from, $field_value_to); $row = $res->getRow(); return $row['transition_id']; }