/** * Handle on prepare project overview event * * @param NamedList $tabs * @param User $logged_user * @param Project $project * @return null */ function milestones_handle_on_project_tabs(&$tabs, &$logged_user, &$project) { if ($logged_user->getProjectPermission('milestone', $project) >= PROJECT_PERMISSION_ACCESS) { $tabs->add('milestones', array('text' => lang('Milestones'), 'url' => milestones_module_url($project))); } // if if ($logged_user->getProjectPermission('ticket', $project) >= PROJECT_PERMISSION_ACCESS) { $tabs->add('tickets', array('text' => lang('Tickets'), 'url' => tickets_module_url($project))); } // if if ($logged_user->getProjectPermission('page', $project) >= PROJECT_PERMISSION_ACCESS) { $tabs->add('pages', array('text' => lang('Pages'), 'url' => pages_module_url($project))); } // if }
/** * Constructor * * @param Request $request * @return PagesController */ function __construct($request) { parent::__construct($request); //echo $this->logged_user->getProjectPermission('page', $this->active_project); if ($this->logged_user->getProjectPermission('page', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $section_url = pages_module_url($this->active_project); $this->wireframe->addBreadCrumb(lang('Pages'), $section_url); if ($this->active_category->isLoaded()) { $this->wireframe->addBreadCrumb($this->active_category->getName(), assemble_url('project_pages', array('project_id' => $this->active_project->getId(), 'category_id' => $this->active_category->getId()))); } // if $page_id = $this->request->get('page_id'); if ($page_id) { $this->active_page = Pages::findById($page_id); } // if if (instance_of($this->active_page, 'Page')) { $parents = array(); $parent = $this->active_page->getParent(); while (instance_of($parent, 'ProjectObject')) { if (instance_of($parent, 'Page')) { if (array_key_exists($parent->getId(), $parents)) { break; // avoid dead loops } // if $parents[$parent->getId()] = $parent; $parent = $parent->getParent(); } elseif (instance_of($parent, 'Category')) { $parents[$parent->getId()] = $parent; break; } else { break; } // if } // while $parents = array_reverse($parents); foreach ($parents as $parent) { if (instance_of($parent, 'Page')) { $this->wireframe->addBreadCrumb($parent->getName(), $parent->getViewUrl()); } elseif (instance_of($parent, 'Category')) { $this->wireframe->addBreadCrumb($parent->getName(), assemble_url('project_pages', array('project_id' => $this->active_project->getId(), 'category_id' => $parent->getId()))); } // if } // foreach $this->wireframe->addBreadCrumb($this->active_page->getName(), $this->active_page->getViewUrl()); } else { $this->active_page = new Page(); } // if if (Page::canAdd($this->logged_user, $this->active_project)) { if ($this->active_page->isLoaded()) { $add_page_url = pages_module_add_page_url($this->active_project, array('parent' => $this->active_page)); } elseif ($this->active_category->isLoaded()) { $add_page_url = pages_module_add_page_url($this->active_project, array('parent' => $this->active_category)); } else { $add_page_url = pages_module_add_page_url($this->active_project); } // if $this->wireframe->addPageAction(lang('New Page'), $add_page_url); } // if $this->smarty->assign(array('active_page' => $this->active_page, 'pages_url' => $section_url, 'add_page_url' => $add_page_url, 'page_tab' => 'pages')); }