3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Fusionforge.
7 * Fusionforge 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 * Fusionforge 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";
76 $result2 = db_query_params($sql2,array(user_getid(),$group_id,$group_project_id));
77 $rows2 = db_numrows($result2);
79 $vItemId = new Valid_UInt('hide_item_id');
81 if($request->valid($vItemId)) {
82 $hide_item_id = $request->get('hide_item_id');
87 $vPm = new Valid_WhiteList('hide_pm', array(0, 1));
89 if($request->valid($vPm)) {
90 $hide_pm = $request->get('hide_pm');
95 list($hide_now,$count_diff,$hide_url) = my_hide_url('pm',$group_project_id,$hide_item_id,$rows2,$hide_pm);
97 $html_hdr = '<tr class="boxitem"><td colspan="3">'.
98 $hide_url.'<a href="/pm/task.php?group_id='.$group_id.
99 '&group_project_id='.$group_project_id.'">'.
100 db_result($result,$j,'group_name').' - '.
101 db_result($result,$j,'project_name').'</a> ';
103 $count_new = max(0, $count_diff);
104 for ($i=0; $i<$rows2; $i++) {
109 <tr class=priority"'.db_result($result2,$i,'priority').
110 '"><td class="small"><a href="/pm/task.php/?func=detailtask&project_task_id='.
111 db_result($result2, $i, 'project_task_id').'&group_id='.
112 $group_id.'&group_project_id='.$group_project_id.
113 '">'.stripslashes(db_result($result2,$i,'summary')).'</a></td>'.
114 '<td class="small">'.(db_result($result2,$i,'percent_complete')).'%</td></tr>';
119 $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
120 $this->content .= $html_hdr.$html;
122 $this->content .= '</table>';
124 $this->content .= '<div class="warning">'. _("No task yet") .'</div>';
127 function getTitle() {
128 return _("My Tasks");
130 function getContent() {
131 return $this->content;
133 function isAvailable() {
134 if (!forge_get_config('use_pm')) {
138 foreach (UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
146 function getDescription() {
147 return _("List the tasks assigned to you.");