5 * Copyright 2004 (c) Dominik Haas, GForge Team
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
25 require_once $gfcommon.'search/TasksSearchQuery.class.php';
27 class TasksHtmlSearchRenderer extends HtmlGroupSearchRenderer {
32 * @param string $words words we are searching for
33 * @param int $offset offset
34 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
35 * @param int $groupId group id
36 * @param array $sections array of all sections to search in (array of strings)
39 function TasksHtmlSearchRenderer($words, $offset, $isExact, $groupId, $sections=SEARCH__ALL_SECTIONS) {
40 $userIsGroupMember = $this->isGroupMember($groupId);
42 $searchQuery = new TasksSearchQuery($words, $offset, $isExact, $groupId, $sections, $userIsGroupMember);
44 $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_TASKS, $words, $isExact, $searchQuery, $groupId, 'pm');
46 $this->tableHeaders = array(
57 function getFilteredRows() {
58 $rowsCount = $this->searchQuery->getRowsCount();
59 $result =& $this->searchQuery->getResult();
61 $fields = array ('group_project_id',
71 for($i = 0; $i < $rowsCount; $i++) {
72 if (forge_check_perm('pm',
73 db_result($result, $i, 'group_project_id'),
76 foreach ($fields as $f) {
77 $r[$f] = db_result($result, $i, $f);
86 * getRows - get the html output for result rows
88 * @return string html output
91 $fd = $this->getFilteredRows();
93 $dateFormat = _('Y-m-d H:i');
97 $lastProjectName = null;
99 foreach ($fd as $row) {
101 $currentProjectName = $row['project_name'];
102 if ($lastProjectName != $currentProjectName) {
103 $return .= '<tr><td colspan="7">'.$currentProjectName.'</td></tr>';
104 $lastProjectName = $currentProjectName;
107 $return .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($rowColor) .'>'
108 . ' <td width="5%"> </td>'
109 . ' <td>'.$row['project_task_id'].'</td>'
111 . '<a href="'.util_make_url ('/pm/task.php?func=detailtask&project_task_id=' . $row['project_task_id'].'&group_id='.$this->groupId . '&group_project_id='.$row['group_project_id']).'">'
112 . html_image('ic/msg.png', '10', '12').' '
113 . $row['summary'].'</a></td>'
114 . ' <td width="15%">'.date($dateFormat, $row['start_date']).'</td>'
115 . ' <td width="15%">'.date($dateFormat, $row['end_date']).'</td>'
116 . ' <td width="15%">'.$row['realname'].'</td>'
117 . ' <td width="8%">'.$row['percent_complete'].' %</td></tr>';
124 * getSections - get the array of possible sections to search in
126 * @return array sections
128 static function getSections($groupId) {
129 $userIsGroupMember = TasksHtmlSearchRenderer::isGroupMember($groupId);
131 return TasksSearchQuery::getSections($groupId, $userIsGroupMember);