/**
  * Constructor
  *
  * @param Request $request
  * @return ProjectCalendarController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->wireframe->addBreadCrumb(lang('Calendar'), Calendar::getProjectCalendarUrl($this->active_project));
 }
 /**
  * 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
 }
 function reminders_list()
 {
     $project_id = $_GET['project_id'];
     $flag = $_GET['flag'];
     $active_project = Projects::findById($project_id);
     $tabs = new NamedList();
     $tabs->add('overview', array('text' => str_excerpt($active_project->getName(), 25), 'url' => $active_project->getOverviewUrl()));
     event_trigger('on_project_tabs', array(&$tabs, &$this->logged_user, &$active_project));
     $tabs->add('people', array('text' => lang('People'), 'url' => $active_project->getPeopleUrl()));
     $tabs->add('recent_pages', array('text' => lang('Recent Pages'), 'url' => assemble_url('recent_pages') . '&project_id=' . $active_project->getId()));
     /*$tabs->add('attachments', array(
         'text' => lang('Attachments'),
         'url' => assemble_url('attachments_list', array('project_id' => $active_project->getId())) ,
       ));*/
     $tabs->add('reminders', array('text' => lang('Notifications'), 'url' => assemble_url('reminders_list', array('project_id' => $active_project->getId()))));
     $tabs->add('calendar', array('text' => lang('Calendar'), 'url' => Calendar::getProjectCalendarUrl($active_project)));
     js_assign('active_project_id', $active_project->getId());
     $this->smarty->assign('page_tabs', $tabs);
     $reminders = array();
     $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
     mysql_select_db(DB_NAME);
     if ($flag) {
         $query = "select a.user_id, a.object_id, a.comment, a.created_by_id, a.created_on from healingcrystals_reminders a inner join healingcrystals_project_objects b on a.object_id=b.id where b.project_id='" . $active_project->getId() . "' and a.user_id='" . $this->logged_user->getId() . "' order by a.created_on desc";
     } else {
         $query = "select a.user_id, a.object_id, a.comment, a.created_by_id, a.created_on from healingcrystals_reminders a inner join healingcrystals_project_objects b on a.object_id=b.id where b.project_id='" . $active_project->getId() . "' and (a.created_by_id='" . $this->logged_user->getId() . "' or a.user_id='" . $this->logged_user->getId() . "') order by a.created_on desc";
     }
     $result = mysql_query($query, $link);
     while ($entry = mysql_fetch_assoc($result)) {
         $object_ref = new ProjectObject($entry['object_id']);
         $cur_type = $object_ref->getType();
         $type_ref = new $cur_type($entry['object_id']);
         $reminders[] = array('sent_to' => new User($entry['user_id']), 'object' => $type_ref, 'comment' => $entry['comment'], 'sent_by' => new User($entry['created_by_id']), 'sent_on' => date('d-M-Y H:i', strtotime($entry['created_on'])));
     }
     mysql_close($link);
     $this->smarty->assign('reminders', $reminders);
     $this->smarty->assign('page_tab', 'reminders');
     $this->smarty->assign('flag', $flag);
 }