/**
 * 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 MilestonesController
  */
 function __construct($request)
 {
     parent::__construct($request);
     if ($this->logged_user->getProjectPermission('milestone', $this->active_project) < PROJECT_PERMISSION_ACCESS) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $milestones_url = milestones_module_url($this->active_project);
     $add_milestone_url = milestones_module_add_url($this->active_project);
     $this->wireframe->addBreadCrumb(lang('Milestones'), $milestones_url);
     if (Milestone::canAdd($this->logged_user, $this->active_project)) {
         $this->wireframe->addPageAction(lang('New Milestone'), $add_milestone_url);
     }
     // if
     //$this->wireframe->addPageAction(lang('Today'), assemble_url('project_user_today_page', array('project_id' => $this->active_project->getId(), 'user_id' => $this->logged_user->getId())));
     $milestone_id = $this->request->getId('milestone_id');
     if ($milestone_id) {
         $this->active_milestone = ProjectObjects::findById($milestone_id);
     }
     // if
     //BOF: task 03 | AD
     $order_by_val = $_GET['order_by'];
     if (!empty($order_by_val)) {
         $this->order_by = $order_by_val;
     }
     $sort_order_val = $_GET['sort_order'];
     if (!empty($sort_order_val)) {
         $this->sort_order = $sort_order_val;
     }
     //EOF: task 03 | AD
     if (instance_of($this->active_milestone, 'Milestone')) {
         if ($this->active_milestone->getCompletedOn()) {
             $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('project_milestones_archive', array('project_id' => $this->active_project->getId())));
         }
         // if
         $this->wireframe->addBreadCrumb($this->active_milestone->getName(), $this->active_milestone->getViewUrl());
     } else {
         $this->active_milestone = new Milestone();
     }
     // if
     $this->smarty->assign(array('active_milestone' => $this->active_milestone, 'milestones_url' => $milestones_url, 'add_milestone_url' => $add_milestone_url, 'page_tab' => 'milestones', 'mass_edit_milestones_url' => assemble_url('project_milestones_mass_edit', array('project_id' => $this->active_project->getId()))));
 }