当前位置: 首页>>代码示例>>PHP>>正文


PHP ProjectTasks::findAll方法代码示例

本文整理汇总了PHP中ProjectTasks::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectTasks::findAll方法的具体用法?PHP ProjectTasks::findAll怎么用?PHP ProjectTasks::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectTasks的用法示例。


在下文中一共展示了ProjectTasks::findAll方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ExecuteQuery

 function ExecuteQuery()
 {
     $this->data = array();
     $date = new DateTimeValue(Time());
     $notYet = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND ( due_date = \'0000-00-00 00:00:00\' OR due_date > \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "')"));
     $today = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date = \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
     $past = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date > \'1900-01-01 00:00:00\' AND due_date < \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
     $value = 0;
     if (isset($past)) {
         $value = count($past);
     }
     $this->data['values'][0]['labels'][] = 'Overdue';
     $this->data['values'][0]['values'][] = $value;
     $value = 0;
     if (isset($notYet)) {
         $value = count($notYet);
     }
     $this->data['values'][0]['labels'][] = 'Not yet due';
     $this->data['values'][0]['values'][] = $value;
     $value = 0;
     if (isset($today)) {
         $value = count($today);
     }
     $this->data['values'][0]['labels'][] = 'Due today';
     $this->data['values'][0]['values'][] = $value;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:26,代码来源:TasksByDueDate.class.php

示例2: getUsersTasks

 /**
  * Return array of task that are assigned to specific user or his company
  *
  * @param User $user
  * @return array
  */
 function getUsersTasks(User $user)
 {
     $task_lists = $this->getTaskLists();
     if (!is_array($task_lists)) {
         return false;
     }
     // if
     $task_list_ids = array();
     foreach ($task_lists as $task_list) {
         if (!$user->isMemberOfOwnerCompany() && $task_list->isPrivate()) {
             continue;
         }
         // if
         $task_list_ids[] = $task_list->getId();
     }
     // if
     return ProjectTasks::findAll(array('conditions' => array('`task_list_id` IN (?) AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?)) AND `completed_on` = ?', $task_list_ids, $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, EMPTY_DATETIME), 'order' => '`created_on`'));
     // findAll
 }
开发者ID:swenson,项目名称:projectpier,代码行数:25,代码来源:Project.class.php

示例3: quick_edit_task

 function quick_edit_task()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $task = ProjectTasks::findById(get_id());
     if (!$task instanceof ProjectTask) {
         flash_error(lang('task list dnx'));
         return;
     }
     if (!$task->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     $task_data = array_var($_POST, 'task');
     // set task dates
     if (is_array($task_data)) {
         $send_edit = false;
         if ($task->getAssignedToContactId() == array_var($task_data, 'assigned_to_contact_id')) {
             $send_edit = true;
         }
         $task_data['due_date'] = getDateValue(array_var($task_data, 'task_due_date'));
         $task_data['start_date'] = getDateValue(array_var($task_data, 'task_start_date'));
         if ($task_data['due_date'] instanceof DateTimeValue) {
             $duetime = getTimeValue(array_var($task_data, 'task_due_time'));
             if (is_array($duetime)) {
                 $task_data['due_date']->setHour(array_var($duetime, 'hours'));
                 $task_data['due_date']->setMinute(array_var($duetime, 'mins'));
             }
             $task_data['due_date']->advance(logged_user()->getTimezone() * -3600);
             $task_data['use_due_time'] = is_array($duetime);
         }
         if ($task_data['start_date'] instanceof DateTimeValue) {
             $starttime = getTimeValue(array_var($task_data, 'task_start_time'));
             if (is_array($starttime)) {
                 $task_data['start_date']->setHour(array_var($starttime, 'hours'));
                 $task_data['start_date']->setMinute(array_var($starttime, 'mins'));
             }
             $task_data['start_date']->advance(logged_user()->getTimezone() * -3600);
             $task_data['use_start_time'] = is_array($starttime);
         }
         if (config_option("wysiwyg_tasks")) {
             $task_data['type_content'] = "html";
             $task_data['text'] = preg_replace("/[\n|\r|\n\r]/", '', array_var($task_data, 'text'));
         } else {
             $task_data['type_content'] = "text";
         }
         $task->setFromAttributes($task_data);
         if (array_var($_GET, 'dont_mark_as_read')) {
             $is_read = $task->getIsRead(logged_user()->getId());
         }
         try {
             DB::beginWork();
             $subs = array();
             if (config_option('multi_assignment') && Plugins::instance()->isActivePlugin('crpm')) {
                 if (array_var($task_data, 'multi_assignment_aplly_change') == 'subtask') {
                     $null = null;
                     Hook::fire('edit_subtasks', $task, $null);
                     $subtasks = ProjectTasks::findAll(array('conditions' => '`parent_id` = ' . DB::escape($task->getId())));
                     // findAll
                     foreach ($subtasks as $sub) {
                         $subs[] = $sub->getArrayInfo();
                     }
                 }
             }
             $task->save();
             // get member ids
             $member_ids = array();
             if (array_var($task_data, 'members')) {
                 $member_ids = json_decode(array_var($task_data, 'members'));
             }
             // get member id when changing member via drag & drop
             if (array_var($task_data, 'member_id')) {
                 $member_ids[] = array_var($task_data, 'member_id');
             }
             // drag & drop - also apply changes to subtasks
             $tasks_to_update = $task->getAllSubTasks();
             $tasks_to_update[] = $task;
             // calculate and set time estimate
             $totalMinutes = array_var($task_data, 'hours') * 60 + array_var($task_data, 'minutes');
             $task->setTimeEstimate($totalMinutes);
             $task->save();
             $assignee = $task->getAssignedToContact();
             if ($assignee instanceof Contact) {
                 $task->subscribeUser($assignee);
             }
             // add to members, subscribers, etc
             $object_controller = new ObjectController();
             if (count($member_ids) > 0) {
                 foreach ($tasks_to_update as $task_to_update) {
                     $object_controller->add_to_members($task_to_update, $member_ids);
                 }
             }
             $task->resetIsRead();
             $log_info = '';
             if ($send_edit == true) {
                 $log_info = $task->getAssignedToContactId();
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:TaskController.class.php

示例4: findByTaskAndRelated

	function findByTaskAndRelated($task_id,$original_task_id) {
		return ProjectTasks::findAll(array('conditions' => array('(`original_task_id` = ? OR `object_id` = ?) AND `object_id` <> ?', $original_task_id,$original_task_id,$task_id)));
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:3,代码来源:ProjectTasks.class.php

示例5: getCompletedTasks

 /**
  * Return completed tasks
  *
  * @access public
  * @param void
  * @return array
  */
 function getCompletedTasks()
 {
     if (is_null($this->completed_tasks)) {
         $this->completed_tasks = ProjectTasks::findAll(array('conditions' => '`task_list_id` = ' . DB::escape($this->getId()) . ' AND `completed_on` > ' . DB::escape(EMPTY_DATETIME), 'order' => '`completed_on` DESC'));
         // findAll
     }
     // if
     return $this->completed_tasks;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:16,代码来源:ProjectTaskList.class.php

示例6: new_list_tasks


//.........这里部分代码省略.........
             // Today + Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 20:
             // Actives task by current user
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_user_id` = " . logged_user()->getId();
             break;
         case 21:
             // Subscribed tasks by current user
             $res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `object_manager` LIKE 'ProjectTasks' AND `user_id` = " . logged_user()->getId());
             $subs_rows = $res20->fetchAll($res20);
             foreach ($subs_rows as $row) {
                 $subs[] = $row['object_id'];
             }
             unset($res20, $subs_rows, $row);
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")";
             break;
         case 2:
             // All tasks
             break;
         default:
             throw new Exception('Task status "' . $status . '" not recognised');
     }
     if (!$tag) {
         $tagstr = "";
     } else {
         $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_tasks.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectTasks' ) > 0 ";
     }
     $conditions = $template_condition . $task_filter_condition . $task_status_condition . $permissions . $tagstr . $projectstr . " AND `trashed_by_id` = 0 AND `archived_by_id` = 0";
     //Now get the tasks
     $tasks = ProjectTasks::findAll(array('conditions' => $conditions, 'order' => 'created_on DESC', 'limit' => user_config_option('task_display_limit') > 0 ? user_config_option('task_display_limit') + 1 : null));
     ProjectTasks::populateData($tasks);
     //Find all internal milestones for these tasks
     $internalMilestones = ProjectMilestones::getProjectMilestones(active_or_personal_project(), null, 'DESC', "", null, null, null, $status == 0, false);
     ProjectMilestones::populateData($internalMilestones);
     //Find all external milestones for these tasks
     $milestone_ids = array();
     if ($tasks) {
         foreach ($tasks as $task) {
             if ($task->getMilestoneId() != 0) {
                 $milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId();
             }
         }
     }
     $milestone_ids_condition = '';
     if (count($milestone_ids) > 0) {
         $milestone_ids_condition = ' OR id in (' . implode(',', $milestone_ids) . ')';
     }
     if ($status == 0) {
         $pendingstr = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " ";
     } else {
         $pendingstr = "";
     }
     if (!$tag) {
         $tagstr = "";
     } else {
         $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_milestones.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectMilestones' ) > 0 ";
     }
     $projectstr = " AND (" . ProjectMilestones::getWorkspaceString($pids) . $milestone_ids_condition . ")";
     $archivedstr = " AND `archived_by_id` = 0 ";
     $milestone_conditions = " `is_template` = false " . $archivedstr . $projectstr . $pendingstr;
     $externalMilestonesTemp = ProjectMilestones::findAll(array('conditions' => $milestone_conditions));
     $externalMilestones = array();
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:67,代码来源:TaskController.class.php

示例7: quick_add_task


//.........这里部分代码省略.........
             $task->save();
             $gb_member_ids = array_var($task_data, 'members');
             $member_ids = array();
             $persons_dim = Dimensions::findByCode('feng_persons');
             $persons_dim_id = $persons_dim instanceof Dimension ? $persons_dim->getId() : 0;
             if ($parent) {
                 if (count($parent->getMembers()) > 0) {
                     foreach ($parent->getMembers() as $member) {
                         if ($member->getDimensionId() != $persons_dim_id) {
                             $member_ids[] = $member->getId();
                         }
                     }
                 }
                 $task->setMilestoneId($parent->getMilestoneId());
                 $task->save();
             }
             if (count($member_ids) == 0) {
                 $member_ids = active_context_members(false);
             }
             // get member ids
             if ($gb_member_ids && !empty($gb_member_ids)) {
                 $member_ids = json_decode(array_var($task_data, 'members'));
             }
             $object_controller = new ObjectController();
             $object_controller->add_to_members($task, $member_ids);
             $assignee = $task->getAssignedToContact();
             $assignee_to_me = false;
             if ($assignee instanceof Contact) {
                 $task->subscribeUser($assignee);
                 //do not notify my self
                 if ($assignee->getId() == logged_user()->getId()) {
                     $assignee_to_me = true;
                 }
             }
             // create default reminder by user config option
             if ($task->getDueDate() != null && user_config_option("add_task_default_reminder")) {
                 $reminder = new ObjectReminder();
                 $def = explode(",", user_config_option("reminders_tasks"));
                 $minutes = $def[2] * $def[1];
                 $reminder->setMinutesBefore($minutes);
                 $reminder->setType($def[0]);
                 $reminder->setContext("due_date");
                 $reminder->setObject($task);
                 $reminder->setUserId(0);
                 $date = $task->getDueDate();
                 if ($date instanceof DateTimeValue) {
                     $rdate = new DateTimeValue($date->getTimestamp() - $minutes * 60);
                     $reminder->setDate($rdate);
                 }
                 $reminder->save();
             }
             $subs = array();
             if (config_option('multi_assignment') && Plugins::instance()->isActivePlugin('crpm')) {
                 $json_subtasks = json_decode(array_var($_POST, 'multi_assignment'), true);
                 $subtasks = array();
                 $line = 0;
                 if (is_array($json_subtasks)) {
                     foreach ($json_subtasks as $json_subtask) {
                         $subtasks[$line]['assigned_to_contact_id'] = $json_subtask['assigned_to_contact_id'];
                         $subtasks[$line]['name'] = $json_subtask['name'];
                         $subtasks[$line]['time_estimate_hours'] = $json_subtask['time_estimate_hours'];
                         $subtasks[$line]['time_estimate_minutes'] = $json_subtask['time_estimate_minutes'];
                         $line++;
                     }
                 }
                 Hook::fire('save_subtasks', $task, $subtasks);
                 $subtasks = ProjectTasks::findAll(array('conditions' => '`parent_id` = ' . DB::escape($task->getId())));
                 // findAll
                 foreach ($subtasks as $sub) {
                     $subs[] = $sub->getArrayInfo();
                 }
             }
             // subscribe
             $task->subscribeUser(logged_user());
             //for calculate member status we save de task again after the object have the members
             $task->save();
             DB::commit();
             $isSailent = true;
             // notify asignee
             if ((array_var($task_data, 'notify') == 'true' || user_config_option("can notify from quick add") && !user_config_option("show_notify_checkbox_in_quick_add")) && !$assignee_to_me) {
                 $isSailent = false;
                 try {
                     Notifier::taskAssigned($task);
                 } catch (Exception $e) {
                     Logger::log($e->getMessage());
                     Logger::log($e->getTraceAsString());
                 }
                 // try
             }
             ApplicationLogs::createLog($task, ApplicationLogs::ACTION_ADD, null, $isSailent);
             ajx_extra_data(array("task" => $task->getArrayInfo(), 'subtasks' => $subs));
             flash_success(lang('success add task', $task->getObjectName()));
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:TaskController.class.php

示例8: lang

    ?>
<b><?php 
    echo lang('task list');
    ?>
:</b> <?php 
    echo $taskList->getName() . "<br>\n";
    ?>
<ol>
<?php 
    $condition = 'task_list_id = ' . $taskList->getId();
    if (!$settings->getIncludeEveryone()) {
        $condition .= " and assigned_to_user_id = " . $user->getId();
    }
    $condition .= " and completed_on is null";
    $condition .= " and due_date < Interval " . $settings->getRemindersFuture() . " day + now()";
    $tasks = ProjectTasks::findAll(array('conditions' => $condition));
    foreach ($tasks as $task) {
        echo "<li>";
        echo "<a href='" . str_replace('&amp;', '&', externalUrl($task->getViewUrl())) . "'>";
        echo $task->getText();
        echo "</a> ";
        if ($settings->getIncludeEveryone() && $task->getAssignedTo() && $task->getAssignedTo()->getObjectName() != $user->getObjectName()) {
            echo " - <i>assigned to " . $task->getAssignedTo()->getObjectName() . "</i> - ";
        } else {
            if (!$task->getAssignedTo()) {
                echo " - <i>assigned to anyone</i> - ";
            }
        }
        if ($task->getDueDate()->isUpcoming()) {
            echo format_days('is future', $task->getDueDate()->getLeftInDays());
        } elseif ($task->getDueDate()->isToday()) {
开发者ID:bklein01,项目名称:Project-Pier,代码行数:31,代码来源:reminders_all.php

示例9: send_reports

 function send_reports()
 {
     $company = Companies::findById(1);
     $lTime = time() + 60 * 60 * $company->getTimezone();
     $dayOfWeek = date("l", $lTime);
     $footer = '<a href="' . externalUrl(ROOT_URL) . '">' . externalUrl(ROOT_URL) . "</a>";
     $people = Reminders::findAll(array('conditions' => 'reports_enabled = 1 and report_day = "' . $dayOfWeek . '"'));
     if (is_array($people) && count($people)) {
         foreach ($people as $person) {
             tpl_assign('settings', $person);
             $user = Users::findById($person->getUserId());
             tpl_assign('user', $user);
             $offset = 60 * 60 * $user->getTimezone();
             tpl_assign('offset', $offset);
             $allProjects = $user->getProjects();
             $emailBody = '';
             $recipient = Notifier::prepareEmailAddress($user->getEmail(), $user->getDisplayName());
             foreach ($allProjects as $project) {
                 if ($project->isActive() || $project->getCompletedOn()->getLeftInDays() > -7) {
                     tpl_assign('project', $project);
                     $condition = 'project_id = ' . $project->getId();
                     $condition .= " and is_private = 0 and is_silent = 0";
                     if (!$person->getReportsIncludeEveryone()) {
                         $condition .= ' and taken_by_id = ' . $user->getId();
                     }
                     $logs = array();
                     if ($person->getReportsIncludeActivity()) {
                         $condition .= " and created_on > Interval -7 day + now()";
                         $logs = ApplicationLogs::findAll(array('conditions' => $condition));
                     }
                     tpl_assign('logs', $logs);
                     $taskLists = $project->getAllTaskLists();
                     $emailTaskLists = array();
                     if (is_array($taskLists) && count($taskLists)) {
                         foreach ($taskLists as $taskList) {
                             $condition = 'task_list_id = ' . $taskList->getId();
                             if (!$person->getReportsIncludeEveryone()) {
                                 $condition .= " and assigned_to_user_id = " . $user->getId();
                             }
                             $condition .= " and completed_on > Interval -7 day + now()";
                             $tasks = ProjectTasks::findAll(array('conditions' => $condition));
                             if (is_array($tasks) && count($tasks)) {
                                 $emailTaskLists[] = $taskList;
                             }
                         }
                     }
                     if (count($emailTaskLists) || count($logs)) {
                         tpl_assign('taskLists', $emailTaskLists);
                         $emailBody .= tpl_fetch(get_template_path('report_per_project', 'reminders'));
                         if ($person->getReportsSummarizedBy()) {
                             try {
                                 Notifier::sendEmail($recipient, $recipient, "[ProjectPier] - Project Report - " . $project->getObjectName(), $emailBody . $footer, 'text/html');
                                 // send
                                 $emailBody = '';
                             } catch (Exception $e) {
                                 echo $e;
                             }
                         }
                     }
                 }
             }
             if (strlen($emailBody) && !$person->getReportsSummarizedBy()) {
                 $time = time() + 60 * 60 * $user->getTimezone();
                 try {
                     Notifier::sendEmail($recipient, $recipient, "[ProjectPier] - Activity Report - " . gmdate('Y/m/d', $time), $emailBody . $footer, 'text/html');
                     // send
                     $emailBody = '';
                 } catch (Exception $e) {
                     echo $e;
                 }
             }
         }
     }
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:74,代码来源:RemindersController.class.php

示例10: foreach

?>
			this.dialog.setTitle(lang('tasks related'));
			this.dialog.show();
		}
		
		<?php 
if (!$task->isCompleted()) {
    ?>
			og.changeTaskRepeat();
		<?php 
}
?>

		<?php 
if (!$task->isNew()) {
    $subtasks = ProjectTasks::findAll(array('conditions' => "parent_id=" . $task->getId() . " AND trashed_by_id=0"));
    foreach ($subtasks as $st) {
        $st_name = clean(escape_character($st->getObjectName()));
        ?>
					ogTasks.drawAddSubTaskInputs('<?php 
        echo $genid;
        ?>
', {id:'<?php 
        echo $st->getId();
        ?>
', name:'<?php 
        echo $st_name;
        ?>
', assigned_to:'<?php 
        echo $st->getAssignedToContactId();
        ?>
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:add_template_task.php

示例11: getCompletedSubTasks

 /**
  * Return completed tasks
  *
  * @access public
  * @param void
  * @return array
  */
 function getCompletedSubTasks()
 {
     if (is_null($this->completed_tasks)) {
         $this->completed_tasks = ProjectTasks::findAll(array('conditions' => '`milestone_id` = ' . DB::escape($this->getId()) . ' AND `trashed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `completed_on` > ' . DB::escape(EMPTY_DATETIME) . " AND " . permissions_sql_for_listings(new ProjectTasks(), ACCESS_LEVEL_READ, logged_user()), 'order' => '`completed_on` DESC'));
         // findAll
     }
     // if
     return $this->completed_tasks;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:16,代码来源:ProjectMilestone.class.php

示例12: quick_add_task


//.........这里部分代码省略.........
				}

				if(count($member_ids) == 0){
					$member_ids = active_context_members(false);
				}
                                
				if ($gb_member_id && is_numeric($gb_member_id)) {
					$member_ids[] = $gb_member_id;
				}
                                
				$object_controller = new ObjectController();
				$object_controller->add_to_members($task, $member_ids);
				
				//Add new work timeslot for this task
//				if (array_var($task_data,'hours') != '' && array_var($task_data,'hours') > 0){
//					$hours = array_var($task_data, 'hours');
//					$hours = - $hours;
//						
//					$timeslot = new Timeslot();
//					$dt = DateTimeValueLib::now();
//					$dt2 = DateTimeValueLib::now();
//					$timeslot->setEndTime($dt);
//					$dt2 = $dt2->add('h', $hours);
//					$timeslot->setStartTime($dt2);
//					$timeslot->setContactId(logged_user()->getId());
//					$timeslot->setObjectId($task->getId());
//					$timeslot->save();
//				}

				ApplicationLogs::createLog($task, ApplicationLogs::ACTION_ADD);
				$assignee = $task->getAssignedToContact();
				if ($assignee instanceof Contact) {
					$task->subscribeUser($assignee);
				}
				
				// create default reminder by user config option
				if ($task->getDueDate()!= null && user_config_option("add_task_default_reminder")){			
					$reminder = new ObjectReminder();
					$def = explode(",",user_config_option("reminders_tasks"));          			
					$minutes = $def[2] * $def[1];
          			$reminder->setMinutesBefore($minutes);
                    $reminder->setType($def[0]);
                    $reminder->setContext("due_date");
                    $reminder->setObject($task);
                    $reminder->setUserId(0);
                    $date = $task->getDueDate();
                                        
					if ($date instanceof DateTimeValue) {
						$rdate = new DateTimeValue($date->getTimestamp() - $minutes * 60);
						$reminder->setDate($rdate);
					}
					$reminder->save();
				}
				
				$subs = array();
				if(config_option('multi_assignment') && Plugins::instance()->isActivePlugin('crpm')){
					$json_subtasks = json_decode(array_var($_POST, 'multi_assignment'), true);
					$subtasks = array();
					$line = 0;
					if (is_array($json_subtasks)) {
						foreach ($json_subtasks as $json_subtask){
							$subtasks[$line]['assigned_to_contact_id'] = $json_subtask['assigned_to_contact_id'];
							$subtasks[$line]['name'] = $json_subtask['name'];
							$subtasks[$line]['time_estimate_hours'] = $json_subtask['time_estimate_hours'];
							$subtasks[$line]['time_estimate_minutes'] = $json_subtask['time_estimate_minutes'];
							$line++;
						}
					}
					Hook::fire('save_subtasks', $task, $subtasks);

					$subtasks = ProjectTasks::findAll(array(
						'conditions' => '`parent_id` = ' . DB::escape($task->getId())
					)); // findAll
					foreach ($subtasks as $sub){
						$subs[] = $sub->getArrayInfo();
					}
				}
				
				// subscribe
				$task->subscribeUser(logged_user());
                                
				DB::commit();

				// notify asignee
				if(array_var($task_data, 'notify') == 'true') {
					try {
						Notifier::taskAssigned($task);
					} catch(Exception $e) {
						Logger::log($e->getMessage());
						Logger::log($e->getTraceAsString());
					} // try
				}
				ajx_extra_data(array("task" => $task->getArrayInfo(), 'subtasks' => $subs));
				flash_success(lang('success add task', $task->getObjectName()));
			} catch(Exception $e) {
				DB::rollback();
				flash_error($e->getMessage());
			} // try
		} // if
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:TaskController.class.php


注:本文中的ProjectTasks::findAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。