/** * @throws Tracker_Workflow_GlobalRulesViolationException */ public function checkGlobalRules(array $fields_data) { if ($this->disabled) { return true; } if (!$this->global_rules_manager->validate($this->tracker_id, $fields_data)) { throw new Tracker_Workflow_GlobalRulesViolationException(); } }
/** * Is the field used in a field dependency? * * @return boolean returns true if the field is used in field dependency, false otherwise */ public function isUsedInFieldDependency() { $rm = new Tracker_RulesManager($this->getTracker()); return $rm->isUsedInFieldDependency($this); }
/** * Display the artifact * * @param Tracker_IDisplayTrackerLayout $layout Displays the page header and footer * @param Codendi_Request $request The data coming from the user * @param User $current_user The current user * * @return void */ public function display(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { $hp = Codendi_HTMLPurifier::instance(); $tracker = $this->getTracker(); $title = $hp->purify($tracker->item_name, CODENDI_PURIFIER_CONVERT_HTML) . ' #' . $this->id; $breadcrumbs = array(array('title' => $title, 'url' => TRACKER_BASE_URL . '/?aid=' . $this->id)); $tracker->displayHeader($layout, $title, $breadcrumbs); $current_user->addRecentElement($this); $from_aid = $request->get('from_aid'); $html = ''; $redirect = new Tracker_Artifact_Redirect(); $redirect->base_url = TRACKER_BASE_URL; $redirect->query_parameters = array('aid' => $this->id, 'func' => 'artifact-update'); if ($from_aid != null) { $redirect->query_parameters['from_aid'] = $from_aid; } EventManager::instance()->processEvent(TRACKER_EVENT_BUILD_ARTIFACT_FORM_ACTION, array('request' => $request, 'redirect' => $redirect)); $html .= '<form action="' . $redirect->toUrl() . '" method="POST" enctype="multipart/form-data">'; $html .= '<input type="hidden" value="67108864" name="max_file_size" />'; $html .= $this->fetchTitleInHierarchy($current_user); $html .= $this->fetchFields($request->get('artifact')); $html .= $this->fetchFollowUps($current_user, $request->get('artifact_followup_comment')); // We don't need History since we have changesets //$html .= $this->_fetchHistory(); $html .= '</form>'; $trm = new Tracker_RulesManager($tracker); $html .= $trm->displayRulesAsJavascript(); echo $html; $tracker->displayFooter($layout); exit; }
/** * Display the submit form */ public function displaySubmit(Tracker_IFetchTrackerSwitcher $layout, $request, $current_user, $link = null) { $hp = Codendi_HTMLPurifier::instance(); $breadcrumbs = array(array('title' => 'New artifact', 'url' => $this->getSubmitUrl())); if (!$link) { $this->displayHeader($layout, $this->name, $breadcrumbs); } if ($link) { echo '<html>'; echo '<head>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; $GLOBALS['HTML']->displayStylesheetElements(array()); $GLOBALS['HTML']->includeCalendarScripts(); $GLOBALS['HTML']->displayJavascriptElements(array()); echo '</head>'; echo '<body>'; echo '<div class="main_body_row">'; echo '<div class="contenttable">'; $project = null; $artifact = Tracker_ArtifactFactory::instance()->getArtifactByid($link); if ($artifact) { $project = $artifact->getTracker()->getProject(); $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_tracker', 'linked_to', array($artifact->fetchDirectLinkToArtifact(), $layout->fetchTrackerSwitcher($current_user, ' ', $project, $this))), CODENDI_PURIFIER_DISABLED); } else { $GLOBALS['Response']->addFeedback('error', 'Error the artifact to link doesn\'t exist'); } $GLOBALS['Response']->displayFeedback(); } $html = ''; if ($this->submit_instructions) { $html .= '<p class="submit_instructions">' . $hp->purify($this->submit_instructions, CODENDI_PURIFIER_FULL) . '</p>'; } $redirect = new Tracker_Artifact_Redirect(); $redirect->base_url = TRACKER_BASE_URL; $redirect->query_parameters = array('tracker' => $this->id, 'func' => 'submit-artifact'); EventManager::instance()->processEvent(TRACKER_EVENT_BUILD_ARTIFACT_FORM_ACTION, array('request' => $request, 'redirect' => $redirect)); $html .= '<form action="' . $redirect->toUrl() . '" method="POST" enctype="multipart/form-data">'; if ($link) { $html .= '<input type="hidden" name="link-artifact-id" value="' . (int) $link . '" />'; if ($request->get('immediate')) { $html .= '<input type="hidden" name="immediate" value="1" />'; } } $html .= '<input type="hidden" value="67108864" name="max_file_size" />'; $html .= '<table><tr><td>'; foreach ($this->getFormElements() as $formElement) { $html .= $formElement->fetchSubmit($request->get('artifact')); } $html .= '</td></tr></table>'; if ($current_user->isAnonymous()) { $html .= $this->fetchAnonymousEmailForm(); } if (!$link) { $html .= '<input type="submit" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; $html .= ' '; $html .= '<input type="submit" name="submit_and_continue" value="' . $GLOBALS['Language']->getText('global', 'btn_submit_and_continue') . '" />'; $html .= '<input type="submit" name="submit_and_stay" value="' . $GLOBALS['Language']->getText('global', 'btn_submit_and_stay') . '" />'; } else { $html .= '<input type="submit" id="tracker_artifact_submit" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; } $html .= '</form>'; $trm = new Tracker_RulesManager($this); $html .= $trm->displayRulesAsJavascript(); $html .= '</div></div>'; echo $html; if (!$link) { $this->displayFooter($layout); } }
/** * Is the field used in a field dependency? * * @return boolean returns true if the field is used in field dependency, false otherwise */ public function isUsedInFieldDependency() { $rm = new Tracker_RulesManager($this->getTracker(), Tracker_FormElementFactory::instance()); return $rm->isUsedInFieldDependency($this); }
function testExportToXmlCallsRuleListFactoryExport() { $xml_data = <<<XML <?xml version="1.0" encoding="UTF-8"?> <tracker /> XML; $sax_object = new SimpleXMLElement($xml_data); $xmlMapping = array(); $tracker = mock('Tracker'); $form_element_factory = mock('Tracker_FormElementFactory'); $manager = new Tracker_RulesManager($tracker, $form_element_factory); stub($tracker)->getId()->returns(45); $date_factory = mock('Tracker_Rule_Date_Factory'); stub($date_factory)->exportToXml($sax_object, $xmlMapping, 45)->once(); $list_factory = mock('Tracker_Rule_List_Factory'); stub($list_factory)->exportToXml($sax_object, $xmlMapping, $form_element_factory, 45)->once(); $manager->setRuleDateFactory($date_factory); $manager->setRuleListFactory($list_factory); $manager->exportToXml($sax_object, $xmlMapping); }