/**
  * 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
 }