X-Git-Url: https://scm.fusionforge.org/anonscm/gitweb?p=fusionforge%2Ffusionforge.git;a=blobdiff_plain;f=src%2Fcommon%2Fpm%2FProjectTaskFactory.class.php;h=a7e1abefde54b930f17936a60dcb8cf8d3cdc2ee;hp=06ab6b444e2f1c60e7162ba4a2e49c0f3dfa6670;hb=cb9d8f3128e8530091790b75cb7a74aa71798ce0;hpb=f62cf13502a645f8b1c1b79b5e965fe9a81f4d66 diff --git a/src/common/pm/ProjectTaskFactory.class.php b/src/common/pm/ProjectTaskFactory.class.php index 06ab6b444e..a7e1abefde 100644 --- a/src/common/pm/ProjectTaskFactory.class.php +++ b/src/common/pm/ProjectTaskFactory.class.php @@ -5,6 +5,7 @@ * Copyright 1999-2000, Tim Perdue/Sourceforge * Copyright 2002, Tim Perdue/GForge, LLC * Copyright 2009, Roland Mas + * Copyright 2014, Franck Villaume - TrivialDev * * This file is part of FusionForge. FusionForge is free software; * you can redistribute it and/or modify it under the terms of the @@ -30,14 +31,14 @@ class ProjectTaskFactory extends Error { /** * The ProjectGroup object. * - * @var object $ProjectGroup. + * @var object $ProjectGroup. */ var $ProjectGroup; /** * The project_tasks array. * - * @var array project_tasks. + * @var array project_tasks. */ var $project_tasks; var $order; @@ -52,8 +53,8 @@ class ProjectTaskFactory extends Error { /** * Constructor. * - * @param object The ProjectGroup object to which this ProjectTask is associated. - * @return boolean success. + * @param ProjectGroup $ProjectGroup The ProjectGroup object to which this ProjectTask is associated. + * @return boolean success. */ function ProjectTaskFactory(&$ProjectGroup) { $this->Error(); @@ -73,15 +74,16 @@ class ProjectTaskFactory extends Error { } /** - * setup - sets up limits and sorts before you call getTasks(). + * setup - sets up limits and sorts before you call getTasks(). * - * @param int The offset - number of rows to skip. - * @param string The way to order - ASC or DESC. - * @param int The max number of rows to return. - * @param string Whether to set these prefs into the user_prefs table - use "custom". - * @param int Include this param if you want to limit to a certain assignee. - * @param int Include this param if you want to limit to a certain category. - * @param string What view mode the screen should be in. + * @param int $offset The offset - number of rows to skip. + * @param string $order The way to order - ASC or DESC. + * @param int $max_rows The max number of rows to return. + * @param string $set Whether to set these prefs into the user_prefs table - use "custom". + * @param int $_assigned_to Include this param if you want to limit to a certain assignee. + * @param int $_status Include this param if you want to limit to a certain category. + * @param $_category_id + * @param string $_view */ function setup($offset,$order,$max_rows,$set,$_assigned_to,$_status,$_category_id,$_view='') { //echo "
offset: $offset| order: $order|max_rows: $max_rows|_assigned_to: $_assigned_to|_status: $_status|_category_id: $_category_id +"; @@ -145,15 +147,15 @@ class ProjectTaskFactory extends Error { } /** - * getTasks - get an array of ProjectTask objects. + * getTasks - get an array of ProjectTask objects. * - * @return array The array of ProjectTask objects. + * @return array ProjectTask[] The array of ProjectTask objects. */ function &getTasks() { if ($this->project_tasks) { return $this->project_tasks; } - + $qpa = db_construct_qpa(); if ($this->order=='priority') { $order = 'ORDER BY priority DESC' ; } else { @@ -164,32 +166,32 @@ class ProjectTaskFactory extends Error { $tat = $this->assigned_to ; if (! is_array ($tat)) $tat = array ($tat) ; - - $result = db_query_params ('SELECT project_task_vw.*, project_task_external_order.external_id - FROM project_task_vw natural left join project_task_external_order, project_assigned_to - WHERE project_task_vw.project_task_id=project_assigned_to.project_task_id - AND project_task_vw.group_project_id = $1 - AND project_assigned_to.assigned_to_id = ANY ($2)' . $order, - array ($this->ProjectGroup->getID(), - db_int_array_to_any_clause ($tat)), - $this->max_rows, - $this->offset) ; + $qpa = db_construct_qpa($qpa, 'SELECT project_task_vw.*, project_task_external_order.external_id + FROM project_task_vw natural left join project_task_external_order, project_assigned_to + WHERE project_task_vw.project_task_id = project_assigned_to.project_task_id '); + $qpa = db_construct_qpa($qpa, 'AND project_task_vw.group_project_id = $1 AND project_assigned_to.assigned_to_id = ANY ($2) ', + array ($this->ProjectGroup->getID(), db_int_array_to_any_clause ($tat))); } else { - $result = db_query_params ('SELECT project_task_vw.*, project_task_external_order.external_id - FROM project_task_vw natural left join project_task_external_order - WHERE project_task_vw.group_project_id = $1' . $order, - array ($this->ProjectGroup->getID()), - $this->max_rows, - $this->offset) ; + $qpa = db_construct_qpa($qpa, 'SELECT project_task_vw.*, project_task_external_order.external_id + FROM project_task_vw natural left join project_task_external_order '); + $qpa = db_construct_qpa($qpa, 'WHERE project_task_vw.group_project_id = $1 ', + array ($this->ProjectGroup->getID())); } - $rows = db_numrows($result); - $this->fetched_rows=$rows; + if ($this->status != 100) { + $qpa = db_construct_qpa($qpa, ' AND project_task_vw.status_id = $1 ', array($this->status)); + } + + $qpa = db_construct_qpa($qpa, $order); + $result = db_query_qpa($qpa, $this->max_rows, $this->offset); + if (db_error()) { - $this->setError('Database Error: '.db_error().$sql); + $this->setError('Database Error: '.db_error()); return false; } + $rows = db_numrows($result); + $this->fetched_rows = $rows; $this->project_tasks = array(); while ($arr = db_fetch_array($result)) { if ($this->status && ($this->status != 100)) {