protected function doSearch(TBGRequest $request)
 {
     $i18n = TBGContext::getI18n();
     if ($this->searchterm) {
         preg_replace_callback(TBGTextParser::getIssueRegex(), array($this, 'extractIssues'), $this->searchterm);
         if (!count($this->foundissues)) {
             $issue = TBGIssue::getIssueFromLink($this->searchterm);
             if ($issue instanceof TBGIssue) {
                 $this->foundissues = array($issue);
                 $this->resultcount = 1;
             }
         }
     }
     if (count($this->foundissues) == 0) {
         if ($request->hasParameter('predefined_search')) {
             switch ((int) $request->getParameter('predefined_search')) {
                 case TBGContext::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES:
                     $this->filters['state'] = array('operator' => '=', 'value' => TBGIssue::STATE_OPEN);
                     $this->groupby = 'issuetype';
                     break;
                 case TBGContext::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES:
                     $this->filters['state'] = array('operator' => '=', 'value' => TBGIssue::STATE_CLOSED);
                     $this->groupby = 'issuetype';
                     break;
                 case TBGContext::PREDEFINED_SEARCH_PROJECT_MILESTONE_TODO:
                     $this->groupby = 'milestone';
                     break;
                 case TBGContext::PREDEFINED_SEARCH_PROJECT_MOST_VOTED:
                     $this->filters['state'] = array('operator' => '=', 'value' => TBGIssue::STATE_OPEN);
                     $this->groupby = 'votes';
                     $this->grouporder = 'desc';
                     break;
                 case TBGContext::PREDEFINED_SEARCH_MY_REPORTED_ISSUES:
                     $this->filters['posted_by'] = array('operator' => '=', 'value' => TBGContext::getUser()->getID());
                     $this->groupby = 'issuetype';
                     break;
                 case TBGContext::PREDEFINED_SEARCH_MY_ASSIGNED_OPEN_ISSUES:
                     $this->filters['state'] = array('operator' => '=', 'value' => TBGIssue::STATE_OPEN);
                     $this->filters['assigned_type'] = array('operator' => '=', 'value' => TBGIdentifiableClass::TYPE_USER);
                     $this->filters['assigned_to'] = array('operator' => '=', 'value' => TBGContext::getUser()->getID());
                     $this->groupby = 'issuetype';
                     break;
                 case TBGContext::PREDEFINED_SEARCH_TEAM_ASSIGNED_OPEN_ISSUES:
                     $this->filters['state'] = array('operator' => '=', 'value' => TBGIssue::STATE_OPEN);
                     $this->filters['assigned_type'] = array('operator' => '=', 'value' => TBGIdentifiableClass::TYPE_TEAM);
                     foreach (TBGContext::getUser()->getTeams() as $team_id => $team) {
                         $this->filters['assigned_to'][] = array('operator' => '=', 'value' => $team_id);
                     }
                     $this->groupby = 'issuetype';
                     break;
             }
         } elseif (in_array($this->templatename, array('results_userpain_singlepainthreshold', 'results_userpain_totalpainthreshold'))) {
             $this->searchtitle = $i18n->__('Showing "bug report" issues sorted by user pain, threshold set at %threshold%', array('%threshold%' => $this->template_parameter));
             $this->ipp = 0;
             $this->groupby = 'user_pain';
             $this->grouporder = 'desc';
             $ids = TBGIssueTypesTable::getTable()->getBugReportTypeIDs();
             $this->filters['issuetype'] = array();
             foreach ($ids as $id) {
                 $this->filters['issuetype'][] = array('operator' => '=', 'value' => $id);
             }
         } elseif ($this->templatename == 'results_votes') {
             $this->searchtitle = $i18n->__('Showing issues ordered by number of votes');
             $this->ipp = $request->getParameter('issues_per_page', 100);
             $this->groupby = 'votes';
             $this->grouporder = 'desc';
         }
         list($this->foundissues, $this->resultcount) = TBGIssue::findIssues($this->filters, $this->ipp, $this->offset, $this->groupby, $this->grouporder);
     } elseif (count($this->foundissues) == 1 && !$request->getParameter('quicksearch')) {
         $issue = array_shift($this->foundissues);
         $this->forward(TBGContext::getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())));
     } elseif ($request->hasParameter('sortby')) {
     } else {
         $this->resultcount = count($this->foundissues);
         if ($this->templatename == 'results_userpain_singlepainthreshold') {
             usort($this->foundissues, array('searchActions', 'userPainSort'));
         }
     }
     if ($request->hasParameter('predefined_search')) {
         switch ((int) $request->getParameter('predefined_search')) {
             case TBGContext::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES:
                 $this->searchtitle = TBGContext::isProjectContext() ? $i18n->__('Open issues for %project_name%', array('%project_name%' => TBGContext::getCurrentProject()->getName())) : $i18n->__('All open issues');
                 break;
             case TBGContext::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES:
                 $this->searchtitle = TBGContext::isProjectContext() ? $i18n->__('Closed issues for %project_name%', array('%project_name%' => TBGContext::getCurrentProject()->getName())) : $i18n->__('All closed issues');
                 break;
             case TBGContext::PREDEFINED_SEARCH_PROJECT_MILESTONE_TODO:
                 $this->searchtitle = $i18n->__('Milestone todo-list for %project_name%', array('%project_name%' => TBGContext::getCurrentProject()->getName()));
                 $this->templatename = 'results_todo';
                 break;
             case TBGContext::PREDEFINED_SEARCH_PROJECT_MOST_VOTED:
                 $this->searchtitle = TBGContext::isProjectContext() ? $i18n->__('Most voted issues for %project_name%', array('%project_name%' => TBGContext::getCurrentProject()->getName())) : $i18n->__('Most voted issues');
                 $this->templatename = 'results_votes';
                 break;
             case TBGContext::PREDEFINED_SEARCH_MY_ASSIGNED_OPEN_ISSUES:
                 $this->searchtitle = $i18n->__('Open issues assigned to me');
                 break;
             case TBGContext::PREDEFINED_SEARCH_TEAM_ASSIGNED_OPEN_ISSUES:
                 $this->searchtitle = $i18n->__('Open issues assigned to my teams');
                 break;
             case TBGContext::PREDEFINED_SEARCH_MY_REPORTED_ISSUES:
                 $this->searchtitle = $i18n->__('Issues reported by me');
                 break;
         }
     }
 }
Beispiel #2
0
 public function runListIssues(TBGRequest $request)
 {
     $filters = array('project_id' => array('operator' => '=', 'value' => $this->selected_project->getID()));
     $filter_state = $request->getParameter('state', 'all');
     $filter_issuetype = $request->getParameter('issuetype', 'all');
     $filter_assigned_to = $request->getParameter('assigned_to', 'all');
     if (mb_strtolower($filter_state) != 'all') {
         $filters['state'] = array('operator' => '=', 'value' => '');
         if (mb_strtolower($filter_state) == 'open') {
             $filters['state']['value'] = TBGIssue::STATE_OPEN;
         } elseif (mb_strtolower($filter_state) == 'closed') {
             $filters['state']['value'] = TBGIssue::STATE_CLOSED;
         }
     }
     if (mb_strtolower($filter_issuetype) != 'all') {
         $issuetype = TBGIssuetype::getIssuetypeByKeyish($filter_issuetype);
         if ($issuetype instanceof TBGIssuetype) {
             $filters['issuetype'] = array('operator' => '=', 'value' => $issuetype->getID());
         }
     }
     if (mb_strtolower($filter_assigned_to) != 'all') {
         $user_id = 0;
         switch (mb_strtolower($filter_assigned_to)) {
             case 'me':
                 $user_id = TBGContext::getUser()->getID();
                 break;
             case 'none':
                 $user_id = 0;
                 break;
             default:
                 try {
                     $user = TBGUser::findUser(mb_strtolower($filter_assigned_to));
                     if ($user instanceof TBGUser) {
                         $user_id = $user->getID();
                     }
                 } catch (Exception $e) {
                 }
                 break;
         }
         $filters['assignee_user'] = array('operator' => '=', 'value' => $user_id);
     }
     list($this->issues, $this->count) = TBGIssue::findIssues($filters, 0);
     $this->return_issues = array();
 }
 protected function _performSearch()
 {
     list($this->_issues, $this->_total_number_of_issues) = TBGIssue::findIssues($this->getFilters(), $this->getIssuesPerPage(), $this->getOffset(), $this->getGroupby(), $this->getGrouporder(), $this->getSortFields());
 }