3 * GForge Project Management Facility
5 * Copyright 2002 GForge, LLC
8 * This file is part of GForge.
10 * GForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * GForge 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
21 * along with GForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
25 require_once('common/pm/ProjectGroup.class.php');
26 require_once('common/pm/ProjectTask.class.php');
27 require_once('common/include/Group.class.php');
28 require_once('common/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 &getTasksFromSQL ($sql) {
58 $result=db_query($sql);
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 $sql = "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='".$this->User->getID()."'
85 ORDER BY group_name,project_name";
86 return $this->getTasksFromSQL($sql);
89 function &getTasksForToday() {
91 $today = mktime (18, 00, 00, $now['mon'], $now['mday'], $now['year']);
93 $sql = "SELECT ptv.*,g.group_name,pgl.project_name
94 FROM project_task_vw ptv,
95 project_assigned_to pat,
97 project_group_list pgl
98 WHERE ptv.project_task_id=pat.project_task_id
99 AND pgl.group_id=g.group_id
100 AND pgl.group_project_id=ptv.group_project_id
101 AND ptv.start_date < '$today'
103 AND pat.assigned_to_id='".$this->User->getID()."'
104 ORDER BY group_name,project_name";
105 return $this->getTasksFromSQL($sql);