コード例 #1
0
ファイル: TicketListing.php プロジェクト: nirix/traq
 /**
  * Set ticket filters.
  */
 public function setFiltersAction()
 {
     $queryString = [];
     $filters = Request::$post->get('filters', [], false);
     // Add filter
     if ($newFilter = Request::$post->get('new_filter') and $newFilter !== '') {
         if (!isset($filters[$newFilter])) {
             $filters[$newFilter] = ['prefix' => '', 'values' => []];
         } else {
             $filters[$newFilter]['values'][] = '';
         }
     }
     foreach ($filters as $name => $filter) {
         $filter['prefix'] = $filter['prefix'] == '-' ? '!' : '';
         // Is this a filter?
         if (!in_array($name, array_keys(TicketFilters::filtersFor($this->currentProject)))) {
             continue;
         }
         if (!isset($filter['values'])) {
             $filter['values'] = [];
         }
         if ($field = CustomField::find('slug', $name)) {
             $queryString[$name] = $filter['prefix'] . implode(',', $filter['values']);
         } else {
             $queryString[$name] = $filter['prefix'] . implode(',', $filter['values']);
         }
     }
     return $this->redirect($this->generateUrl('tickets', ['pslug' => $this->currentProject['slug']]) . '?' . Request::buildQueryString($queryString, false));
 }