function repetitive_tasks_related($task, $action, $type_related = "", $task_data = array()) { //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated($task->getObjectId()); if (!$task_related) { //is not the original as the original look plus other related if ($task->getOriginalTaskId() != "0") { $task_related = ProjectTasks::findByTaskAndRelated($task->getObjectId(), $task->getOriginalTaskId()); } } if ($task_related) { switch ($action) { case "edit": foreach ($task_related as $t_rel) { if ($type_related == "news") { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate()) { $this->repetitive_task_related_edit($t_rel, $task_data); } } else { $this->repetitive_task_related_edit($t_rel, $task_data); } } break; case "delete": $delete_task = array(); foreach ($task_related as $t_rel) { $task_rel = Objects::findObject($t_rel->getId()); if ($type_related == "news") { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate()) { $delete_task[] = $t_rel->getId(); $task_rel->trash(); } } else { $delete_task[] = $t_rel->getId(); $task_rel->trash(); } } return $delete_task; break; case "archive": $archive_task = array(); foreach ($task_related as $t_rel) { $task_rel = Objects::findObject($t_rel->getId()); if ($type_related == "news") { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate()) { $archive_task[] = $t_rel->getId(); $t_rel->archive(); } } else { $archive_task[] = $t_rel->getId(); $t_rel->archive(); } } return $archive_task; break; } } }
/** * End task templates */ function getArrayInfo($full = false) { if (config_option("wysiwyg_tasks")) { if ($this->getTypeContent() == "text") { $desc = nl2br(htmlspecialchars($this->getText())); } else { $desc = purify_html(nl2br($this->getText())); } } else { if ($this->getTypeContent() == "text") { $desc = htmlspecialchars($this->getText()); } else { $desc = html_to_text(html_entity_decode(nl2br($this->getText()), null, "UTF-8")); } } $result = array('id' => $this->getId(), 't' => $this->getObjectName(), 'desc' => $desc, 'members' => $this->getMemberIds(), 'c' => $this->getCreatedOn() instanceof DateTimeValue ? $this->getCreatedOn()->getTimestamp() : 0, 'cid' => $this->getCreatedById(), 'otype' => $this->getObjectSubtype(), 'percentCompleted' => $this->getPercentCompleted(), 'memPath' => str_replace('"', "'", str_replace("'", "\\'", json_encode($this->getMembersToDisplayPath())))); if ($full) { $result['description'] = $this->getText(); } $result['multiAssignment'] = $this->getColumnValue('multi_assignment', 0); if ($this->isCompleted()) { $result['s'] = 1; } if ($this->getParentId() > 0) { $result['pid'] = $this->getParentId(); } //if ($this->getPriority() != 200) $result['pr'] = $this->getPriority(); if ($this->getMilestoneId() > 0) { $result['mid'] = $this->getMilestoneId(); } if ($this->getAssignedToContactId() > 0) { $result['atid'] = $this->getAssignedToContactId(); } $result['atName'] = $this->getAssignedToName(); if ($this->getCompletedById() > 0) { $result['cbid'] = $this->getCompletedById(); $result['con'] = $this->getCompletedOn()->getTimestamp(); } if ($this->getDueDate() instanceof DateTimeValue) { $result['dd'] = $this->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600; $result['udt'] = $this->getUseDueTime() ? 1 : 0; } if ($this->getStartDate() instanceof DateTimeValue) { $result['sd'] = $this->getStartDate()->getTimestamp() + logged_user()->getTimezone() * 3600; $result['ust'] = $this->getUseStartTime() ? 1 : 0; } $time_estimate = $this->getTimeEstimate(); $result['TimeEstimate'] = $this->getTimeEstimate(); if ($time_estimate > 0) { $result['estimatedTime'] = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60); } $result['tz'] = logged_user()->getTimezone() * 3600; $ot = $this->getOpenTimeslots(); if ($ot) { $users = array(); $time = array(); $paused = array(); foreach ($ot as $t) { $time[] = $t->getSeconds(); $users[] = $t->getContactId(); $paused[] = $t->isPaused() ? 1 : 0; if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) { $result['wpt'] = $t->getPausedOn()->getTimestamp(); } } $result['wt'] = $time; $result['wid'] = $users; $result['wp'] = $paused; } if ($this->isRepetitive()) { $result['rep'] = 1; } else { //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated($this->getObjectId()); if (!$task_related) { //is not the original as the original look plus other related if ($this->getOriginalTaskId() != "0") { $task_related = ProjectTasks::findByTaskAndRelated($this->getObjectId(), $this->getOriginalTaskId()); } } if ($task_related) { $result['rep'] = 1; } } return $result; }