/** * @see Tracker_FormElement::process() */ public function process(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { parent::process($layout, $request, $current_user); if ($request->get('func') == 'get-values') { $GLOBALS['Response']->sendJSON($this->getBind()->fetchFormattedForJson()); } }
/** * Process the request * * @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 user who mades the request * * @return void */ public function process(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { switch ($request->get('func')) { case 'fetch-artifacts': $read_only = false; $prefill_removed_values = array(); $only_rows = true; $this_project_id = $this->getTracker()->getProject()->getGroupId(); $hp = Codendi_HTMLPurifier::instance(); $ugroups = $current_user->getUgroups($this_project_id, array()); $ids = $request->get('ids'); //2, 14, 15 $tracker = array(); $result = array(); //We must retrieve the last changeset ids of each artifact id. $dao = new Tracker_ArtifactDao(); foreach ($dao->searchLastChangesetIds($ids, $ugroups, $current_user->isSuperUser()) as $matching_ids) { $tracker_id = $matching_ids['tracker_id']; $tracker = $this->getTrackerFactory()->getTrackerById($tracker_id); $project = $tracker->getProject(); if ($tracker->userCanView()) { $trf = Tracker_ReportFactory::instance(); $report = $trf->getDefaultReportsByTrackerId($tracker->getId()); if ($report) { $renderers = $report->getRenderers(); // looking for the first table renderer foreach ($renderers as $renderer) { if ($renderer->getType() === Tracker_Report_Renderer::TABLE) { $key = $this->id . '_' . $report->id . '_' . $renderer->getId(); $result[$key] = $renderer->fetchAsArtifactLink($matching_ids, $this->getId(), $read_only, $prefill_removed_values, $only_rows); $head = '<div>'; $project_name = ''; if ($project->getGroupId() != $this_project_id) { $project_name = ' (<abbr title="' . $hp->purify($project->getPublicName(), CODENDI_PURIFIER_CONVERT_HTML) . '">'; $project_name .= $hp->purify($project->getUnixName(), CODENDI_PURIFIER_CONVERT_HTML); $project_name .= '</abbr>)'; } $head .= '<h2 class="tracker-form-element-artifactlink-tracker_' . $tracker->getId() . '">'; $head .= $hp->purify($tracker->getName(), CODENDI_PURIFIER_CONVERT_HTML) . $project_name; $head .= '</h2>'; //if ($artifact) { // $title = $hp->purify('link a '. $tracker->getItemName(), CODENDI_PURIFIER_CONVERT_HTML); // $head .= '<a href="'.TRACKER_BASE_URL.'/?tracker='.$tracker_id.'&func=new-artifact-link&id='.$artifact->getId().'" class="tracker-form-element-artifactlink-link-new-artifact">'. 'create a new '.$hp->purify($tracker->getItemName(), CODENDI_PURIFIER_CONVERT_HTML) .'</a>'; //} $result[$key]['head'] = $head . $result[$key]['head']; break; } } } } } if ($result) { $head = array(); $rows = array(); foreach ($result as $key => $value) { $head[$key] = $value["head"]; $rows[$key] = $value["rows"]; } header('Content-type: application/json'); echo json_encode(array('head' => $head, 'rows' => $rows)); } exit; break; case 'fetch-aggregates': $read_only = false; $prefill_removed_values = array(); $only_rows = true; $only_one_column = false; $extracolumn = Tracker_Report_Renderer_Table::EXTRACOLUMN_UNLINK; $read_only = true; $use_data_from_db = false; $ugroups = $current_user->getUgroups($this->getTracker()->getGroupId(), array()); $ids = $request->get('ids'); //2, 14, 15 $tracker = array(); $json = array('tabs' => array()); $dao = new Tracker_ArtifactDao(); foreach ($dao->searchLastChangesetIds($ids, $ugroups, $current_user->isSuperUser()) as $matching_ids) { $tracker_id = $matching_ids['tracker_id']; $tracker = $this->getTrackerFactory()->getTrackerById($tracker_id); $project = $tracker->getProject(); if ($tracker->userCanView()) { $trf = Tracker_ReportFactory::instance(); $report = $trf->getDefaultReportsByTrackerId($tracker->getId()); if ($report) { $renderers = $report->getRenderers(); // looking for the first table renderer foreach ($renderers as $renderer) { if ($renderer->getType() === Tracker_Report_Renderer::TABLE) { $key = $this->id . '_' . $report->id . '_' . $renderer->getId(); $columns = $renderer->getTableColumns($only_one_column, $use_data_from_db); $extracted_fields = $renderer->extractFieldsFromColumns($columns); $json['tabs'][] = array('key' => $key, 'src' => $renderer->fetchAggregates($matching_ids, $extracolumn, $only_one_column, $columns, $extracted_fields, $use_data_from_db, $read_only)); break; } } } } } header('Content-type: application/json'); echo json_encode($json); exit; break; default: parent::process($layout, $request, $current_user); break; } }
/** * * @param Tracker_IDisplayTrackerLayout $layout * @param Codendi_Request $request * @param User $current_user */ public function process(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { switch ($request->get('func')) { case self::FUNC_SHOW_BURNDOWN: try { $artifact_id = $request->getValidated('src_aid', 'uint', 0); $artifact = Tracker_ArtifactFactory::instance()->getArtifactById($artifact_id); if (!$artifact) { return false; } $this->fetchBurndownImage($artifact, $current_user); } catch (Tracker_FormElement_Field_BurndownException $e) { $this->displayErrorImage($GLOBALS['Language']->getText('plugin_tracker', $e->getMessage())); } break; default: parent::process($layout, $request, $current_user); } }