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()
		);
	}
	static function getArrayInfo($raw_data, $full = false){
		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' => $raw_data['id'],
			't' => $raw_data['name'],
			'desc' => $desc,
			'members' => $member_ids,
			'c' => strtotime($raw_data['created_on']),
			'cid' => (int)$raw_data['created_by_id'],
			'otype' => $raw_data['object_subtype'],
			'pc' => (int)$raw_data['percent_completed'],
			'memPath' => str_replace('"',"'", str_replace("'", "\'", json_encode($tmp_task->getMembersToDisplayPath($member_ids))))
		);

		if ($full) {
			$result['description'] = $raw_data['text'];
		}

		$result['mas'] = (int)array_var($raw_data, 'multi_assignment');
			
		if ($raw_data['completed_by_id'] > 0) {
			$result['s'] = 1;
		}
			
		if ($raw_data['parent_id'] > 0) {
			$result['pid'] = (int)$raw_data['parent_id'];
		}
		//if ($this->getPriority() != 200)
		$result['pr'] = (int)$raw_data['priority'];

		if ($raw_data['milestone_id'] > 0) {
			$result['mid'] = (int)$raw_data['milestone_id'];
		}
			
		if ($raw_data['assigned_to_contact_id'] > 0) {
			$result['atid'] = (int)$raw_data['assigned_to_contact_id'];
		}
		$result['atName'] = $tmp_task->getAssignedToName();

		if ($raw_data['completed_by_id'] > 0) {
			$result['cbid'] = (int)$raw_data['completed_by_id'];
			$result['con'] = strtotime($raw_data['completed_on']);;
		}
			
		if ($raw_data['due_date'] != EMPTY_DATETIME) {
			$result['dd'] = strtotime($raw_data['due_date']) + logged_user()->getTimezone() * 3600;
			$result['udt'] = $raw_data['use_due_time'] ? 1 : 0;
		}
		if ($raw_data['start_date'] != EMPTY_DATETIME) {
			$result['sd'] = strtotime($raw_data['start_date']) + logged_user()->getTimezone() * 3600;
			$result['ust'] = $raw_data['use_start_time'] ? 1 : 0;
		}

		$time_estimate = $raw_data['time_estimate'];
		$result['te'] = $raw_data['time_estimate'];
		if ($time_estimate > 0) $result['et'] = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60) ;


		$result['tz'] = 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['wpt'] = $t->getPausedOn()->getTimestamp();
				}
			}
			$result['wt'] = $time;
			$result['wid'] = $users;
			$result['wp'] = $paused;
		}

		if ($raw_data['repeat_forever'] > 0 || $raw_data['repeat_num'] > 0 || $raw_data['repeat_end'] != EMPTY_DATETIME) {
			$result['rep'] = 1;
		}
		
		return $result;
	}
 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());
 }
Beispiel #4
0
                                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 
                                    echo $task->getId();
                                    ?>
, '<i>' + '<?php 
                                    echo $tip_title;
                                    ?>
 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;
 }