/** * Constructor * * @param Request $request * @return MobileAccessController extends ApplicationController */ function __construct($request) { parent::__construct($request); $this->disableCategories(); $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')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if 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 $this->project_sections = array(); $this->project_sections[] = array("name" => "overview", "full_name" => lang("Overview"), "url" => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId()))); if (module_loaded('discussions') && $this->logged_user->getProjectPermission('discussion', $this->active_project)) { $this->project_sections[] = array("name" => "discussions", "full_name" => lang("Discussions"), "url" => assemble_url('mobile_access_view_discussions', array('project_id' => $this->active_project->getId()))); } if (module_loaded('milestones') && $this->logged_user->getProjectPermission('milestone', $this->active_project)) { $this->project_sections[] = array("name" => "milestones", "full_name" => lang("Milestones"), "url" => assemble_url('mobile_access_view_milestones', array('project_id' => $this->active_project->getId()))); } if (module_loaded('files') && $this->logged_user->getProjectPermission('file', $this->active_project)) { $this->project_sections[] = array("name" => "files", "full_name" => lang("Files"), "url" => assemble_url('mobile_access_view_files', array('project_id' => $this->active_project->getId()))); } if (module_loaded('checklists') && $this->logged_user->getProjectPermission('checklist', $this->active_project)) { $this->project_sections[] = array("name" => "checklists", "full_name" => lang("Checklists"), "url" => assemble_url('mobile_access_view_checklists', array('project_id' => $this->active_project->getId()))); } if (module_loaded('pages') && $this->logged_user->getProjectPermission('page', $this->active_project)) { $this->project_sections[] = array("name" => "pages", "full_name" => lang("Pages"), "url" => assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId()))); } if (module_loaded('tickets') && $this->logged_user->getProjectPermission('ticket', $this->active_project)) { $this->project_sections[] = array("name" => "tickets", "full_name" => lang("Tickets"), "url" => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId()))); } if (module_loaded('timetracking') && $this->logged_user->getProjectPermission('timerecord', $this->active_project)) { $this->project_sections[] = array("name" => "timetracking", "full_name" => lang("Time"), "url" => assemble_url('mobile_access_view_timerecords', array('project_id' => $this->active_project->getId()))); } if (module_loaded('source') && $this->logged_user->getProjectPermission('repository', $this->active_project)) { $this->project_sections[] = array("name" => "source", "full_name" => lang("Repositories"), "url" => assemble_url('mobile_access_view_repositories', array('project_id' => $this->active_project->getId()))); } //if($this->active_project->isLoaded() && $this->enable_categories) { $this->addBreadcrumb(lang('Project'), assemble_url('mobile_access_view_project', array("project_id" => $this->active_project->getId()))); $this->smarty->assign(array("page_title" => $this->active_project->getName(), "active_project" => $this->active_project, "project_sections" => $this->project_sections, "page_breadcrumbs" => $this->breadcrumbs, "active_project_section" => 'overview', "active_category" => $this->active_category)); }
function jsonEncodeProject(Project $project) { return sprintf('{"name":"%s","label":"%s","path":"%s","type":"%s"},', $project->getName(), $project->getLabel(), $project->getPath(), $project->getType()); }
/** * 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 }