* 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
/**
* 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;
/**
* Constructor.
*
- * @param ProjectGroup $ProjectGroup 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();
/**
* setup - sets up limits and sorts before you call getTasks().
*
- * @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
+ * @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 "<br />offset: $offset| order: $order|max_rows: $max_rows|_assigned_to: $_assigned_to|_status: $_status|_category_id: $_category_id +";
/**
* getTasks - get an array of ProjectTask objects.
*
- * @return ProjectTask[] 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 {
$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 == 1 || $this->status == 2 || $this->status == 3) {
+ $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());
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)) {
- if ($this->status == 1) {
- if ($arr['status_id'] != 1 && $arr['status_id'] != 100)
- continue ;
- } else {
- if ($arr['status_id'] != $this->status)
- continue ;
- }
- }
-
if ($this->category) {
if ($arr['category_id'] != $this->category)
continue ;
}
-
$this->project_tasks[] = new ProjectTask($this->ProjectGroup, $arr['project_task_id'], $arr);
}
return $this->project_tasks;