3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2014-2016, Franck Villaume - TrivialDev
6 * This file is a part of Fusionforge.
8 * Fusionforge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Fusionforge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
22 require_once 'Widget.class.php';
23 require_once $gfcommon.'widget/WidgetLayoutManager.class.php';
24 require_once $gfcommon.'include/my_utils.php';
29 * Tasks assigned to me
31 class Widget_MyTasks extends Widget {
33 var $can_be_displayed;
35 function __construct() {
37 parent::__construct('mytasks');
39 $this->setOwner(user_getid(), WidgetLayoutManager::OWNER_TYPE_USER);
41 $sql = 'SELECT groups.group_id, groups.group_name, project_group_list.group_project_id, project_group_list.project_name '.
42 'FROM groups,project_group_list,project_task,project_assigned_to '.
43 'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
44 'AND project_assigned_to.assigned_to_id=$1'.
45 ' AND project_task.status_id=1 AND project_group_list.group_id=groups.group_id '.
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()));
51 while ($r = db_fetch_array($result)) {
52 if (forge_check_perm('project_read', $r['group_id'])
53 && forge_check_perm('pm', $r['group_project_id'], 'read')) {
58 $rows = count($plist);
60 if ($result && $rows >= 1) {
61 $request =& HTTPRequest::instance();
62 $this->content .= $HTML->listTableTop();
63 for ($j=0; $j<$rows; $j++) {
65 $group_id = $plist[$j]['group_id'];
66 $group_project_id = $plist[$j]['group_project_id'];
68 $sql2 = 'SELECT project_task.project_task_id, project_task.priority, project_task.summary,project_task.percent_complete '.
69 'FROM groups,project_group_list,project_task,project_assigned_to '.
70 'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
71 'AND project_assigned_to.assigned_to_id = $1 AND project_task.status_id = 1 '.
72 'AND project_group_list.group_id=groups.group_id '.
73 "AND groups.group_id=$2 ".
74 'AND project_group_list.group_project_id=project_task.group_project_id '.
75 'AND project_group_list.group_project_id= $3 ';
77 $result2 = db_query_params($sql2,array(user_getid(),$group_id,$group_project_id), 100);
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 = '<tr class="boxitem"><td colspan="3">'.
99 $hide_url.util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id,
100 db_result($result,$j,'group_name').' - '.db_result($result,$j,'project_name'));
102 $count_new = max(0, $count_diff);
103 for ($i=0; $i<$rows2; $i++) {
108 <tr class="priority'.db_result($result2,$i,'priority').
109 '"><td class="small">'.
110 util_make_link('/pm/task.php/?func=detailtask&project_task_id='.db_result($result2, $i, 'project_task_id').
111 '&group_id='.$group_id.'&group_project_id='.$group_project_id,
112 stripslashes(db_result($result2,$i,'summary'))).'</td>'.
113 '<td class="small">'.(db_result($result2,$i,'percent_complete')).'%</td></tr>';
118 $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
119 $this->content .= $html_hdr.$html;
121 $this->content .= $HTML->listTableBottom();
123 $this->content .= $HTML->warning_msg(_('No task yet.'));
127 function getTitle() {
128 return _('My Tasks');
131 function getContent() {
132 return $this->content;
135 function isAvailable() {
136 if (!forge_get_config('use_pm')) {
140 foreach (UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
148 function getDescription() {
149 return _('List the tasks assigned to you.');
152 function getCategory() {
153 return _('Project Management');