3 * FusionForge project manager
5 * Copyright 1999-2000, Tim Perdue/Sourceforge
6 * Copyright 2002, Tim Perdue/GForge, LLC
7 * Copyright 2009, Roland Mas
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'pm/ProjectGroup.class.php';
26 require_once $gfcommon.'pm/ProjectTask.class.php';
27 require_once $gfcommon.'include/Group.class.php';
28 require_once $gfcommon.'include/Error.class.php';
31 * A class that manages the project tasks for a specific user
33 class ProjectTasksForUser extends Error {
36 * The User to whom the tasks belong
41 * Creates a new ProjectTasksForUser object
43 * @param user the User object
45 function ProjectTasksForUser(&$user) {
51 * Gets a list of tasks for this user
53 * @param the SQL query to use to fetch the tasks
54 * @return an array of ProjectTask objects
56 function &getTasksFromSQLwithParams ($sql, $params) {
58 $result = db_query_params ($sql, $params);
59 $rows=db_numrows($result);
60 for ($i=0; $i < $rows; $i++) {
61 $project_task_id = db_result($result,$i,'project_task_id');
62 $arr = db_fetch_array($result);
63 $task = projecttask_get_object($project_task_id,$arr);
70 * Gets a list of tasks by group project name
72 * @return an array of ProjectTask objects
74 function &getTasksByGroupProjectName () {
75 return $this->getTasksFromSQLwithParams ('SELECT ptv.*,g.group_name,pgl.project_name
76 FROM project_task_vw ptv,
77 project_assigned_to pat,
79 project_group_list pgl
80 WHERE ptv.project_task_id=pat.project_task_id
81 AND pgl.group_id=g.group_id
82 AND pgl.group_project_id=ptv.group_project_id
84 AND pat.assigned_to_id=$1
85 ORDER BY group_name,project_name',
86 array ($this->User->getID())) ;
89 function &getOpenTasksForDate($date) {
90 return $this->getTasksFromSQLwithParams ('SELECT ptv.*,g.group_name,pgl.project_name
91 FROM project_task_vw ptv,
92 project_assigned_to pat,
94 project_group_list pgl
95 WHERE ptv.project_task_id=pat.project_task_id
96 AND pgl.group_id=g.group_id
97 AND pgl.group_project_id=ptv.group_project_id
98 AND ptv.start_date < $1
100 AND pat.assigned_to_id=$2
101 ORDER BY group_name,project_name',
103 $this->User->getID())) ;
106 function &getTasksForToday() {
108 $today = mktime (18, 00, 00, $now['mon'], $now['mday'], $now['year']);
109 return $this->getOpenTasksForDate($today);
112 function &getTasksForThisWeek() {
114 $thisweek = mktime (18, 00, 00, $now['mon'], $now['mday'], $now['year'])+7*24*3600;
115 return $this->getOpenTasksForDate($thisweek);
121 // c-file-style: "bsd"