Beispiel #1
0
 function _process_search($search)
 {
     $bugs = new Bug();
     $bugs->distinct();
     $args = $search['args'];
     // Put related first, to force prepending of table name
     foreach (array('status', 'category', 'user') as $rel) {
         if (isset($args[$rel])) {
             $v = array_unique(array_map('intval', $args[$rel]));
             $bugs->where_in_related($rel, 'id', $v);
         }
     }
     if (isset($args['text'])) {
         $kws = explode(' ', $args['text']);
         if (!empty($kws)) {
             $bugs->group_start();
             foreach ($kws as $kw) {
                 if ($kw !== '') {
                     // case insensitive search
                     $kw = strtoupper($kw);
                     $bugs->or_ilike('title', $kw);
                     $bugs->or_ilike('description', $kw);
                 }
             }
             $bugs->group_end();
         }
     }
     if (isset($args['priority'])) {
         $v = array_unique(array_map('intval', $args['priority']));
         $bugs->where_in('priority', $v);
     }
     $limit = 15;
     $page = $limit * $search['page'];
     // add in extras
     $bugs->include_related('status', 'name', TRUE, TRUE);
     $bugs->order_by('updated', 'DESC');
     return $bugs->get_paged_iterated($search['page'], $limit);
 }