/** * enable Categories * */ function enableCategories() { $this->enable_categories = false; if ($this->active_project->isLoaded()) { $this->enable_categories = true; $category_id = $this->request->get('category_id'); if ($category_id) { $this->active_category = Categories::findById($category_id); } // if if (instance_of($this->active_category, 'Category')) { if ($this->active_category->getProjectId() != $this->active_project->getId()) { $this->active_category = new Category(); // this category is not part of selected project } // if } else { $this->active_category = new Category(); // invalid category instance } // if } else { $this->active_category = new Category(); // categories disabled or category not selected } // if $this->smarty->assign(array("enable_categories" => $this->enable_categories, "active_category" => $this->active_category)); }
public function getStartEndDate($_project_id = '', $_task_id = '') { if (!empty($this->_data['project_id'])) { $_project_id = $this->_data['project_id']; } if (!empty($this->_data['task_id'])) { $_task_id = $this->_data['task_id']; } $obj = ''; if (!empty($_task_id)) { $obj = new Task(); $obj->load($_task_id); } elseif (!empty($_project_id)) { $obj = new Project(); $obj->load($_project_id); } if ($obj instanceof DataObject && $obj->isLoaded()) { $start_date = un_fix_date($obj->start_date); $end_date = un_fix_date($obj->end_date); } else { $start_date = $end_date = date(DATE_FORMAT); } $output['start_date'] = array('data' => $start_date, 'is_array' => is_array($start_date)); $output['end_date'] = array('data' => $end_date, 'is_array' => is_array($end_date)); if (isset($this->_data['ajax'])) { $this->view->set('data', $output); $this->setTemplateName('ajax_multiple'); } else { return $output; } }
/** * Construct project controller * * @param Request $request * @return ProjectController */ function __construct($request) { parent::__construct($request); $this->wireframe->page_actions = array(); // Reset page actions $project_id = $this->request->get('project_id'); if ($project_id) { $this->active_project = Projects::findById($project_id); } // if if (instance_of($this->active_project, 'Project')) { if (!$this->logged_user->isProjectMember($this->active_project)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->active_project->getType() == PROJECT_TYPE_SYSTEM) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if ($this->active_project->isCompleted()) { $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('projects_archive')); } // if $this->wireframe->addBreadCrumb($this->active_project->getName(), $this->active_project->getOverviewUrl()); $tabs = new NamedList(); $tabs->add('overview', array('text' => str_excerpt($this->active_project->getName(), 25), 'url' => $this->active_project->getOverviewUrl())); event_trigger('on_project_tabs', array(&$tabs, &$this->logged_user, &$this->active_project)); $tabs->add('people', array('text' => lang('People'), 'url' => $this->active_project->getPeopleUrl())); $tabs->add('recent_pages', array('text' => lang('Recent Pages'), 'url' => assemble_url('recent_pages') . '&project_id=' . $this->active_project->getId())); /*$tabs->add('recent_pages_1', array( 'text' => lang('Recent Pages'), 'url' => assemble_url('project_recent_pages_1'), ));*/ //BOF:mod /*$tabs->add('attachments', array( 'text' => lang('Attachments'), 'url' => assemble_url('attachments_list', array('project_id' => $this->active_project->getId())) , ));*/ //EOF:mod $tabs->add('reminders', array('text' => lang('Notifications'), 'url' => assemble_url('reminders_list', array('project_id' => $this->active_project->getId())))); $tabs->add('calendar', array('text' => lang('Calendar'), 'url' => Calendar::getProjectCalendarUrl($this->active_project))); js_assign('image_picker_url', assemble_url('image_picker', array('project_id' => $this->active_project->getId()))); js_assign('active_project_id', $this->active_project->getId()); $this->smarty->assign('page_tabs', $tabs); // --------------------------------------------------- // Set page company and page project // --------------------------------------------------- $page_company = $this->active_project->getCompany(); if (instance_of($page_company, 'Company')) { $this->wireframe->page_company = $page_company; } // if $this->wireframe->page_project = $this->active_project; // New project } else { if ($this->controller_name == 'project') { $this->active_project = new Project(); } else { $this->httpError(HTTP_ERR_NOT_FOUND); } // if } // if $this->smarty->assign(array('active_project' => $this->active_project, 'page_tab' => 'overview')); // ----------------------------------------------------------------------- // Do category related voodoo if categories are enabled. Categories are // not initialized if we don't have a loaded project (no project ID) // ----------------------------------------------------------------------- if ($this->active_project->isLoaded() && $this->enable_categories) { $category_id = $this->request->get('category_id'); if ($category_id) { $this->active_category = Categories::findById($category_id); } // if if (instance_of($this->active_category, 'Category')) { if ($this->active_category->getProjectId() != $this->active_project->getId()) { $this->active_category = new Category(); // this category is not part of selected project } // if } else { $this->active_category = new Category(); } // if $this->smarty->assign(array('active_category' => $this->active_category, 'categories_url' => Category::getSectionUrl($this->active_project, $this->getControllerName(), $this->active_module), 'add_category_url' => Category::getAddUrl($this->active_project, $this->getControllerName(), $this->active_module))); } // if }
public function getStartEndDate($_project_id = '', $_task_id = '') { if (!empty($this->_data['project_id'])) { $_project_id = $this->_data['project_id']; } if (!empty($this->_data['task_id'])) { $_task_id = $this->_data['task_id']; } $obj = ''; if (!empty($_task_id)) { $obj = new Task(); $obj->load($_task_id); } elseif (!empty($_project_id)) { $obj = new Project(); $obj->load($_project_id); } if ($obj instanceof DataObject && $obj->isLoaded()) { $start_date = un_fix_date($obj->start_date, true); $end_date = un_fix_date($obj->end_date, true); } else { $start_date = $end_date = date(DATE_FORMAT) . ' 00:00'; } $dates = array('start_date' => $start_date, 'end_date' => $end_date); $start_date_hours = array_shift(explode(':', array_pop(explode(' ', $start_date)))); $start_date_minutes = array_pop(explode(':', array_pop(explode(' ', $start_date)))); $start_date = array_shift(explode(' ', $start_date)); $end_date_hours = array_shift(explode(':', array_pop(explode(' ', $end_date)))); $end_date_minutes = array_pop(explode(':', array_pop(explode(' ', $end_date)))); $end_date = array_shift(explode(' ', $end_date)); $output['start_date'] = array('data' => $start_date, 'is_array' => is_array($start_date)); $output['start_date_hours'] = array('data' => $start_date_hours, 'is_array' => is_array($start_date_hours)); $output['start_date_minutes'] = array('data' => $start_date_minutes, 'is_array' => is_array($start_date_minutes)); $output['end_date'] = array('data' => $end_date, 'is_array' => is_array($end_date)); $output['end_date_hours'] = array('data' => $end_date_hours, 'is_array' => is_array($end_date_hours)); $output['end_date_minutes'] = array('data' => $end_date_minutes, 'is_array' => is_array($end_date_minutes)); if (isset($this->_data['ajax'])) { $this->view->set('data', $output); $this->setTemplateName('ajax_multiple'); } else { return $dates; } }