require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'include/Validator.class.php';
-function &projecttask_get_object($project_task_id,$data=false) {
+function projecttask_get_object($project_task_id,$data=false) {
global $PROJECTTASK_OBJ;
if (!isset($PROJECTTASK_OBJ["_".$project_task_id."_"])) {
if ($data) {
function ProjectTask(&$ProjectGroup, $project_task_id=false, $arr=false) {
$this->Error();
if (!$ProjectGroup || !is_object($ProjectGroup)) {
- $this->setError('ProjectTask:: No Valid ProjectGroup Object');
+ $this->setError('No Valid ProjectGroup Object');
return false;
}
if ($ProjectGroup->isError()) {
- $this->setError('ProjectTask:: '.$ProjectGroup->getErrorMessage());
+ $this->setError($ProjectGroup->getErrorMessage());
return false;
}
$this->ProjectGroup =& $ProjectGroup;
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()) {
$v = new Validator();
- $v->check($summary, "summary");
- $v->check($details, "details");
- $v->check($priority, "priority");
- $v->check($hours, "hours");
- $v->check($start_date, "start date");
- $v->check($end_date, "end date");
- $v->check($category_id, "category");
+ $v->check($summary, _("summary"));
+ $v->check($details, _("details"));
+ $v->check($priority, _("priority"));
+ $v->check($hours, _("hours"));
+ $v->check($start_date, _("start date"));
+ $v->check($end_date, _("end date"));
+ $v->check($category_id, _("category"));
if (!$v->isClean()) {
- $this->setError($v->formErrorMsg("Must include "));
+ $this->setError($v->formErrorMsg(_("Must include ")));
return false;
}
if (!$parent_id) {
$parent_id)) ;
if (!$result || db_affected_rows($result) < 1) {
- $this->setError('ProjectTask::create() Posting Failed '.db_error());
+ $this->setError('Posting Failed '.db_error());
db_rollback();
return false;
}
array ($project_task_id,
$this->ProjectGroup->getID())) ;
if (!$res || db_numrows($res) < 1) {
- $this->setError('ProjectTask::fetchData() Invalid Task ID'.db_error());
+ $this->setError('Invalid Task ID'.db_error());
return false;
}
$this->data_array = db_fetch_array($res);
$uid,
$time)) ;
if (!$res || db_affected_rows($res) < 1) {
- $this->setError('AddMessage():: '.db_error());
+ $this->setError(db_error());
return false;
} else {
return true;
array ($this->getID(),
$del_arr[$i])) ;
if (db_error()) {
- $this->setError('setDependentOn()-1:: '.db_error());
+ $this->setError(db_error());
return false;
}
}
$add_arr[$i],
$lnk)) ;
if (db_error()) {
- $this->setError('setDependentOn()-2:: '.db_error().$sql);
+ $this->setError(db_error());
return false;
}
}
$arr2 = $this->getAssignedTo();
$this->assignedto =& $arr;
- //If no one is assigned, then assign it to "100" - NOBODY
+ // If no one is assigned, then assign it to "100" - NOBODY
if (!$arr || count($arr) < 1 || ((count($arr)==1) && ($arr[0]==''))) {
$arr=array('100');
}
array ($this->getID(),
$del_arr[$i])) ;
if (db_error()) {
- $this->setError('setAssignedTo()-1:: '.db_error());
+ $this->setError(db_error());
return false;
}
}
array ($this->getID(),
$add_arr[$i])) ;
if (db_error()) {
- $this->setError('setAssignedTo()-2:: '.db_error());
+ $this->setError(db_error());
return false;
}
}
$new_group_project_id,$duration=0,$parent_id=0) {
$has_changes = false; // if any of the values passed is different from
- $arrChangedAndInNotice = array("details"=>"","summary"=>"",
- "complete"=>"","status"=>"","subproject"=>""); /* includes only
- entries that changed and will be sended by E-Mail (sendNotice()) */
+ $arrChangedAndInNotice = array(
+ 'details'=>'',
+ 'summary'=>'',
+ 'assigned'=>'',
+ 'complete'=>'',
+ 'status'=>'',
+ 'subproject'=>''
+ );
$v = new Validator();
- $v->check($summary, "summary");
- $v->check($priority, "priority");
- $v->check($hours, "hours");
- $v->check($start_date, "start date");
- $v->check($end_date, "end date");
- $v->check($status_id, "status");
- $v->check($category_id, "category");
+ $v->check($summary, _("summary"));
+ $v->check($priority, _("priority"));
+ $v->check($hours, _("hours"));
+ $v->check($start_date, _("start date"));
+ $v->check($end_date, _("end date"));
+ $v->check($status_id, _("status"));
+ $v->check($category_id, _("category"));
if (!$v->isClean()) {
- $this->setError($v->formErrorMsg("Must include "));
+ $this->setError($v->formErrorMsg(_("Must include ")));
return false;
}
if (!$parent_id) {
}
$old_assigned = $this->getAssignedTo();
- $diff_assigned_array=array_diff($old_assigned, $assigned_arr);
- if (count($diff_assigned_array)>0) {
- for ($tmp=0;$tmp<count($old_assigned);$tmp++) {
- $this->addHistory('assigned_to_id',$old_assigned[$tmp]);
- }
- $has_changes = true;
+ if ($assigned_arr == '' || !$assigned_arr) {
+ $assigned_arr = array();
+ $assigned_arr[0] = 100;
+ }
+ $removed=array_diff($old_assigned, $assigned_arr);
+ $added=array_diff($assigned_arr, $old_assigned);
+ if (count($removed)>0 || count($added)>0) {
+ $assigned = array();
+ foreach ($old_assigned as $user_id) {
+ $assigned[] = user_get_object($user_id)->getRealName();
+ }
+ $this->addHistory('assigned_to', join(', ', $assigned));
+ $arrChangedAndInNotice['assigned'] = ">";
+ $has_changes = true;
}
+
$old_array = array_keys($this->getDependentOn());
- $diff_array=array_diff($old_array,array_keys($depend_arr));
- if (count($diff_array)>0) {
- for ($tmp=0;$tmp<count($old_array);$tmp++) {
- $this->addHistory('dependent_on_id', $old_array[$tmp]);
- }
+ if (!is_array($depend_arr)) {
+ $depend_arr = array();
+ }
+ $removed=array_diff($old_array,array_keys($depend_arr));
+ $added=array_diff(array_keys($depend_arr), $old_array);
+ if (count($removed)>0 || count($added)>0) {
+ $this->addHistory('dependent_on', join(', ', $old_array));
$has_changes = true;
}
$parent_id,
$group_project_id,
$this->getID())) ;
- if (!$res) {
- $this->setError('Error On ProjectTask::update-5: '.db_error().$sql);
+ if (!$res || db_affected_rows($res) < 1) {
+ $this->setError(db_error());
db_rollback();
return false;
} else {
if (!$this->fetchData($this->getID())) {
- $this->setError('Error On ProjectTask::update-6: '.db_error());
+ $this->setError(db_error());
db_rollback();
return false;
} else {
return true;
}
- $body = "Task #". $this->getID() ." has been updated. ".
+ if (session_loggedin()) {
+ $user = session_get_user()->getRealName();
+ } else {
+ $user = '';
+ }
+
+ $body = "Task #". $this->getID() ." has been updated by $user.".
"\n\nProject: ". $this->ProjectGroup->Group->getPublicName();
- if (isset($arrChangedAndInNotice['subproject']))
- $body .= "\n". $arrChangedAndInNotice['subproject']."Subproject: ". $this->ProjectGroup->getName();
- if (isset($arrChangedAndInNotice['summary']))
- $body .= "\n". $arrChangedAndInNotice['summary']. "Summary: ".util_unconvert_htmlspecialchars( $this->getSummary() );
+ if (isset($arrChangedAndInNotice['subproject']))
+ $body .= "\n". $arrChangedAndInNotice['subproject']."Subproject: ". $this->ProjectGroup->getName();
+
+ if (isset($arrChangedAndInNotice['summary']))
+ $body .= "\n". $arrChangedAndInNotice['summary']. "Summary: ".util_unconvert_htmlspecialchars( $this->getSummary() );
- if (isset($arrChangedAndInNotice['complete']))
- $body .= "\n". $arrChangedAndInNotice['complete']. "Complete: ". $this->getPercentComplete() ."%";
+ if (isset($arrChangedAndInNotice['complete']))
+ $body .= "\n". $arrChangedAndInNotice['complete']. "Complete: ". $this->getPercentComplete() ."%";
- if (isset($arrChangedAndInNotice['status']))
- $body .= "\n". $arrChangedAndInNotice['status']. "Status: ". $this->getStatusName();
+ if (isset($arrChangedAndInNotice['status']))
+ $body .= "\n". $arrChangedAndInNotice['status']. "Status: ". $this->getStatusName();
+
+ if (isset($arrChangedAndInNotice['assigned'])) {
+ $assigned = array();
+ foreach ($this->getAssignedTo() as $user_id) {
+ $assigned[] = user_get_object($user_id)->getRealName();
+ }
+ $body .= "\n". $arrChangedAndInNotice['assigned']. "Assigned: ". join(', ', $assigned);
+ }
- $body .= "\n\nDescription: ". util_unconvert_htmlspecialchars( $this->getDetails() );
+ $body .= "\n\nDescription: ". util_unconvert_htmlspecialchars( $this->getDetails() );
/*
Now get the followups to this task