public function getSlicedChildrenArtifactsForUser(Tracker_Artifact $artifact, PFUser $user, $limit, $offset) { $children = array(); $paginated_children = $this->getPaginatedChildrenOfArtifact($artifact, $limit, $offset); $total_size = $this->artifact_dao->foundRows(); foreach ($paginated_children as $child) { if ($child->userCanView($user)) { $children[] = $child; } } return new Tracker_SlicedArtifacts($children, $total_size); }
/** @return AgileDashboard_Milestone_Backlog_DescendantItemsCollection */ public function getMilestoneUnplannedBacklogItemsWithLimitAndOffset(PFUser $user, $sub_milestone_ids, $limit, $offset) { $result = $this->artifact_dao->getLinkedArtifactsOfTrackersNotLinkedToOthersWithLimitAndOffset($this->milestone_id, $this->descendant_tracker_ids, $sub_milestone_ids, $this->getDescendantPlannifiableItems(), $limit, $offset); return $this->getItemsForUser($user, $result, $this->artifact_dao->foundRows()); }
/** * Display the submit form */ public function displaySearch(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { $hp = Codendi_HTMLPurifier::instance(); $pm = ProjectManager::instance(); $group_id = $request->get('group_id'); $group = $pm->getProject($group_id); if (!$group || !is_object($group) || $group->isError()) { exit_no_group(); } $breadcrumbs = array(array('title' => $GLOBALS['Language']->getText('plugin_tracker_browse', 'search_result'), 'url' => TRACKER_BASE_URL . '/?tracker=' . $this->getId())); $this->displayHeader($layout, $this->name, $breadcrumbs); $html = ''; $words = $request->get('words'); $criteria = 'OR'; if ($request->exist('exact') && $request->get('exact') == '1') { $criteria = 'AND'; } $offset = 0; if ($request->exist('offset')) { $offset = $request->get('offset'); } $limit = 25; $tracker_artifact_dao = new Tracker_ArtifactDao(); $dar = $tracker_artifact_dao->searchByKeywords($this->getId(), $words, $criteria, $offset, $limit); $rows_returned = $tracker_artifact_dao->foundRows(); $no_rows = false; if ($dar->rowCount() < 1 || $rows_returned < 1) { $no_rows = true; $html .= '<h2>' . $GLOBALS['Language']->getText('search_index', 'no_match_found', $hp->purify($words, CODENDI_PURIFIER_CONVERT_HTML)) . '</h2>'; } else { $html .= '<h3>' . $GLOBALS['Language']->getText('search_index', 'search_res', array($hp->purify($words, CODENDI_PURIFIER_CONVERT_HTML), $rows_returned)) . '</h3>'; $title_arr = array(); $art_field_fact = Tracker_FormElementFactory::instance(); $artifact_factory = Tracker_ArtifactFactory::instance(); $user_helper = UserHelper::instance(); $summary_field = $this->getTitleField(); if ($summary_field && $summary_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('plugin_tracker_search_index', 'artifact_title'); } $submitted_field = $art_field_fact->getFormElementByName($this->getId(), 'submitted_by'); if ($submitted_field && $submitted_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('search_index', 'submitted_by'); } $date_field = $art_field_fact->getFormElementByName($this->getId(), 'open_date'); if ($date_field && $date_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('search_index', 'date'); } $status_field = $this->getStatusField(); if ($status_field && $status_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('global', 'status'); } $html .= html_build_list_table_top($title_arr); $nb_artifacts = 0; while ($row = $dar->getRow()) { $nb_artifacts++; $artifact_id = $row['artifact_id']; $artifact = $artifact_factory->getArtifactById($artifact_id); if ($artifact->userCanView()) { $html .= '<tr class="' . html_get_alt_row_color($nb_artifacts) . '">'; if ($summary_field->userCanRead()) { $html .= '<td><a href="' . TRACKER_BASE_URL . '/?aid=' . $artifact_id . '"><img src="' . util_get_image_theme('msg.png') . '" border="0" height="12" width="10"> ' . $artifact->getTitle() . '</a></td>'; } if ($submitted_field->userCanRead()) { $html .= '<td>' . $hp->purify($user_helper->getDisplayNameFromUserId($artifact->getSubmittedBy())) . '</td>'; } if ($date_field->userCanRead()) { $html .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $artifact->getSubmittedOn()) . '</td>'; } if ($status_field->userCanRead()) { $html .= '<td>' . $artifact->getStatus() . '</td>'; } $html .= '</tr>'; } } $html .= '</table>'; } // Search result pagination if (!$no_rows && ($rows_returned > $nb_artifacts || $offset != 0)) { $html .= '<br />'; $url_params = array('exact' => $request->get('exact') === '1' ? 1 : 0, 'group_id' => $this->getGroupId(), 'tracker' => $this->getId(), 'type_of_search' => 'tracker', 'words' => urlencode($words), 'offset' => $offset - $limit); $html .= '<table class="boxitem" width="100%" cellpadding="5" cellspacing="0">'; $html .= '<tr>'; $html .= '<td align="left">'; if ($offset != 0) { $html .= '<span class="normal"><b>'; $html .= '<a href="/search/?' . http_build_query($url_params); $html .= '">' . "<b><img src=\"" . util_get_image_theme('t2.png') . "\" height=15 width=15 border=0 align=middle> " . $GLOBALS['Language']->getText('search_index', 'prev_res') . " </a></b></span>"; } else { $html .= ' '; } $html .= '</td><td align="right">'; if ($rows_returned > $nb_artifacts && $rows_returned > $offset + $limit) { $url_params['offset'] = $offset + $limit; $html .= '<span class="normal"><b>'; $html .= '<a href="/search/?' . http_build_query($url_params); $html .= '"><b>' . $GLOBALS['Language']->getText('search_index', 'next_res') . ' <img src="' . util_get_image_theme('t.png') . '" height="15" width="15" border="0" align="middle"></a></b></span>'; } else { $html .= ' '; } $html .= '</td></tr>'; $html .= '</table>'; } echo $html; $this->displayFooter($layout); }