public function initialize()
 {
     parent::initialize();
     // Default redirect to avoid redirection loops.
     $this->redirect_url = $this->params["redirect"] ? $this->params["redirect"] : "/";
     // security check
     if ($this->params['request_secure']) {
         try {
             Security::CheckRequest($this->params['request_token']);
         } catch (SecurityException $ex) {
             $this->securityException = $ex->getMessage();
             return;
         }
     }
     $this->redirect = isset($this->params['redirect']) ? $this->params['redirect'] : false;
     if (!empty($this->params['username'])) {
         $this->session->login($this->params['username'], $this->params['password']);
         if ($this->session->isLoggedin()) {
             // reroute
             $this->abort('redirect', $this->redirect_url, null);
         } else {
             $this->error = true;
         }
     } else {
         if (isset($this->params['logout']) && $this->session->isLoggedin()) {
             $this->session->logout();
             $this->loggedout = true;
             $this->abort('redirect', $this->redirect_url, null);
         }
     }
     if ($this->session->isLoggedin()) {
         $this->loggedin = true;
     }
 }
Пример #2
0
 public function _initialize()
 {
     parent::_initialize();
     if (!check_get_key() || I('get.id') == '') {
         $this->error('发生错误');
     }
     $this->id = I('get.id', 0, 'intval');
     $this->page = I('get.page', 1, 'intval');
 }
Пример #3
0
 public function _initialize()
 {
     parent::_initialize();
     if (I('eid')) {
         $eid = I('eid', 0, 'intval');
         $user_id = session('user_id');
         $this->row = D('Examadmin')->chkexamprivilege($eid, $user_id, true);
         if (is_array($this->row)) {
             self::$isruning = D('Examadmin')->chkruning($this->row['start_time'], $this->row['end_time']);
         }
     }
 }
Пример #4
0
 public function _initialize()
 {
     parent::_initialize();
     if (isset($_GET['eid'])) {
         $this->eid = intval($_GET['eid']);
         $this->assign('eid', $this->eid);
     } else {
         if (isset($_POST['eid'])) {
             $this->eid = intval($_POST['eid']);
         } else {
             $this->error('No Such Exam!');
         }
     }
 }
 public function _initialize()
 {
     parent::_initialize();
     if (isset($_GET['eid']) && isset($_GET['type'])) {
         $this->eid = intval($_GET['eid']);
         $type = intval($_GET['type']);
         $this->assign('eid', $this->eid);
         $this->assign('type', $type);
         if (!$this->isowner($this->eid)) {
             $this->error('You have no privilege of this exam~');
         }
     } else {
         if (isset($_POST['eid'])) {
             $this->eid = intval($_POST['eid']);
         } else {
             $this->error('No Such Exam!');
         }
     }
 }
 public function _initialize()
 {
     $this->isNeedFilterSql = true;
     parent::_initialize();
 }
Пример #7
0
 public function _initialize()
 {
     $this->isNeedLogin = false;
     parent::_initialize();
 }
Пример #8
0
 /**
  * Edit task
  *
  * @access public
  * @param void
  * @return null
  */
 function edit_task()
 {
     $isTemplateTask = false;
     if (array_var($_REQUEST, 'template_task') == true) {
         $isTemplateTask = true;
     }
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add_task');
     if (array_var($_REQUEST, "template_task")) {
         $task = TemplateTasks::findById(array_var($_REQUEST, "template_task_id", get_id()));
         $this->setTemplate(get_template_path('add_template_task', 'template_task'));
         if (array_var($_REQUEST, 'template_id')) {
             $template_id = array_var($_REQUEST, 'template_id');
         } else {
             $template_id = $task->getTemplateId();
         }
         tpl_assign('additional_tt_params', array_var($_REQUEST, 'additional_tt_params'));
         tpl_assign('template_id', $template_id);
         if (!$task instanceof TemplateTask) {
             flash_error(lang('task list dnx'));
             ajx_current("empty");
             return;
         }
         // if
     } else {
         $task = ProjectTasks::findById(get_id());
         if (!$task instanceof ProjectTask) {
             flash_error(lang('task list dnx'));
             ajx_current("empty");
             return;
         }
         // if
         if (!$task->canEdit(logged_user())) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
         // if
     }
     if (array_var($_GET, 'replace')) {
         ajx_replace(true);
     }
     $task_data = array_var($_POST, 'task');
     $time_estimate = array_var($_POST, 'hours', 0) * 60 + array_var($_POST, 'minutes', 0);
     if ($time_estimate > 0) {
         $estimatedTime = $time_estimate;
     } else {
         $estimatedTime = $task->getTimeEstimate();
     }
     if (!is_array($task_data)) {
         // set layout for modal form
         if (array_var($_REQUEST, 'modal')) {
             $this->setLayout("json");
             tpl_assign('modal', true);
         }
         $this->getRepeatOptions($task, $occ, $rsel1, $rsel2, $rsel3, $rnum, $rend, $rjump);
         $dd = $task->getDueDate() instanceof DateTimeValue ? $task->getDueDate() : null;
         if ($dd instanceof DateTimeValue && $task->getUseDueTime()) {
             $dd->advance(logged_user()->getTimezone() * 3600);
         }
         $sd = $task->getStartDate() instanceof DateTimeValue ? $task->getStartDate() : null;
         if ($sd instanceof DateTimeValue && $task->getUseStartTime()) {
             $sd->advance(logged_user()->getTimezone() * 3600);
         }
         $post_dd = null;
         if (array_var($_POST, 'task_due_date')) {
             $post_dd = getDateValue(array_var($_POST, 'task_due_date'));
             if ($post_dd instanceof DateTimeValue) {
                 $duetime = getTimeValue(array_var($_POST, 'task_due_time'));
                 if (is_array($duetime)) {
                     $post_dd->setHour(array_var($duetime, 'hours'));
                     $post_dd->setMinute(array_var($duetime, 'mins'));
                     $post_dd->advance(logged_user()->getTimezone() * 3600);
                 }
             }
         }
         $post_st = null;
         if (array_var($_POST, 'task_start_date')) {
             $post_st = getDateValue(array_var($_POST, 'task_start_date'));
             if ($post_st instanceof DateTimeValue) {
                 $starttime = getTimeValue(array_var($_POST, 'task_start_time'));
                 if (is_array($starttime)) {
                     $post_st->setHour(array_var($starttime, 'hours'));
                     $post_st->setMinute(array_var($starttime, 'mins'));
                     $post_st->advance(logged_user()->getTimezone() * 3600);
                 }
             }
         }
         if (config_option("wysiwyg_tasks")) {
             $text_post = preg_replace("/[\n|\r|\n\r]/", '', array_var($_POST, 'text', $task->getText()));
         } else {
             $text_post = array_var($_POST, 'text', $task->getText());
         }
         $task_data = array('name' => array_var($_POST, 'name', $task->getObjectName()), 'text' => $text_post, 'milestone_id' => array_var($_POST, 'milestone_id', $task->getMilestoneId()), 'due_date' => getDateValue($post_dd, $dd), 'start_date' => getDateValue($post_st, $sd), 'parent_id' => $task->getParentId(), 'assigned_to_contact_id' => array_var($_POST, 'assigned_to_contact_id', $task->getAssignedToContactId()), 'selected_members_ids' => json_decode(array_var($_POST, 'members', null)), 'priority' => array_var($_POST, 'priority', $task->getPriority()), 'time_estimate' => $estimatedTime, 'percent_completed' => $task->getPercentCompleted(), 'forever' => $task->getRepeatForever(), 'rend' => $rend, 'rnum' => $rnum, 'rjump' => $rjump, 'rsel1' => $rsel1, 'rsel2' => $rsel2, 'rsel3' => $rsel3, 'occ' => $occ, 'repeat_by' => $task->getRepeatBy(), 'object_subtype' => array_var($_POST, "object_subtype", $task->getObjectSubtype() != 0 ? $task->getObjectSubtype() : config_option('default task co type')), 'type_content' => $task->getTypeContent(), 'multi_assignment' => $task->getColumnValue('multi_assignment', 0), 'send_notification_subscribers' => user_config_option("can notify subscribers"));
         // array
         //control dates of parent and subtasks
         $task_data['type_control'] = "";
         $parent_data = $task->getParent();
         if ($parent_data) {
             $task_data['type_control'] = "child";
             $task_data['control_title'] = $parent_data->getObjectName();
             $task_data['control_due_date'] = $parent_data->getDueDate() instanceof DateTimeValue ? $parent_data->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600 : null;
             $task_data['control_start_date'] = $parent_data->getStartDate() instanceof DateTimeValue ? $parent_data->getStartDate()->getTimestamp() + logged_user()->getTimezone() * 3600 : null;
         }
         $subtask_data = $task->getAllSubTasks();
         if ($subtask_data) {
             $task_data['type_control'] = "father";
             $task_data['control_title'] = $task->getObjectName();
             $task_data['control_due_date'] = getDateValue($post_dd, $dd) instanceof DateTimeValue ? getDateValue($post_dd, $dd)->getTimestamp() : null;
             $task_data['control_start_date'] = getDateValue($post_st, $sd) instanceof DateTimeValue ? getDateValue($post_st, $sd)->getTimestamp() : null;
         }
     }
     // if
     //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) {
         $pending_id = 0;
         foreach ($task_related as $t_rel) {
             if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate() && !$t_rel->isCompleted()) {
                 $pending_id = $t_rel->getId();
                 break;
             }
         }
         tpl_assign('pending_task_id', $pending_id);
         tpl_assign('task_related', true);
     } else {
         tpl_assign('pending_task_id', 0);
         tpl_assign('task_related', false);
     }
     tpl_assign('task', $task);
     tpl_assign('task_data', $task_data);
     if (is_array(array_var($_POST, 'task'))) {
         foreach ($task_data as $k => &$v) {
             $v = remove_scripts($v);
         }
         $send_edit = false;
         if ($task->getAssignedToContactId() == array_var($task_data, 'assigned_to_contact_id')) {
             $send_edit = true;
         }
         $old_owner = $task->getAssignedTo();
         if (array_var($task_data, 'parent_id') == $task->getId()) {
             flash_error(lang("task own parent error"));
             ajx_current("empty");
             return;
         }
         try {
             try {
                 $task_data['due_date'] = getDateValue(array_var($_POST, 'task_due_date'));
                 $task_data['start_date'] = getDateValue(array_var($_POST, 'task_start_date'));
             } catch (Exception $e) {
                 throw new Exception(lang('date format error', date_format_tip(user_config_option('date_format'))));
             }
             if ($task_data['due_date'] instanceof DateTimeValue) {
                 $duetime = getTimeValue(array_var($_POST, '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($_POST, '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);
             }
             //control date subtask whit parent
             if (array_var($_POST, 'control_dates') == "child") {
                 $parent = $task->getParent();
                 if ($parent->getStartDate() instanceof DateTimeValue && $task_data['start_date'] instanceof DateTimeValue) {
                     if ($task_data['start_date']->getTimestamp() < $parent->getStartDate()->getTimestamp()) {
                         $parent->setStartDate($task_data['start_date']);
                         $parent->setUseStartTime($task_data['use_start_time']);
                     }
                 } else {
                     $parent->setStartDate($task_data['start_date']);
                     $parent->setUseStartTime(array_var($task_data, 'use_start_time', 0));
                 }
                 if ($parent->getDueDate() instanceof DateTimeValue && $task_data['due_date'] instanceof DateTimeValue) {
                     if ($task_data['due_date']->getTimestamp() > $parent->getDueDate()->getTimestamp()) {
                         $parent->setDueDate($task_data['due_date']);
                         $parent->setUseDueTime($task_data['use_due_time']);
                     }
                 } else {
                     $parent->setDueDate($task_data['due_date']);
                     $parent->setUseDueTime(array_var($task_data, 'use_due_time', 0));
                 }
                 // calculate and set estimated time
                 $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes');
                 $parent->setTimeEstimate($totalMinutes);
                 $parent->save();
             }
             $err_msg = $this->setRepeatOptions($task_data);
             if ($err_msg) {
                 throw new Exception($err_msg);
             }
             if (!isset($task_data['parent_id'])) {
                 $task_data['parent_id'] = 0;
             }
             $member_ids = json_decode(array_var($_POST, 'members'));
             // keep old dates to check for subtasks
             $old_start_date = $task->getStartDate();
             $old_due_date = $task->getDueDate();
             if (config_option("wysiwyg_tasks")) {
                 $task_data['type_content'] = "html";
                 $task_data['text'] = str_replace(array("\r", "\n", "\r\n"), array('', '', ''), array_var($task_data, 'text'));
             } else {
                 $task_data['type_content'] = "text";
             }
             $task->setFromAttributes($task_data);
             $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes');
             $task->setTimeEstimate($totalMinutes);
             if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) {
                 flash_error(lang('task child of child error'));
                 ajx_current("empty");
                 return;
             }
             if (isset($task_data['percent_completed']) && $task_data['percent_completed'] >= 0 && $task_data['percent_completed'] <= 100) {
                 $task->setPercentCompleted($task_data['percent_completed']);
             }
             DB::beginWork();
             $task->save();
             if (!isset($task_data['percent_completed'])) {
                 $task->calculatePercentComplete();
             }
             // dependencies
             if (config_option('use tasks dependencies')) {
                 $previous_tasks = array_var($task_data, 'previous');
                 if (is_array($previous_tasks)) {
                     foreach ($previous_tasks as $ptask) {
                         if ($ptask == $task->getId()) {
                             continue;
                         }
                         $dep = ProjectTaskDependencies::findById(array('previous_task_id' => $ptask, 'task_id' => $task->getId()));
                         if (!$dep instanceof ProjectTaskDependency) {
                             $dep = new ProjectTaskDependency();
                             $dep->setPreviousTaskId($ptask);
                             $dep->setTaskId($task->getId());
                             $dep->save();
                         }
                     }
                     $saved_ptasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = ' . $task->getId()));
                     foreach ($saved_ptasks as $pdep) {
                         if (!in_array($pdep->getPreviousTaskId(), $previous_tasks)) {
                             $pdep->delete();
                         }
                     }
                 } else {
                     ProjectTaskDependencies::delete('task_id = ' . $task->getId());
                 }
             }
             // Add assigned user to the subscibers list
             if ($task->getAssignedToContactId() > 0 && Contacts::instance()->findById($task->getAssignedToContactId())) {
                 if (!isset($_POST['subscribers'])) {
                     $_POST['subscribers'] = array();
                 }
                 $_POST['subscribers']['user_' . $task->getAssignedToContactId()] = '1';
             }
             $object_controller = new ObjectController();
             if ($isTemplateTask) {
                 $object_controller->add_to_members($task, $member_ids, null, false);
             } else {
                 $object_controller->add_to_members($task, $member_ids);
             }
             $is_template = $task instanceof TemplateTask;
             $object_controller->add_subscribers($task, null, !$is_template);
             $object_controller->link_to_new_object($task);
             $object_controller->add_custom_properties($task);
             if (!$task->isCompleted()) {
                 //to make sure the task it is not completed yet, and that it has subscribed people
                 $old_reminders = ObjectReminders::getByObject($task);
                 $object_controller->add_reminders($task);
                 //adding the new reminders, if any
                 $object_controller->update_reminders($task, $old_reminders);
                 //updating the old ones
                 if (logged_user() instanceof Contact && (!is_array($old_reminders) || count($old_reminders) == 0) && (user_config_option("add_task_autoreminder") && logged_user()->getId() != $task->getAssignedToContactId() || user_config_option("add_self_task_autoreminder") && logged_user()->getId() == $task->getAssignedToContactId())) {
                     //if there is no asignee, but it still has subscribers
                     $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();
                 }
             }
             if (!is_array($member_ids) || count($member_ids) == 0) {
                 $member_ids = array(0);
             }
             $members = Members::findAll(array('conditions' => "id IN (" . implode(',', $member_ids) . ")"));
             $task->apply_members_to_subtasks($members, true);
             // apply values to subtasks
             $assigned_to = $task->getAssignedToContactId();
             $subtasks = $task->getAllSubTasks();
             $milestone_id = $task->getMilestoneId();
             $apply_ms = array_var($task_data, 'apply_milestone_subtasks');
             $apply_at = array_var($task_data, 'apply_assignee_subtasks', '');
             foreach ($subtasks as $sub) {
                 $modified = false;
                 //if ($apply_at || !($sub->getAssignedToContactId() > 0)) {
                 if ($apply_at) {
                     $sub->setAssignedToContactId($assigned_to);
                     $modified = true;
                 }
                 if ($apply_ms) {
                     $sub->setMilestoneId($milestone_id);
                     $modified = true;
                 }
                 if ($modified) {
                     $sub->save();
                 }
                 //control date parent whit subtask
                 if ($_POST['control_dates'] == "father") {
                     if ($sub->getStartDate() instanceof DateTimeValue) {
                         if ($task->getStartDate() instanceof DateTimeValue) {
                             if ($task->getStartDate()->getTimestamp() > $sub->getStartDate()->getTimestamp()) {
                                 $sub->setStartDate($task->getStartDate());
                             }
                         }
                     } else {
                         if ($task->getStartDate() instanceof DateTimeValue) {
                             $sub->setStartDate($task->getStartDate());
                         }
                     }
                     $sub->setUseStartTime($task->getUseStartTime());
                     if ($sub->getDueDate() instanceof DateTimeValue) {
                         if ($task->getDueDate() instanceof DateTimeValue) {
                             if ($task->getDueDate()->getTimestamp() < $sub->getDueDate()->getTimestamp()) {
                                 $sub->setDueDate($task->getDueDate());
                             }
                         }
                     } else {
                         if ($task->getDueDate() instanceof DateTimeValue) {
                             $sub->setDueDate($task->getDueDate());
                         }
                     }
                     $sub->setUseDueTime($task->getUseDueTime());
                     $sub->save();
                 }
             }
             $task->resetIsRead();
             $log_info = '';
             if ($send_edit == true) {
                 $log_info = $task->getAssignedToContactId();
             } else {
                 if ($send_edit == false) {
                     $task->setAssignedBy(logged_user());
                     $task->save();
                 }
             }
             if (config_option('repeating_task') == 1) {
                 $opt_rep_day['saturday'] = false;
                 $opt_rep_day['sunday'] = false;
                 if (array_var($task_data, 'repeat_saturdays', false)) {
                     $opt_rep_day['saturday'] = true;
                 }
                 if (array_var($task_data, 'repeat_sundays', false)) {
                     $opt_rep_day['sunday'] = true;
                 }
                 $this->repetitive_task($task, $opt_rep_day);
             }
             if (isset($_POST['type_related'])) {
                 if ($_POST['type_related'] == "all" || $_POST['type_related'] == "news") {
                     $task_data['members'] = json_decode(array_var($_POST, 'members'));
                     unset($task_data['due_date']);
                     unset($task_data['use_due_time']);
                     unset($task_data['start_date']);
                     unset($task_data['use_start_time']);
                     $this->repetitive_tasks_related($task, "edit", $_POST['type_related'], $task_data);
                 }
             }
             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);
                 }
             }
             //for calculate member status we save de task again after the object have the members
             $task->save();
             // save subtasks added in 'subtasks' tab
             $sub_tasks_to_log = $this->saveSubtasks($task, array_var($task_data, 'subtasks'), $member_ids);
             DB::commit();
             foreach ($sub_tasks_to_log['add'] as $st_to_log) {
                 ApplicationLogs::createLog($st_to_log, ApplicationLogs::ACTION_ADD);
             }
             foreach ($sub_tasks_to_log['edit'] as $st_to_log) {
                 ApplicationLogs::createLog($st_to_log, ApplicationLogs::ACTION_EDIT);
             }
             foreach ($sub_tasks_to_log['trash'] as $st_to_log) {
                 ApplicationLogs::createLog($st_to_log, ApplicationLogs::ACTION_TRASH);
             }
             //Send Template task to view
             if ($task instanceof TemplateTask) {
                 $objectId = $task->getObjectId();
                 $id = $task->getId();
                 $objectTypeName = $task->getObjectTypeName();
                 $objectName = $task->getObjectName();
                 $manager = get_class($task->manager());
                 $milestoneId = $task instanceof TemplateTask ? $task->getMilestoneId() : '0';
                 $subTasks = $task->getSubTasks();
                 $parentId = $task->getParentId();
                 $ico = "ico-task";
                 $action = "edit";
                 $object = TemplateController::prepareObject($objectId, $id, $objectName, $objectTypeName, $manager, $action, $milestoneId, $subTasks, $parentId, $ico);
                 $template_task_data = array('object' => $object);
                 if (array_var($_REQUEST, 'additional_tt_params')) {
                     $additional_tt_params = json_decode(str_replace("'", '"', array_var($_REQUEST, 'additional_tt_params')), true);
                     foreach ($additional_tt_params as $k => $v) {
                         $template_task_data[$k] = $v;
                     }
                 }
                 if (!array_var($_REQUEST, 'modal')) {
                     evt_add("template object added", $template_task_data);
                 }
             }
             try {
                 // notify asignee
                 if (array_var($task_data, 'send_notification') && $task->getAssignedToContactId() != $task->getAssignedById()) {
                     $new_owner = $task->getAssignedTo();
                     if ($new_owner instanceof Contact) {
                         Notifier::taskAssigned($task);
                     }
                     // if
                 }
                 // if
                 if (array_var($task_data, 'send_notification')) {
                     foreach ($sub_tasks_to_log['assigned'] as $st_to_log) {
                         Notifier::taskAssigned($st_to_log);
                     }
                 }
             } catch (Exception $e) {
             }
             // try
             //notify subscribers
             $isSilent = true;
             if (array_var($task_data, 'send_notification_subscribers')) {
                 $isSilent = false;
             }
             ApplicationLogs::createLog($task, ApplicationLogs::ACTION_EDIT, false, false, true, $log_info);
             //flash_success(lang('success edit task list', $task->getObjectName()));
             if (array_var($_REQUEST, 'modal')) {
                 if (array_var($_REQUEST, 'reload')) {
                     evt_add("reload current panel");
                 } else {
                     ajx_current("empty");
                     $this->setLayout("json");
                     $this->setTemplate(get_template_path("empty"));
                     // reload task info because plugins may have updated some task info (for example: name prefix)
                     if ($is_template) {
                         $task = TemplateTasks::findById($task->getId());
                     } else {
                         $task = ProjectTasks::findById($task->getId());
                     }
                     $params = array('msg' => lang('success edit task list', $task->getObjectName()), 'task' => $task->getArrayInfo(), 'reload' => array_var($_REQUEST, 'reload'));
                     if ($task instanceof TemplateTask) {
                         //$params['msg'] = lang('success edit template', $task->getObjectName());
                         $params['object'] = $template_task_data['object'];
                     }
                     //print_modal_json_response($params, true, array_var($_REQUEST, 'use_ajx'));
                     ajx_extra_data($params);
                 }
             } else {
                 ajx_current("back");
             }
             // if has subtasks and dates were changed, ask the user if the subtasks dates should also be changed
             if ($task instanceof ProjectTask && $task->countOpenSubTasks() > 0) {
                 // check if there was any due date changes
                 $dd_advance_info = null;
                 if ($task->getDueDate() instanceof DateTimeValue && $old_due_date instanceof DateTimeValue && $old_due_date->getTimestamp() != $task->getDueDate()->getTimestamp()) {
                     $dd_to_advance_ts = $task->getDueDate()->getTimestamp() - $old_due_date->getTimestamp();
                     if ($dd_to_advance_ts != 0) {
                         $dd_advance_info = get_time_info($dd_to_advance_ts);
                     }
                 }
                 // check if there was any start date changes
                 $sd_advance_info = null;
                 if ($task->getStartDate() instanceof DateTimeValue && $old_start_date instanceof DateTimeValue && $old_start_date->getTimestamp() != $task->getStartDate()->getTimestamp()) {
                     $sd_to_advance_ts = $task->getStartDate()->getTimestamp() - $old_start_date->getTimestamp();
                     if ($sd_to_advance_ts != 0) {
                         $sd_advance_info = get_time_info($sd_to_advance_ts);
                     }
                 }
                 if ($dd_advance_info != null || $sd_advance_info != null) {
                     evt_add('ask to change subtasks dates', array('dd_diff' => $dd_advance_info, 'sd_diff' => $sd_advance_info, 'task_id' => $task->getId()));
                 }
             }
         } catch (Exception $e) {
             DB::rollback();
             if (array_var($_REQUEST, 'modal')) {
                 $this->setLayout("json");
                 $this->setTemplate(get_template_path("empty"));
                 print_modal_json_response(array('errorCode' => 1, 'errorMessage' => $e->getMessage(), 'showMessage' => 1), true, array_var($_REQUEST, 'use_ajx'));
             } else {
                 flash_error($e->getMessage());
             }
             ajx_current("empty");
         }
         // try
     }
     // if
 }
Пример #9
0
 public function actionPerform($template = null, $file = null)
 {
     $this->setTemplate($template);
     $this->setFile($file ?: static::template2file($template));
     return parent::actionPerform();
 }
Пример #10
0
<?php

/*
|------------------------------------------------------------------------------
| View composer for create product layout
|------------------------------------------------------------------------------
*/
\View::composer('template', function ($view) {
    \View::share(['Categories' => TemplateController::nav()]);
});