public function process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user) { $hp = Codendi_HTMLPurifier::instance(); $workflow = $this->workflow_factory->getWorkflowByTrackerId($this->tracker->id); $this->displayHeader($layout); echo '<h3>' . $GLOBALS['Language']->getText('workflow_admin', 'title_define_transitions') . '</h3>'; echo '<div class="workflow_transitions">'; if (count($workflow)) { $this->displayAdminWorkflow($layout, $request, $current_user, $workflow); } else { //Display creation form echo '<p>'; echo $GLOBALS['Language']->getText('workflow_admin', 'choose_field'); echo '<p>'; echo '<form action="' . TRACKER_BASE_URL . '/?' . http_build_query(array('tracker' => (int) $this->tracker->id, 'func' => Workflow::FUNC_ADMIN_TRANSITIONS)) . '" method="POST">'; echo '<SELECT name="field_id">'; //We display only the 'sb' static type field foreach ($this->form_element_factory->getUsedFormElementsByType($this->tracker, 'sb') as $field) { $bf = new Tracker_FormElement_Field_List_BindFactory(); if ($bf->getType($field->getBind()) == 'static') { echo '<OPTION value=' . $hp->purify($field->id) . '>' . $hp->purify($field->label) . '</OPTION>'; } } echo '</SELECT>'; echo '<br>'; echo '<input type="submit" name="create" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; echo '</form>'; } echo '</div>'; $this->displayFooter($layout); }
/** * Fetch additionnal stuff to display below the create form * Result if not empty must be enclosed in a <tr> * * @return string html */ public function fetchAfterAdminCreateForm() { $bf = new Tracker_FormElement_Field_List_BindFactory(); $html = ''; $html .= '<tr valign="top"><td colspan="2">'; $html .= $bf->fetchCreateABind($this->formElement); $html .= '</td></tr>'; return $html; }
public function createFormElement(Tracker $tracker, array $formElement_data, User $user) { $formElement = $this->factory->getFormElementById($formElement_data['field_id']); if (!$formElement) { $exception_message = $GLOBALS['Language']->getText('plugin_tracker_formelement_exception', 'wrong_field_id', $formElement_data['field_id']); throw new Exception($exception_message); } $field = $this->getRootOriginalField($formElement); $this->assertFieldCanBeCopied($field, $user); $data = $this->populateFormElementDataForASharedField($field); $type = $data['type']; $id = $this->factory->createFormElement($tracker, $type, $data); $this->boundValuesFactory->duplicateByReference($field->getId(), $id); return $id; }
/** * Transforms FormElement_List into a SimpleXMLElement * * @param SimpleXMLElement $root The node to which the FormElement is attached (passed by reference) * @param array &$xmlMapping The correpondance between real ids and xml IDs */ public function exportToXml(SimpleXMLElement $root, &$xmlMapping) { parent::exportToXML($root, $xmlMapping); if ($this->getBind() && $this->shouldBeBindXML()) { $child = $root->addChild('bind'); $bf = new Tracker_FormElement_Field_List_BindFactory(); $child->addAttribute('type', $bf->getType($this->getBind())); $this->getBind()->exportToXML($child, $xmlMapping); } }
/** * * @param SimpleXMLElement $root * @param array $xmlMapping * @param Tracker_FormElementFactory $form_element_factory * @param int $tracker_id */ public function exportToXml(SimpleXMLElement $root, $xmlMapping, $form_element_factory, $tracker_id) { $rules = $this->searchByTrackerId($tracker_id); $list_rules = $root->addChild('list_rules'); foreach ($rules as $rule) { $source_field = $form_element_factory->getFormElementById($rule->getSourceFieldId()); $target_field = $form_element_factory->getFormElementById($rule->getTargetFieldId()); $bf = new Tracker_FormElement_Field_List_BindFactory(); //TODO: handle sb/msb bind to users and remove condition if ($bf->getType($source_field->getBind()) == 'static' && $bf->getType($target_field->getBind()) == 'static') { $child = $list_rules->addChild('rule'); $child->addChild('source_field')->addAttribute('REF', array_search($rule->source_field, $xmlMapping)); $child->addChild('target_field')->addAttribute('REF', array_search($rule->target_field, $xmlMapping)); if ($rule->source_value == Tracker_FormElement_Field_List_Bind_StaticValue_None::VALUE_ID) { $child->addChild('source_value')->addAttribute('is_none', '1'); } else { $child->addChild('source_value')->addAttribute('REF', array_search($rule->source_value, $xmlMapping['values'])); } if ($rule->target_value == Tracker_FormElement_Field_List_Bind_StaticValue_None::VALUE_ID) { $child->addChild('target_value')->addAttribute('is_none', '1'); } else { $child->addChild('target_value')->addAttribute('REF', array_search($rule->target_value, $xmlMapping['values'])); } } } }
public function getSoapBindingProperties() { $bind_factory = new Tracker_FormElement_Field_List_BindFactory(); $bind_type = $bind_factory->getType($this); return array(self::SOAP_TYPE_KEY => $bind_type, self::SOAP_LIST_KEY => $this->getSoapBindingList()); }
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); } }
function itRaisesAnErrorIfUnkownType() { $factory = new Tracker_FormElement_Field_List_BindFactory(mock('UGroupManager')); $this->expectError('Unknown bind "unknown"'); $factory->getInstanceFromRow(array('type' => 'unknown', 'field' => 'a_field_object')); }