3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once('Widget.class.php');
22 require_once('common/widget/WidgetLayoutManager.class.php');
23 require_once $gfwww.'include/my_utils.php';
28 * Tasks assigned to me
30 class Widget_MyTasks extends Widget {
32 var $can_be_displayed;
34 function Widget_MyTasks() {
35 $this->Widget('mytasks');
37 $this->setOwner(user_getid(), WidgetLayoutManager::OWNER_TYPE_USER);
40 $sql = 'SELECT groups.group_id, groups.group_name, project_group_list.group_project_id, project_group_list.project_name '.
41 'FROM groups,project_group_list,project_task,project_assigned_to '.
42 'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
43 'AND project_assigned_to.assigned_to_id=$1'.
44 ' AND project_task.status_id=1 AND project_group_list.group_id=groups.group_id '.
45 "AND project_group_list.is_public!='9' ".
46 'AND project_group_list.group_project_id=project_task.group_project_id GROUP BY groups.group_id, groups.group_name, project_group_list.project_name, project_group_list.group_project_id';
48 $result=db_query_params($sql,array(user_getid()));
49 $rows=db_numrows($result);
51 if ($result && $rows >= 1) {
52 $request =& HTTPRequest::instance();
53 $this->content .= '<table style="width:100%">';
54 for ($j=0; $j<$rows; $j++) {
56 $group_id = db_result($result,$j,'group_id');
57 $group_project_id = db_result($result,$j,'group_project_id');
59 $sql2 = 'SELECT project_task.project_task_id, project_task.priority, project_task.summary,project_task.percent_complete '.
60 'FROM groups,project_group_list,project_task,project_assigned_to '.
61 'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
62 "AND project_assigned_to.assigned_to_id=$1 AND project_task.status_id='1' ".
63 'AND project_group_list.group_id=groups.group_id '.
64 "AND groups.group_id=$2 ".
65 'AND project_group_list.group_project_id=project_task.group_project_id '.
66 "AND project_group_list.is_public!='9' ".
67 "AND project_group_list.group_project_id= $3 LIMIT 100";
70 $result2 = db_query_params($sql2,array(user_getid(),$group_id,$group_project_id));
71 $rows2 = db_numrows($result2);
73 $vItemId = new Valid_UInt('hide_item_id');
75 if($request->valid($vItemId)) {
76 $hide_item_id = $request->get('hide_item_id');
81 $vPm = new Valid_WhiteList('hide_pm', array(0, 1));
83 if($request->valid($vPm)) {
84 $hide_pm = $request->get('hide_pm');
89 list($hide_now,$count_diff,$hide_url) = my_hide_url('pm',$group_project_id,$hide_item_id,$rows2,$hide_pm);
91 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="3">' : '').
92 $hide_url.'<a href="/pm/task.php?group_id='.$group_id.
93 '&group_project_id='.$group_project_id.'">'.
94 db_result($result,$j,'group_name').' - '.
95 db_result($result,$j,'project_name').'</a> ';
97 $count_new = max(0, $count_diff);
98 for ($i=0; $i<$rows2; $i++) {
103 <tr class=priority"'.db_result($result2,$i,'priority').
104 '"><td class="small"><a href="/pm/task.php/?func=detailtask&project_task_id='.
105 db_result($result2, $i, 'project_task_id').'&group_id='.
106 $group_id.'&group_project_id='.$group_project_id.
107 '">'.stripslashes(db_result($result2,$i,'summary')).'</a></td>'.
108 '<td class="small">'.(db_result($result2,$i,'percent_complete')).'%</td></tr>';
113 $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
114 $this->content .= $html_hdr.$html;
116 $this->content .= '</table>';
118 $this->content .= '<div class="warning">'. _("No task yet") .'</div>';
121 function getTitle() {
122 return _("My Tasks");
124 function getContent() {
125 return $this->content;
127 function isAvailable() {
128 if (!forge_get_config('use_pm')) {
132 foreach (UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
140 function getDescription() {
141 return _("List the tasks assigned to you.");