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.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published
13 * by the Free Software Foundation; either version 2 of the License,
14 * or (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with FusionForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 require_once $gfcommon.'pm/ProjectGroup.class.php';
28 require_once $gfcommon.'pm/ProjectTask.class.php';
29 require_once $gfcommon.'include/Group.class.php';
30 require_once $gfcommon.'include/Error.class.php';
33 * A class that manages the project tasks for a specific user
35 class ProjectTasksForUser extends Error {
38 * The User to whom the tasks belong
43 * Creates a new ProjectTasksForUser object
45 * @param user the User object
47 function ProjectTasksForUser(&$user) {
53 * Gets a list of tasks for this user
55 * @param the SQL query to use to fetch the tasks
56 * @return an array of ProjectTask objects
58 function &getTasksFromSQLwithParams ($sql, $params) {
60 $result = db_query_params ($sql, $params);
61 $rows=db_numrows($result);
62 for ($i=0; $i < $rows; $i++) {
63 $project_task_id = db_result($result,$i,'project_task_id');
64 $arr =& db_fetch_array($result);
65 $task =& projecttask_get_object($project_task_id,$arr);
72 * Gets a list of tasks by group project name
74 * @return an array of ProjectTask objects
76 function &getTasksByGroupProjectName () {
77 return $this->getTasksFromSQLwithParams ('SELECT ptv.*,g.group_name,pgl.project_name
78 FROM project_task_vw ptv,
79 project_assigned_to pat,
81 project_group_list pgl
82 WHERE ptv.project_task_id=pat.project_task_id
83 AND pgl.group_id=g.group_id
84 AND pgl.group_project_id=ptv.group_project_id
86 AND pat.assigned_to_id=$1
87 ORDER BY group_name,project_name',
88 array ($this->User->getID())) ;
91 function &getTasksForToday() {
93 $today = mktime (18, 00, 00, $now['mon'], $now['mday'], $now['year']);
95 return $this->getTasksFromSQLwithParams ('SELECT ptv.*,g.group_name,pgl.project_name
96 FROM project_task_vw ptv,
97 project_assigned_to pat,
99 project_group_list pgl
100 WHERE ptv.project_task_id=pat.project_task_id
101 AND pgl.group_id=g.group_id
102 AND pgl.group_project_id=ptv.group_project_id
103 AND ptv.start_date < $1
105 AND pat.assigned_to_id=$2
106 ORDER BY group_name,project_name',
108 $this->User->getID())) ;
114 // c-file-style: "bsd"