/** * Returns the results to a given keyword. To get the results is the * job of this routine and it does not even need to come from a database. * The results should be an array in the form * array ( * array($key, $name), * array($key, $name), * ... * ) * where $key is an identifier like user_id and $name is a displayed text * that should appear to represent that ID. * @param keyword: string * @param array $contextual_data an associative array with more variables * @param int $limit maximum number of results (default: all) * @param int $offset return results starting from this row (default: 0) * @return array */ public function getResults($keyword, $contextual_data = array(), $limit = PHP_INT_MAX, $offset = 0) { $search_helper = new StudipSemSearchHelper(); $search_helper->setParams(array('quick_search' => $keyword, 'qs_choose' => $contextual_data['search_sem_qs_choose'] ? $contextual_data['search_sem_qs_choose'] : 'all', 'sem' => isset($contextual_data['search_sem_sem']) ? $contextual_data['search_sem_sem'] : 'all', 'category' => $contextual_data['search_sem_category'], 'scope_choose' => $contextual_data['search_sem_scope_choose'], 'range_choose' => $contextual_data['search_sem_range_choose']), !(is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm(Config::Get()->SEM_VISIBILITY_PERM))); $search_helper->doSearch(); $result = $search_helper->getSearchResultAsArray(); if (empty($result)) { return array(); } $style = $this->styles[$this->resultstyle] ?: $this->styles['name']; $query = "SELECT s.Seminar_id, {$style}, Name\n FROM seminare AS s\n LEFT JOIN seminar_user AS su ON (su.Seminar_id = s.Seminar_id AND su.status='dozent')\n LEFT JOIN auth_user_md5 USING (user_id)\n WHERE s.Seminar_id IN (?)\n GROUP BY s.Seminar_id"; if (Config::get()->IMPORTANT_SEMNUMBER) { $query .= " ORDER BY s.VeranstaltungsNummer, s.Name"; } else { $query .= " ORDER BY s.Name"; } $statement = DBManager::get()->prepare($query); $statement->execute(array(array_slice($result, $offset, $limit) ?: '')); return $statement->fetchAll(PDO::FETCH_NUM); }
function doSearch() { $search_helper = new StudipSemSearchHelper($this->form, $this->visible_only); $this->found_rows = $search_helper->doSearch(); $this->search_result = $search_helper->getSearchResultAsSnapshot(); return $this->found_rows; }