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.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';
47 $result=db_query_params($sql,array(user_getid()));
50 while ($r = db_fetch_array($result)) {
51 if (forge_check_perm('project', $r['group_id'], 'read')
52 && forge_check_perm('pm', $r['group_project_id'], 'read')) {
57 $rows = count($plist);
59 if ($result && $rows >= 1) {
60 $request =& HTTPRequest::instance();
61 $this->content .= '<table style="width:100%">';
62 for ($j=0; $j<$rows; $j++) {
64 $group_id = $plist[$j]['group_id'];
65 $group_project_id = $plist[$j]['group_project_id'];
67 $sql2 = 'SELECT project_task.project_task_id, project_task.priority, project_task.summary,project_task.percent_complete '.
68 'FROM groups,project_group_list,project_task,project_assigned_to '.
69 'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
70 "AND project_assigned_to.assigned_to_id=$1 AND project_task.status_id='1' ".
71 'AND project_group_list.group_id=groups.group_id '.
72 "AND groups.group_id=$2 ".
73 'AND project_group_list.group_project_id=project_task.group_project_id '.
74 "AND project_group_list.group_project_id= $3 LIMIT 100";
77 $result2 = db_query_params($sql2,array(user_getid(),$group_id,$group_project_id));
78 $rows2 = db_numrows($result2);
80 $vItemId = new Valid_UInt('hide_item_id');
82 if($request->valid($vItemId)) {
83 $hide_item_id = $request->get('hide_item_id');
88 $vPm = new Valid_WhiteList('hide_pm', array(0, 1));
90 if($request->valid($vPm)) {
91 $hide_pm = $request->get('hide_pm');
96 list($hide_now,$count_diff,$hide_url) = my_hide_url('pm',$group_project_id,$hide_item_id,$rows2,$hide_pm);
98 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="3">' : '').
99 $hide_url.'<a href="/pm/task.php?group_id='.$group_id.
100 '&group_project_id='.$group_project_id.'">'.
101 db_result($result,$j,'group_name').' - '.
102 db_result($result,$j,'project_name').'</a> ';
104 $count_new = max(0, $count_diff);
105 for ($i=0; $i<$rows2; $i++) {
110 <tr class=priority"'.db_result($result2,$i,'priority').
111 '"><td class="small"><a href="/pm/task.php/?func=detailtask&project_task_id='.
112 db_result($result2, $i, 'project_task_id').'&group_id='.
113 $group_id.'&group_project_id='.$group_project_id.
114 '">'.stripslashes(db_result($result2,$i,'summary')).'</a></td>'.
115 '<td class="small">'.(db_result($result2,$i,'percent_complete')).'%</td></tr>';
120 $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
121 $this->content .= $html_hdr.$html;
123 $this->content .= '</table>';
125 $this->content .= '<div class="warning">'. _("No task yet") .'</div>';
128 function getTitle() {
129 return _("My Tasks");
131 function getContent() {
132 return $this->content;
134 function isAvailable() {
135 if (!forge_get_config('use_pm')) {
139 foreach (UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
147 function getDescription() {
148 return _("List the tasks assigned to you.");