Esempio n. 1
0
 public function buildProjectsMenu()
 {
     $s = array();
     $reports = Doctrine_Core::getTable('ProjectsReports')->createQuery()->addWhere('(users_id="' . $this->sf_user->getAttribute('id') . '")')->addWhere('display_in_menu=1')->orderBy('sort_order, name')->execute();
     $is_hr = false;
     foreach ($reports as $r) {
         $is_hr = true;
         $q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users');
         $q = ProjectsReports::addFiltersToQuery($q, $r->getId(), $this->sf_user);
         if (Users::hasAccess('view_own', 'projects', $this->sf_user)) {
             $q->addWhere("find_in_set('" . $this->sf_user->getAttribute('id') . "',p.team) or p.created_by='" . $this->sf_user->getAttribute('id') . "'");
         }
         $pm = array();
         foreach ($q->fetchArray() as $p) {
             $pm[] = array('title' => $p['name'], 'url' => 'projects/open?projects_id=' . $p['id']);
         }
         $s[] = array('title' => $r->getName(), 'url' => 'projectsReports/view?id=' . $r->getId(), 'submenu' => $pm);
     }
     if ($this->access['projects']['insert']) {
         $s[] = array('title' => __('Add Project'), 'url' => 'projects/new', 'modalbox' => true, 'is_hr' => $is_hr);
         $is_hr = false;
     }
     $s[] = array('title' => __('View All'), 'url' => 'projects/index', 'is_hr' => $is_hr);
     return array('title' => __('Projects'), 'url' => 'projects/index', 'submenu' => $s);
 }
Esempio n. 2
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users');
     if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
         $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',p.team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
     }
     if ($this->reports_id > 0) {
         $q = ProjectsReports::addFiltersToQuery($q, $this->reports_id, $this->getUser());
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'ProjectsComments', 'p', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'projects', $this->getUser());
     } else {
         $q = Projects::addFiltersToQuery($q, $this->getUser()->getAttribute('projects_filter'));
         $q = app::addListingOrder($q, 'projects', $this->getUser());
     }
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Projects', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->projects_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=projectsReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = '';
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
 }