/** * A custom method within the Plugin to generate the content * * @return string : HTML * @see class/ProjectTask.class.php * @see class/OfuzHorizontalSlider.class.php */ function generateProgressBlock() { $output = ''; $output .= '<form method="get" action="' . $_SERVER['PHP_SELF'] . '">'; $do_project_task_progress = new ProjectTask(); $do_project_task_progress->getId($_SESSION['do_project_task']->idproject_task); $do_project_task_progress->sessionPersistent('do_project_task_progress', 'project.php', OFUZ_TTL); $_SESSION['do_project_task_progress']->setFields(new Fields()); $_SESSION['do_project_task_progress']->fields->addField(new OfuzHorizontalSlider("progress")); $_SESSION['do_project_task_progress']->setApplyRegistry(true, "Form"); $output .= $_SESSION['do_project_task_progress']->progress; $output .= '</form>'; return $output; }
private function task_item(ProjectTask $task) { return array( "id" => $task->getId(), "title" => clean($task->getObjectName()), "parent" => $task->getParentId(), "milestone" => $task->getMilestoneId(), "assignedTo" => $task->getAssignedTo()? $task->getAssignedToName():'', "completed" => $task->isCompleted(), "completedBy" => $task->getCompletedByName(), "isLate" => $task->isLate(), "daysLate" => $task->getLateInDays(), "priority" => $task->getPriority(), "percentCompleted" => $task->getPercentCompleted(), "duedate" => ($task->getDueDate() ? $task->getDueDate()->getTimestamp() : '0'), "order" => $task->getOrder() ); }
/** * Copies subtasks from taskFrom to taskTo. * * @param ProjectTask $taskFrom * @param ProjectTask $taskTo */ function copySubTasks(ProjectTask $taskFrom, ProjectTask $taskTo, $as_template = false) { foreach ( $taskFrom->getSubTasks () as $sub ) { if ($sub->getId() == $taskTo->getId()) continue; $new = ProjectTasks::createTaskCopy ( $sub ); $new->setIsTemplate ( $as_template ); $new->setParentId ( $taskTo->getId () ); $new->setMilestoneId ( $taskTo->getMilestoneId () ); $new->setOrder ( ProjectTasks::maxOrder ( $new->getParentId (), $new->getMilestoneId () ) ); if ($sub->getIsTemplate ()) { $new->setFromTemplateId ( $sub->getId () ); } $new->save (); $object_controller = new ObjectController(); if (count($taskFrom->getMemberIds())) { $object_controller->add_to_members($new, $taskFrom->getMemberIds()); } $new->copyCustomPropertiesFrom ( $sub ); $new->copyLinkedObjectsFrom ( $sub ); ProjectTasks::copySubTasks ( $sub, $new, $as_template ); } }
private function task_item(ProjectTask $task) { $isCurrentProject = active_project() instanceof Project && $task->getProjectId() == active_project()->getId(); return array("id" => $task->getId(), "title" => clean($task->getObjectName()), "parent" => $task->getParentId(), "milestone" => $task->getMilestoneId(), "assignedTo" => $task->getAssignedTo() ? $task->getAssignedToName() : '', "workspaces" => $isCurrentProject ? '' : $task->getWorkspacesNamesCSV(logged_user()->getWorkspacesQuery()), "workspaceids" => $isCurrentProject ? '' : $task->getWorkspacesIdsCSV(logged_user()->getWorkspacesQuery()), "workspacecolors" => $isCurrentProject ? '' : $task->getWorkspaceColorsCSV(logged_user()->getWorkspacesQuery()), "completed" => $task->isCompleted(), "completedBy" => $task->getCompletedByName(), "isLate" => $task->isLate(), "daysLate" => $task->getLateInDays(), "priority" => $task->getPriority(), "duedate" => $task->getDueDate() ? $task->getDueDate()->getTimestamp() : '0', "order" => $task->getOrder()); }
/** * Return all times that are assigned to the task * * @param ProjectTask $task * @return array */ static function getTimeByTask(ProjectTask $task) { return self::findAll(array('conditions' => array('`task_id` = ? ', $task->getId()), 'order' => '`done_date`')); // findAll }
$ico = "ico-task-start"; $tip_pre = 'st_'; } } $count++; if ($count <= 3) { $ws_color = $task->getObjectColor($task instanceof ProjectEvent ? 1 : 12); cal_get_ws_color($ws_color, $ws_style, $ws_class, $txt_color, $border_color); $cal_text = clean($task->getTitle()); if (function_exists('mb_strlen')) { $cal_text = mb_strlen($cal_text) < $to_show_len ? $cal_text : mb_substr($cal_text, 0, $to_show_len - 3) . "..."; } else { $cal_text = strlen($cal_text) < $to_show_len ? $cal_text : substr($cal_text, 0, $to_show_len - 3) . "..."; } $output .= "<div class='nobr og-wsname-color-{$ws_color}' style='border-radius:4px;height:17px;margin:1px;padding:1px;z-index:1000;border: 1px solid;border-color:{$border_color}'>"; $output .= "<span id='o_ta_div_{$tip_pre}" . $task->getId() . "'>"; $output .= "<a class=\"internalLink link-ico {$ico}\" style='vertical-align:bottom;' href='" . $task->getViewUrl() . "' onclick=\"og.disableEventPropagation(event);\" >"; $output .= $cal_text . "</a>"; $output .= '</span>'; $output .= "</div>"; $tip_text = str_replace("\r", '', lang('assigned to') . ': ' . clean($task->getAssignedToName()) . (trim(clean($task->getText())) == '' ? '' : '<br><br>' . clean(html_to_text($task->getText())))); $tip_text = str_replace("\n", '<br>', $tip_text); if (strlen_utf($tip_text) > 200) { $tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...'; } ?> <script> addTip('o_ta_div_<?php echo $tip_pre; ?> ' + <?php
static function getArrayInfo($raw_data, $full = false) { $desc = ""; if ($full) { if (config_option("wysiwyg_tasks")) { if ($raw_data['type_content'] == "text") { $desc = nl2br(htmlspecialchars($raw_data['text'])); } else { $desc = purify_html(nl2br($raw_data['text'])); } } else { if ($raw_data['type_content'] == "text") { $desc = htmlspecialchars($raw_data['text']); } else { $desc = html_to_text(html_entity_decode(nl2br($raw_data['text']), null, "UTF-8")); } } } $member_ids = ObjectMembers::instance()->getCachedObjectMembers($raw_data['id']); $tmp_task = new ProjectTask(); $tmp_task->setObjectId($raw_data['id']); $tmp_task->setId($raw_data['id']); $tmp_task->setAssignedToContactId($raw_data['assigned_to_contact_id']); $result = array('id' => (int) $raw_data['id'], 'name' => $raw_data['name'], 'description' => $desc, 'members' => $member_ids, 'createdOn' => strtotime($raw_data['created_on']), 'createdById' => (int) $raw_data['created_by_id'], 'otype' => $raw_data['object_subtype'], 'percentCompleted' => (int) $raw_data['percent_completed'], 'memPath' => str_replace('"', "'", escape_character(json_encode($tmp_task->getMembersIdsToDisplayPath())))); if (isset($raw_data['isread'])) { $result['isread'] = $raw_data['isread']; } $result['multiAssignment'] = (int) array_var($raw_data, 'multi_assignment'); if ($raw_data['completed_by_id'] > 0) { $result['status'] = 1; } if ($raw_data['parent_id'] > 0) { $result['parentId'] = (int) $raw_data['parent_id']; } $result['subtasksIds'] = $tmp_task->getSubTasksIds(); //if ($this->getPriority() != 200) $result['priority'] = (int) $raw_data['priority']; if ($raw_data['milestone_id'] > 0) { $result['milestoneId'] = (int) $raw_data['milestone_id']; } if ($raw_data['assigned_by_id'] > 0) { $result['assignedById'] = (int) $raw_data['assigned_by_id']; } if ($raw_data['assigned_to_contact_id'] > 0) { $result['assignedToContactId'] = (int) $raw_data['assigned_to_contact_id']; } $result['atName'] = $tmp_task->getAssignedToName(); if ($raw_data['completed_by_id'] > 0) { $result['completedById'] = (int) $raw_data['completed_by_id']; $result['completedOn'] = strtotime($raw_data['completed_on']); } if ($raw_data['due_date'] != EMPTY_DATETIME) { $result['useDueTime'] = $raw_data['use_due_time'] ? 1 : 0; if ($result['useDueTime']) { $result['dueDate'] = strtotime($raw_data['due_date']) + logged_user()->getTimezone() * 3600; } else { $result['dueDate'] = strtotime($raw_data['due_date']); } } if ($raw_data['start_date'] != EMPTY_DATETIME) { $result['useStartTime'] = $raw_data['use_start_time'] ? 1 : 0; if ($result['useStartTime']) { $result['startDate'] = strtotime($raw_data['start_date']) + logged_user()->getTimezone() * 3600; } else { $result['startDate'] = strtotime($raw_data['start_date']); } } $time_estimate = $raw_data['time_estimate']; $result['timeEstimate'] = $raw_data['time_estimate']; if ($time_estimate > 0) { $result['timeEstimateString'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60)); } $result['timeZone'] = logged_user()->getTimezone() * 3600; $ot = $tmp_task->getOpenTimeslots(); if ($ot) { $users = array(); $time = array(); $paused = array(); foreach ($ot as $t) { if (!$t instanceof Timeslot) { continue; } $time[] = $t->getSeconds(); $users[] = $t->getContactId(); $paused[] = $t->isPaused() ? 1 : 0; if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) { $result['pauseTime'] = $t->getPausedOn()->getTimestamp(); } } $result['workingOnTimes'] = $time; $result['workingOnIds'] = $users; $result['workingOnPauses'] = $paused; } $total_minutes = $tmp_task->getTotalMinutes(); if ($total_minutes > 0) { $result['worked_time'] = $total_minutes; $result['worked_time_string'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($total_minutes * 60), 'hm', 60)); } else { $result['worked_time'] = 0; } $pending_time = $time_estimate - $total_minutes; if ($pending_time > 0) { $result['pending_time'] = $pending_time; $result['pending_time_string'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($pending_time * 60), 'hm', 60)); } else { $result['pending_time'] = 0; } if ($raw_data['repeat_forever'] > 0 || $raw_data['repeat_num'] > 0 || $raw_data['repeat_end'] != EMPTY_DATETIME && $raw_data['repeat_end'] != '') { $result['repetitive'] = 1; } $tmp_members = array(); if (count($member_ids) > 0) { $tmp_members = Members::findAll(array("conditions" => "id IN (" . implode(',', $member_ids) . ")")); } $result['can_add_timeslots'] = can_add_timeslots(logged_user(), $tmp_members); //tasks dependencies if (config_option('use tasks dependencies')) { //get all dependant tasks ids, not completed yet $pending_tasks_ids = ProjectTaskDependencies::getDependenciesForTaskOnlyPendingIds($tmp_task->getId()); //get the total of previous tasks $result['dependants'] = $pending_tasks_ids; $result['previous_tasks_total'] = ProjectTaskDependencies::countPendingPreviousTasks($tmp_task->getId()); } return $result; }
$attachments_extracted = true; } $task_description = $email_sub; $due_date = 'Today'; $task_category = 'Email'; $due_date_dateformat = date('Y-m-d'); $do_proj_task = new ProjectTask(); $do_proj_task->task_description = $task_description; $do_proj_task->due_date = $due_date; $do_proj_task->task_category = $task_category; $do_proj_task->iduser = $iduser; $do_proj_task->due_date_dateformat = $due_date_dateformat; $do_proj_task->idproject = $drop_box_code_proj; $do_proj_task->add(); $idproject_task = $do_proj_task->getPrimaryKeyValue(); $do_proj_task->getId($idproject_task); $idtask = $do_proj_task->idtask; $do_proj_task->drop_box_code = $idtask; $do_proj_task->update(); //workfeed $do_workfeed = new WorkFeedProjectTask(); $do_workfeed->eventaddFeedFromDropbox($iduser, $idproject_task, $drop_box_code_proj, $idtask, $task_description); //$do_workfeed->free(); //workfeed end //echo $idproject_task; $do_proj_task->free(); //$do_task->free(); if (is_array($attachment) && count($attachment) > 0) { $attachment_count = 0; foreach ($attachment as $attachment) { $attachment_count++;
/** * Copies subtasks from taskFrom to taskTo. * * @param ProjectTask $taskFrom * @param ProjectTask $taskTo */ function copySubTasks(ProjectTask $taskFrom, ProjectTask $taskTo, $as_template = false) { foreach ($taskFrom->getSubTasks() as $sub) { $new = ProjectTasks::createTaskCopy($sub); $new->setIsTemplate($as_template); $new->setParentId($taskTo->getId()); $new->setMilestoneId($taskTo->getMilestoneId()); $new->setOrder(ProjectTasks::maxOrder($new->getParentId(), $new->getMilestoneId())); if ($sub->getIsTemplate()) { $new->setFromTemplateId($sub->getId()); } $new->save(); foreach ($taskTo->getWorkspaces() as $workspace) { if (ProjectTask::canAdd(logged_user(), $workspace)) { $new->addToWorkspace($workspace); } } $new->copyCustomPropertiesFrom($sub); $new->copyLinkedObjectsFrom($sub); $new->setTagsFromCSV(implode(",", $sub->getTagNames())); ProjectTasks::copySubTasks($sub, $new, $as_template); } }
function cloneTask($copy_status = false) { $new_task = new ProjectTask(); $new_task->setParentId($this->getParentId()); $new_task->setTitle($this->getTitle()); $new_task->setText($this->getText()); $new_task->setAssignedToCompanyId($this->getAssignedToCompanyId()); $new_task->setAssignedToUserId($this->getAssignedToUserId()); $new_task->setAssignedOn($this->getAssignedOn()); $new_task->setAssignedById($this->getAssignedById()); $new_task->setTimeEstimate($this->getTimeEstimate()); $new_task->setStartedOn($this->getStartedOn()); $new_task->setStartedById($this->getStartedById()); $new_task->setPriority($this->getPriority()); $new_task->setState($this->getState()); $new_task->setOrder($this->getOrder()); $new_task->setMilestoneId($this->getMilestoneId()); $new_task->setIsPrivate($this->getIsPrivate()); $new_task->setIsTemplate($this->getIsTemplate()); $new_task->setFromTemplateId($this->getFromTemplateId()); if ($this->getDueDate() instanceof DateTimeValue) { $new_task->setDueDate(new DateTimeValue($this->getDueDate()->getTimestamp())); } if ($this->getStartDate() instanceof DateTimeValue) { $new_task->setStartDate(new DateTimeValue($this->getStartDate()->getTimestamp())); } if ($copy_status) { $new_task->setCompletedById($this->getCompletedById()); $new_task->setCompletedOn($this->getCompletedOn()); } $new_task->save(); $new_task->setTagsFromCSV(implode(",", $this->getTagNames())); foreach ($this->getWorkspaces() as $ws) { $new_task->addToWorkspace($ws); } if (is_array($this->getAllLinkedObjects())) { foreach ($this->getAllLinkedObjects() as $lo) { $new_task->linkObject($lo); } } $sub_tasks = $this->getAllSubTasks(); foreach ($sub_tasks as $st) { if ($st->getParentId() == $this->getId()) { $new_st = $st->cloneTask($copy_status); if ($copy_status) { $new_st->setCompletedById($st->getCompletedById()); $new_st->setCompletedOn($st->getCompletedOn()); $new_st->save(); } $new_task->attachTask($new_st); } } foreach ($this->getAllComments() as $com) { $new_com = new Comment(); $new_com->setAuthorEmail($com->getAuthorEmail()); $new_com->setAuthorName($com->getAuthorName()); $new_com->setAuthorHomepage($com->getAuthorHomepage()); $new_com->setCreatedById($com->getCreatedById()); $new_com->setCreatedOn($com->getCreatedOn()); $new_com->setUpdatedById($com->getUpdatedById()); $new_com->setUpdatedOn($com->getUpdatedOn()); $new_com->setIsAnonymous($com->getIsAnonymous()); $new_com->setIsPrivate($com->getIsPrivate()); $new_com->setText($com->getText()); $new_com->setRelObjectId($new_task->getId()); $new_com->setRelObjectManager("ProjectTasks"); $new_com->save(); } $_POST['subscribers'] = array(); foreach ($this->getSubscribers() as $sub) { $_POST['subscribers']["user_" . $sub->getId()] = "checked"; } $obj_controller = new ObjectController(); $obj_controller->add_subscribers($new_task); foreach ($this->getCustomProperties() as $prop) { $new_prop = new ObjectProperty(); $new_prop->setRelObjectId($new_task->getId()); $new_prop->setRelObjectManager($prop->getRelObjectManager()); $new_prop->setPropertyName($prop->getPropertyName()); $new_prop->setPropertyValue($prop->getPropertyValue()); $new_prop->save(); } $custom_props = CustomProperties::getAllCustomPropertiesByObjectType("ProjectTasks"); foreach ($custom_props as $c_prop) { $values = CustomPropertyValues::getCustomPropertyValues($this->getId(), $c_prop->getId()); if (is_array($values)) { foreach ($values as $val) { $cp = new CustomPropertyValue(); $cp->setObjectId($new_task->getId()); $cp->setCustomPropertyId($val->getCustomPropertyId()); $cp->setValue($val->getValue()); $cp->save(); } } } $reminders = ObjectReminders::getByObject($this); foreach ($reminders as $reminder) { $copy_reminder = new ObjectReminder(); $copy_reminder->setContext($reminder->getContext()); $reminder_date = $new_task->getColumnValue($reminder->getContext()); if ($reminder_date instanceof DateTimeValue) { $reminder_date = new DateTimeValue($reminder_date->getTimestamp()); $reminder_date->add('m', -$reminder->getMinutesBefore()); } $copy_reminder->setDate($reminder_date); $copy_reminder->setMinutesBefore($reminder->getMinutesBefore()); $copy_reminder->setObject($new_task); $copy_reminder->setType($reminder->getType()); $copy_reminder->setUserId($reminder->getUserId()); $copy_reminder->save(); } return $new_task; }