File: Widget_MyTasks.class.php

package info (click to toggle)
fusionforge 5.3.2%2B20141104-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 60,472 kB
  • sloc: php: 271,846; sql: 36,817; python: 14,575; perl: 6,406; sh: 5,980; xml: 4,294; pascal: 1,411; makefile: 911; cpp: 52; awk: 27
file content (149 lines) | stat: -rw-r--r-- 5,970 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
 *
 * This file is a part of Fusionforge.
 *
 * Fusionforge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Fusionforge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
 */

require_once 'Widget.class.php';
require_once 'common/widget/WidgetLayoutManager.class.php';
require_once $gfwww.'include/my_utils.php';

/**
* Widget_MyTasks
*
* Tasks assigned to me
*/
class Widget_MyTasks extends Widget {
    var $content;
    var $can_be_displayed;

    function Widget_MyTasks() {
        $this->Widget('mytasks');
        $this->content = '';
        $this->setOwner(user_getid(), WidgetLayoutManager::OWNER_TYPE_USER);
        $last_group=0;

        $sql = 'SELECT groups.group_id, groups.group_name, project_group_list.group_project_id, project_group_list.project_name '.
            'FROM groups,project_group_list,project_task,project_assigned_to '.
            'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
            'AND project_assigned_to.assigned_to_id=$1'.
            ' AND project_task.status_id=1 AND project_group_list.group_id=groups.group_id '.
          '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';

        $result=db_query_params($sql,array(user_getid()));

	$plist = array();
	while ($r = db_fetch_array($result)) {
		if (forge_check_perm('project', $r['group_id'], 'read')
				&& forge_check_perm('pm', $r['group_project_id'], 'read')) {
			$plist[] = $r;
		}
	}

        $rows = count($plist);

        if ($result && $rows >= 1) {
            $request =& HTTPRequest::instance();
            $this->content .= '<table style="width:100%">';
            for ($j=0; $j<$rows; $j++) {

                $group_id = $plist[$j]['group_id'];
                $group_project_id = $plist[$j]['group_project_id'];

                $sql2 = 'SELECT project_task.project_task_id, project_task.priority, project_task.summary,project_task.percent_complete '.
                    'FROM groups,project_group_list,project_task,project_assigned_to '.
                    'WHERE project_task.project_task_id=project_assigned_to.project_task_id '.
                    "AND project_assigned_to.assigned_to_id=$1 AND project_task.status_id='1'  ".
                    'AND project_group_list.group_id=groups.group_id '.
                    "AND groups.group_id=$2 ".
                    'AND project_group_list.group_project_id=project_task.group_project_id '.
                   "AND project_group_list.group_project_id= $3 LIMIT 100";

                $result2 = db_query_params($sql2,array(user_getid(),$group_id,$group_project_id));
                $rows2 = db_numrows($result2);

                $vItemId = new Valid_UInt('hide_item_id');
                $vItemId->required();
                if($request->valid($vItemId)) {
                    $hide_item_id = $request->get('hide_item_id');
                } else {
                    $hide_item_id = null;
                }

                $vPm = new Valid_WhiteList('hide_pm', array(0, 1));
                $vPm->required();
                if($request->valid($vPm)) {
                    $hide_pm = $request->get('hide_pm');
                } else {
                    $hide_pm = null;
                }

                list($hide_now,$count_diff,$hide_url) = my_hide_url('pm',$group_project_id,$hide_item_id,$rows2,$hide_pm);

                $html_hdr = '<tr class="boxitem"><td colspan="3">'.
                    $hide_url.'<a href="/pm/task.php?group_id='.$group_id.
                    '&amp;group_project_id='.$group_project_id.'">'.
                    db_result($result,$j,'group_name').' - '.
                    db_result($result,$j,'project_name').'</a> ';
                $html = '';
                $count_new = max(0, $count_diff);
                for ($i=0; $i<$rows2; $i++) {

                    if (!$hide_now) {

                    $html .= '
                    <tr class="priority'.db_result($result2,$i,'priority').
                        '"><td class="small"><a href="/pm/task.php/?func=detailtask&amp;project_task_id='.
                        db_result($result2, $i, 'project_task_id').'&amp;group_id='.
                        $group_id.'&amp;group_project_id='.$group_project_id.
                        '">'.stripslashes(db_result($result2,$i,'summary')).'</a></td>'.
                        '<td class="small">'.(db_result($result2,$i,'percent_complete')).'%</td></tr>';

                    }
                }

                $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
                $this->content .= $html_hdr.$html;
            }
            $this->content .= '</table>';
        } else {
            $this->content .= '<div class="warning">'. _("No task yet") .'</div>';
        }
    }
    function getTitle() {
        return _("My Tasks");
    }
    function getContent() {
        return $this->content;
    }
    function isAvailable() {
	    if (!forge_get_config('use_pm')) {
		    return false ;
	    }

	    foreach (UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
		    if ($p->usesPM()) {
			    return true ;
		    }
	    }
	    return false ;
    }

    function getDescription() {
        return _("List the tasks assigned to you.");
    }
}