/** * Constructor * * @param Request $request * @return TasksController */ function __construct($request) { parent::__construct($request); $task_id = $this->request->getId('task_id'); if ($task_id) { $this->active_task = Tasks::findById($task_id); } // if if (instance_of($this->active_task, 'Task')) { $this->active_task_parent = $this->active_task->getParent(); if (instance_of($this->active_task_parent, 'ProjectObject')) { $this->active_task_parent->prepareProjectSectionBreadcrumb($this->wireframe); } // if } else { $this->active_task = new Task(); $parent_id = $this->request->getId('parent_id'); if ($parent_id) { $parent = ProjectObjects::findById($parent_id); if (instance_of($parent, 'ProjectObject')) { $this->active_task_parent = $parent; $this->active_task_parent->prepareProjectSectionBreadcrumb($this->wireframe); } // if } // if } // if if (instance_of($this->active_task_parent, 'ProjectObject')) { $this->wireframe->addBreadCrumb($this->active_task_parent->getName(), $this->active_task_parent->getViewUrl()); } else { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $this->smarty->assign(array('active_task' => $this->active_task, 'active_task_parent' => $this->active_task_parent, 'page_tab' => $this->active_task->getProjectTab())); }
/** * Show timetracking module homepage * * @param void * @return null */ function index() { if ($this->request->isApiCall()) { $this->serveData(TimeRecords::findByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 'time_records'); } else { // Content for widget popup if ($this->request->get('for_popup_dialog')) { $this->_render_popup_content(); // Classic page } else { if (instance_of($this->active_object, 'ProjectObject')) { $this->wireframe->addPageMessage(lang('Time spent on <a href=":url">:name</a> :type', array('url' => $this->active_object->getViewUrl(), 'name' => $this->active_object->getName(), 'type' => $this->active_object->getVerboseType(true))), 'info'); } // if $timetracking_data = array('record_date' => new DateValue(time() + get_user_gmt_offset($this->logged_user)), 'user_id' => $this->logged_user->getId()); $per_page = 20; $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if if (instance_of($this->active_object, 'ProjectObject')) { list($timerecords, $pagination) = TimeRecords::paginateByObject($this->active_object, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility()); } else { list($timerecords, $pagination) = TimeRecords::paginateByProject($this->active_project, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility()); } // if // Mark this objects as read if (is_foreachable($timerecords)) { foreach ($timerecords as $timerecord) { ProjectObjectViews::log($timerecord, $this->logged_user); } // foreach } // if $this->smarty->assign(array('timetracking_data' => $timetracking_data, 'timerecords' => $timerecords, 'pagination' => $pagination, 'can_add' => TimeRecord::canAdd($this->logged_user, $this->active_project))); js_assign('mass_update_url', assemble_url('project_time_mass_update', array('project_id' => $this->active_project->getId()))); } // if } // if }
function convert_object_to_page() { $process_mode = $_GET['process']; $message = ''; if (empty($process_mode)) { switch ($this->active_object->getType()) { case 'Milestone': $message = 'This action will convert the Project: "' . $this->active_object->getName() . '" to Page.'; break; case 'Ticket': $message = 'This action will convert the Ticket: "' . $this->active_object->getName() . '" to Page.'; break; } } else { $error = ''; $page_id = $this->active_object->convertToPage($this->logged_user, $error); if (!empty($page_id)) { $this->redirectToUrl(assemble_url('project_page', array('project_id' => $this->active_project->getId(), 'page_id' => $page_id))); } } $this->smarty->assign(array('message' => $message, 'redirect_url' => assemble_url('project_object_convert_to_page', array('project_id' => $this->active_object->getProjectId(), 'object_id' => $this->active_object->getId(), 'process' => '1')))); }