示例#1
0
 public function executeGoto(sfWebRequest $request)
 {
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
     if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
         $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
     }
     $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     $this->menu = array();
     $tasks_ids = array();
     foreach ($q->fetchArray() as $tasks) {
         if (strlen($sn = app::getArrayName($tasks, 'TasksStatus')) > 0) {
             $sn = $sn . ': ';
         } else {
             $sn = '';
         }
         if ($request->getParameter('tasks_id') == $tasks['id']) {
             $tasks['name'] = '<b>' . $tasks['name'] . '</b>';
         }
         $this->menu[] = array('title' => $sn . $tasks['name'], 'url' => 'tasksComments/index?projects_id=' . $request->getParameter('projects_id') . '&tasks_id=' . $tasks['id']);
         $tasks_ids[] = $tasks['id'];
     }
     $current_key = array_search($request->getParameter('tasks_id'), $tasks_ids);
     $this->previous_tasks_id = false;
     $this->next_tasks_id = false;
     if (isset($tasks_ids[$current_key - 1])) {
         $this->previous_tasks_id = $tasks_ids[$current_key - 1];
     }
     if (isset($tasks_ids[$current_key + 1])) {
         $this->next_tasks_id = $tasks_ids[$current_key + 1];
     }
 }
示例#2
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tasks', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     if ($this->reports_id > 0) {
         $q = UserReports::addFiltersToQuery($q, $this->reports_id, $this->getUser()->getAttribute('id'));
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'TasksComments', 't', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'tasks', $this->getUser());
     } else {
         $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
         $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     }
     $this->pager = false;
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Tasks', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->tasks_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=userReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = 'redirect_to=tasksList';
         if ($request->hasParameter('projects_id')) {
             $this->url_params = 'projects_id=' . $request->getParameter('projects_id');
         }
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
     $this->users_schema = Users::getSchema();
 }
示例#3
0
 protected function getTasks($request, $tasks_tree)
 {
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tasks', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('gantt_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q->addWhere('t.due_date is not null and t.start_date is not null');
     $q->orderBy('p.name, t.start_date');
     return $q->fetchArray();
 }