* Copyright 2009, Roland Mas
* Copyright 2010, Alain Peyrat - Alcatel-Lucent
* Copyright 2011, Thorsten Glaser <t.glaser@tarent.de>
+ * Copyright 2013, 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
$data = db_fetch_array($res);
}
- $ProjectGroup =& projectgroup_get_object($data["group_project_id"]);
+ $ProjectGroup = projectgroup_get_object($data["group_project_id"]);
$PROJECTTASK_OBJ["_".$project_task_id."_"]= new ProjectTask($ProjectGroup,$project_task_id,$data);
}
/**
* Associative array of data from db.
*
- * @var array $data_array.
+ * @var array $data_array.
*/
var $data_array;
/**
* The ProjectGroup object.
*
- * @var object $ProjectGroup.
+ * @var ProjectGroup $ProjectGroup.
*/
var $ProjectGroup;
var $dependon;
var $relatedartifacts;
/**
- * Constructor.
+ * ProjectTask - Constructor.
*
- * @param object The ProjectGroup object to which this ProjectTask is associated.
- * @param int The project_task_id.
- * @param array The associative array of data.
- * @return boolean success.
+ * @param object $ProjectGroup The ProjectGroup object to which this ProjectTask is associated.
+ * @param int|bool $project_task_id The project_task_id.
+ * @param array|bool $arr The associative array of data.
+ * @return boolean success.
*/
function ProjectTask(&$ProjectGroup, $project_task_id=false, $arr=false) {
$this->Error();
}
/**
- * create - create a new ProjectTask in the database.
+ * create - create a new ProjectTask in the database.
*
- * @param string The summary of this task.
- * @param string The detailed description of this task.
- * @param int The Priority of this task.
- * @param int The Hours estimated to complete this task.
- * @param int The (unix) start date of this task.
- * @param int The (unix) end date of this task.
- * @param int The category_id of this task.
- * @param int The percentage of completion in integer format of this task.
- * @param array An array of user_id's that are assigned this task.
- * @param array An array of project_task_id's that this task depends on.
- * @param int The duration of the task in days.
- * @param int The id of the parent task, if any.
- * @param array An array ('user' => user_id)
- * @return boolean success.
+ * @param string $summary The summary of this task.
+ * @param string $details The detailed description of this task.
+ * @param int $priority The Priority of this task.
+ * @param int $hours The Hours estimated to complete this task.
+ * @param int $start_date The (unix) start date of this task.
+ * @param int $end_date The (unix) end date of this task.
+ * @param int $category_id The category_id of this task.
+ * @param int $percent_complete The percentage of completion in integer format of this task.
+ * @param array $assigned_arr An array of user_id's that are assigned this task.
+ * @param array $depend_arr An array of project_task_id's that this task depends on.
+ * @param int $duration The duration of the task in days.
+ * @param int $parent_id The id of the parent task, if any.
+ * @param array $importData An array ('user' => user_id)
+ * @param array $importData An array ('user' => user_id)
+ * @return boolean success.
*/
function create($summary,$details,$priority,$hours,$start_date,$end_date,
$category_id,$percent_complete,&$assigned_arr,&$depend_arr,$duration=0,$parent_id=0, $importData = array()) {
} else {
$uid = user_getid();
}
-
+
db_begin();
$res = db_query_params ('SELECT nextval($1) AS id',
array ('project_task_pk_seq'));
$parent_id)) ;
if (!$result || db_affected_rows($result) < 1) {
- $this->setError('Posting Failed '.db_error());
+ $this->setError('Posting Failed'.' '.db_error());
db_rollback();
return false;
}
}
/**
- * fetchData - re-fetch the data for this ProjectTask from the database.
+ * fetchData - re-fetch the data for this ProjectTask from the database.
*
- * @param int The project_task_id.
- * @return boolean success.
+ * @param int $project_task_id The project_task_id.
+ * @return boolean success.
*/
function fetchData($project_task_id) {
$res = db_query_params ('SELECT * FROM project_task_vw
array ($project_task_id,
$this->ProjectGroup->getID())) ;
if (!$res || db_numrows($res) < 1) {
- $this->setError('Invalid Task ID'.db_error());
+ $this->setError(_('Invalid Task ID').' '.db_error());
return false;
}
$this->data_array = db_fetch_array($res);
}
/**
- * getProjectGroup - get the ProjectGroup object this ProjectTask is associated with.
+ * getProjectGroup - get the ProjectGroup object this ProjectTask is associated with.
*
- * @return Object The ProjectGroup object.
+ * @return ProjectGroup The ProjectGroup object.
*/
function &getProjectGroup() {
return $this->ProjectGroup;
}
/**
- * getID - get this project_task_id.
+ * getID - get this project_task_id.
*
- * @return int The project_task_id.
+ * @return int The project_task_id.
*/
function getID() {
return $this->data_array['project_task_id'];
}
/**
- * getSubmittedRealName - get the real name of the person who created this task.
+ * getSubmittedRealName - get the real name of the person who created this task.
*
- * @return string The real name person who created this task.
+ * @return string The real name person who created this task.
*/
function getSubmittedRealName() {
return $this->data_array['realname'];
}
/**
- * getDuration - the duration of the task.
+ * getDuration - the duration of the task.
*
- * @return int The number of days of duration.
+ * @return int The number of days of duration.
*/
function getDuration() {
return $this->data_array['duration'];
}
/**
- * getParentID - the task_id of the parent task, if any.
+ * getParentID - the task_id of the parent task, if any.
*
- * @return string The real name person who created this task.
+ * @return string The real name person who created this task.
*/
function getParentID() {
return $this->data_array['parent_id'];
}
/**
- * getSubmittedUnixName - get the unix name of the person who created this task.
+ * getSubmittedUnixName - get the unix name of the person who created this task.
*
- * @return string The unix name of the person who created this task.
+ * @return string The unix name of the person who created this task.
*/
function getSubmittedUnixName() {
return $this->data_array['user_name'];
}
/**
- * getSummary - get the subject/summary of this task.
+ * getSummary - get the subject/summary of this task.
*
- * @return string The summary.
+ * @return string The summary.
*/
function getSummary() {
return $this->data_array['summary'];
}
/**
- * getDetails - get the body/details of this task.
+ * getDetails - get the body/details of this task.
*
- * @return string The body/details.
+ * @return string The body/details.
*/
function getDetails() {
return $this->data_array['details'];
}
/**
- * getPercentComplete - an integer between 0 and 100.
+ * getPercentComplete - an integer between 0 and 100.
*
- * @return int The percentage of completion of this task.
+ * @return int The percentage of completion of this task.
*/
function getPercentComplete() {
return $this->data_array['percent_complete'];
}
/**
- * getPriority - the priority, between 1 and 9 of this task.
+ * getPriority - the priority, between 1 and 9 of this task.
*
- * @return int The priority.
+ * @return int The priority.
*/
function getPriority() {
return $this->data_array['priority'];
}
/**
- * getHours - the hours this task is expected to take.
+ * getHours - the hours this task is expected to take.
*
- * @return int The hours.
+ * @return int The hours.
*/
function getHours() {
return $this->data_array['hours'];
}
/**
- * getStartDate - the unix time that this task will start.
+ * getStartDate - the unix time that this task will start.
*
- * @return int The unix start time of this task.
+ * @return int The unix start time of this task.
*/
function getStartDate() {
return $this->data_array['start_date'];
}
/**
- * getEndDate - the unix time that this task will end.
+ * getEndDate - the unix time that this task will end.
*
- * @return int The unix end time of this task.
+ * @return int The unix end time of this task.
*/
function getEndDate() {
return $this->data_array['end_date'];
}
/**
- * getStatusID - the integer of the status of this task.
+ * getStatusID - the integer of the status of this task.
*
- * @return int the status_id.
+ * @return int the status_id.
*/
function getStatusID() {
return $this->data_array['status_id'];
}
/**
- * getStatusName - the string of the status of this task.
+ * getStatusName - the string of the status of this task.
*
- * @return string the status_name.
+ * @return string the status_name.
*/
function getStatusName() {
return $this->data_array['status_name'];
}
/**
- * getCategoryID - the category_id of this task.
+ * getCategoryID - the category_id of this task.
*
- * @return int the category_id.
+ * @return int the category_id.
*/
function getCategoryID() {
return $this->data_array['category_id'];
}
/**
- * getCategoryName - the category_name of this task.
+ * getCategoryName - the category_name of this task.
*
- * @return int the category_name.
+ * @return int the category_name.
*/
function getCategoryName() {
return $this->data_array['category_name'];
}
/**
- * getLastModifiedDate - the last_modified_date of this task.
+ * getLastModifiedDate - the last_modified_date of this task.
*
- * @return int the last_modified_date.
+ * @return int the last_modified_date.
*/
function getLastModifiedDate() {
return $this->data_array['last_modified_date'];
}
/**
- * setExternalID - set a row in project_task_external_order which stores
- * an id, for example an ID generated by MS Project, which needs to be restored later
+ * setExternalID - set a row in project_task_external_order which stores
+ * an id, for example an ID generated by MS Project, which needs to be restored later
+ *
+ * @param int $id An external ID from another tool
*/
function setExternalID($id) {
$res = db_query_params ('UPDATE project_task_external_order SET external_id=$1
array ($id,
$this->getID())) ;
if (db_affected_rows($res) < 1) {
- $res = db_query_params ('INSERT INTO project_task_external_order (project_task_id,external_id) VALUES ($1, $2)',
+ db_query_params ('INSERT INTO project_task_external_order (project_task_id,external_id) VALUES ($1, $2)',
array ($this->getID(),
$id)) ;
}
}
/**
- * getExternalID - get the ID that MS Project uses to sort tasks
+ * getExternalID - get the ID that MS Project uses to sort tasks
*
- * @return int the id.
+ * @return int the id.
*/
function getExternalID() {
return $this->data_array['external_id'];
}
/**
- * getRelatedArtifacts - Return a result set of artifacts which are related to this task.
+ * getRelatedArtifacts - Return a result set of artifacts which are related to this task.
*
- * @returns Database result set.
+ * @return resource Database result set.
*/
function getRelatedArtifacts() {
if (!$this->relatedartifacts) {
db_query_params ('SELECT agl.group_id,agl.name,agl.group_artifact_id,a.artifact_id,a.open_date,a.summary,ast.status_name
FROM artifact_group_list agl, artifact a, artifact_status ast
WHERE a.group_artifact_id=agl.group_artifact_id
- AND ast.id=a.status_id
+ AND ast.id=a.status_id
AND EXISTS (SELECT artifact_id FROM project_task_artifact
WHERE artifact_id=a.artifact_id
AND project_task_id=$1)',
}
/**
- * addRelatedArtifacts - take an array of artifact_id's and build relationships.
+ * addRelatedArtifacts - take an array of artifact_id's and build relationships.
*
- * @param array An array of artifact_id's to be attached to this task.
- * @return boolean success.
+ * @param array $art_array An array of artifact_id's to be attached to this task.
+ * @return boolean success.
*/
function addRelatedArtifacts($art_array) {
if (!forge_check_perm ('pm', $this->ProjectGroup->getID(), 'manager')) {
}
/**
- * removeRelatedArtifacts - take an array of artifact_id's and delete relationships.
+ * removeRelatedArtifacts - take an array of artifact_id's and delete relationships.
*
- * @param array An array of artifact_id's to be removed from this task.
- * @return boolean success.
+ * @param array $art_array An array of artifact_id's to be removed from this task.
+ * @return boolean success.
*/
function removeRelatedArtifacts($art_array) {
if (!forge_check_perm ('pm', $this->ProjectGroup->getID(), 'manager')) {
}
/**
- * delete - delete this tracker and all its related data.
+ * delete - delete this tracker and all its related data.
*
- * @param bool I'm Sure.
- * @return bool true/false;
+ * @param bool $sure I'm Sure.
+ * @return bool true/false;
*/
function delete($sure) {
if (!$sure) {
}
/**
- * getOtherTasks - Return a result set of tasks in this subproject that do not equal
- * the current task_id.
+ * getOtherTasks - Return a result set of tasks in this subproject that do not equal
+ * the current task_id.
*
- * @returns Database result set.
+ * @return resource Database result set.
*/
function getOtherTasks () {
//
FROM project_task
WHERE group_project_id=$1
AND project_task_id <> $2
- ORDER BY project_task_id DESC',
+ ORDER BY project_task_id DESC',
array ($this->ProjectGroup->getID(),
$this->getID())) ;
} else {
}
/**
- * getHistory - returns a result set of audit trail for this ProjectTask.
+ * getHistory - returns a result set of audit trail for this ProjectTask.
*
- * @return database result set.
+ * @return resource database result set.
*/
function getHistory() {
return db_query_params ('SELECT *
}
/**
- * getMessages - get the list of messages attached to this ProjectTask.
+ * getMessages - get the list of messages attached to this ProjectTask.
*
- * @return database result set.
+ * @param bool $asc
+ * @return resource database result set.
*/
function getMessages($asc=false) {
return db_query_params ('SELECT *
/**
* addMessage - Handle the addition of a followup message to this task.
*
- * @param string The message.
- * @param array Specific data for import (user id and time)
- * @returns boolean success.
+ * @param string $message The message.
+ * @param array $importData Specific data for import (user id and time)
+ * @return boolean success.
*/
function addMessage($message, $importData = array()) {
//prevent posting the same message
/**
* addHistory - Handle the insertion of history for these parameters.
*
- * @param string The field name.
- * @param string The old value.
- * @param array Specific data for import (user id and time)
- * @returns boolean success.
+ * @param string $field_name The field name.
+ * @param string $old_value The old value.
+ * @param array $importData Specific data for import (user id and time)
+ * @return bool
*/
function addHistory ($field_name,$old_value,$importData=array()) {
//Uses importData
/**
* checkCircular - recursive function calls itself to look at all tasks you are dependent on.
*
- * @param int The project_task_id you are dependent on.
- * @param int The project_task_id you are checking circular dependencies for.
- * @returns boolean success.
+ * @param int $depend_on_id The project_task_id you are dependent on.
+ * @param int $original_id The project_task_id you are checking circular dependencies for.
+ * @return boolean success.
*/
function checkCircular($depend_on_id, $original_id) {
//for msproject users - ms project has more complex logic than gforge
return true;
+ /*
if ($depend_on_id == $original_id) {
$this->setError(_('Circular Dependency Detected\''));
return false;
}
}
return true;
+ */
}
/**
* setDependentOn - takes an array of project_task_id's and builds dependencies.
*
- * @param array The array of project_task_id's.
- * @returns boolean success.
+ * @param array $arr_ The array of project_task_id's.
+ * @return boolean success.
*/
function setDependentOn(&$arr_) {
-//printr($arr_,'setDependentOn entry');
//
// IMPORTANT - MUST VERIFY NO CIRCULAR DEPENDENCY!!
//
}
/**
- * convertDependentOn - converts a regular array of dependencies, such
- * as from a multiple-select-box to an associative array with default
- * link types. Should be called from web code as part of the create/update calls.
- * Here we are converting an array like array(1,5,9,77) to array(1=>SS,5=>SF,9=>FS,77=>SS)
+ * convertDependentOn - converts a regular array of dependencies, such
+ * as from a multiple-select-box to an associative array with default
+ * link types. Should be called from web code as part of the create/update calls.
+ * Here we are converting an array like array(1,5,9,77) to array(1=>SS,5=>SF,9=>FS,77=>SS)
+ *
+ * @param array $arr
*/
function &convertDependentOn($arr) {
$deps = $this->getDependentOn();
for ($i=0; $i<count($arr); $i++) {
- if ($deps[$arr[$i]]) {
+ if (isset($deps[$arr[$i]])) {
//use existing link_type if it exists
$new[$arr[$i]]=$deps[$arr[$i]];
} else {
}
/**
- * getDependentOn - get an array of project_task_id's that you are dependent on.
+ * getDependentOn - get an array of project_task_id's that you are dependent on.
*
- * @return array The array of project_task_id's in this format:
- * array($id=>$link_type,id2=>link_type2).
+ * @return array The array of project_task_id's in this format:
+ * array($id=>$link_type,id2=>link_type2).
*/
function getDependentOn() {
if (!$this->getID()) {
$this->dependon[db_result($res,$i,'is_dependent_on_task_id')] = db_result($res,$i,'link_type');
}
}
- /* fix bug 319: if dependentlist is emtpy, set it to 100 (none) */
+ /* fix bug 319: if dependent list is empty, set it to 100 (none) */
if (!$this->dependon) {
$this->dependon[100]=PM_LINK_DEFAULT;
}
/**
* setAssignedTo - takes an array of user_id's and builds assignments.
*
- * @param array The array of user_id's.
- * @returns boolean success.
+ * @param array $arr The array of user_id's.
+ * @return boolean success.
*/
function setAssignedTo(&$arr) {
$arr2 = $this->getAssignedTo();
}
/**
- * getAssignedTo - get an array of user_id's that you are assigned to.
+ * getAssignedTo - get an array of user_id's that you are assigned to.
*
- * @return array The array of user_id's.
+ * @return array The array of user_id's.
*/
function getAssignedTo() {
if (!$this->getID()) {
}
/**
- * update - update this ProjectTask in the database.
+ * update - update this ProjectTask in the database.
*
- * @param string The summary of this task.
- * @param string The detailed description of this task.
- * @param int The Priority of this task.
- * @param int The Hours estimated to complete this task.
- * @param int The (unix) start date of this task.
- * @param int The (unix) end date of this task.
- * @param int The status_id of this task.
- * @param int The category_id of this task.
- * @param int The percentage of completion in integer format of this task.
- * @param array An array of user_id's that are assigned this task.
- * @param array An array of project_task_id's that this task depends on.
- * @param int The GroupProjectID of a new subproject that you want to move this Task to.
- * @param int The duration of the task in days.
- * @param int The id of the parent task, if any.
- * @return boolean success.
+ * @param string $summary The summary of this task.
+ * @param string $details The detailed description of this task.
+ * @param int $priority The Priority of this task.
+ * @param int $hours The Hours estimated to complete this task.
+ * @param int $start_date The (Unix) start date of this task.
+ * @param int $end_date The (Unix) end date of this task.
+ * @param int $status_id The status_id of this task.
+ * @param int $category_id The category_id of this task.
+ * @param int $percent_complete The percentage of completion in integer format of this task.
+ * @param array $assigned_arr An array of user_id's that are assigned this task.
+ * @param array $depend_arr An array of project_task_id's that this task depends on.
+ * @param int $new_group_project_id The GroupProjectID of a new subproject that you want to move this Task to.
+ * @param int $duration The duration of the task in days.
+ * @param int $parent_id The id of the parent task, if any.
+ * @return bool success.
*/
- function update($summary,$details,$priority,$hours,$start_date,$end_date,
- $status_id,$category_id,$percent_complete,&$assigned_arr,&$depend_arr,
- $new_group_project_id,$duration=0,$parent_id=0) {
+ function update($summary, $details, $priority, $hours, $start_date, $end_date,
+ $status_id, $category_id, $percent_complete, &$assigned_arr, &$depend_arr,
+ $new_group_project_id, $duration=0, $parent_id=0) {
$has_changes = false; // if any of the values passed is different from
$arrChangedAndInNotice = array(
$has_changes = true;
}*/
-
db_begin();
//
$arrChangedAndInNotice['subproject'] = ">";
}
-
if ($details) {
$has_changes = true;
if($details != "" && $details != null) {$arrChangedAndInNotice['details'] = ">";}
}
/**
- * sendNotice - contains the logic for sending email/jabber updates.
+ * sendNotice - contains the logic for sending email updates.
*
- * @return boolean success.
+ * @param bool $first
+ * @param array $arrChangedAndInNotice
+ * @return bool success.
*/
function sendNotice($first=false, $arrChangedAndInNotice=array()) {
global $send_task_email;