/** * Browse a glossary entries using the search. * * @param int $id The glossary ID. * @param string $query The search query. * @param bool $fullsearch Whether or not full search is required. * @param string $order The way to order the results. * @param string $sort The direction of the order. * @param int $from Start returning records from here. * @param int $limit Number of records to return. * @param array $options Array of options. * @return array Containing count, entries and warnings. * @since Moodle 3.1 * @throws moodle_exception * @throws invalid_parameter_exception */ public static function get_entries_by_search($id, $query, $fullsearch, $order, $sort, $from, $limit, $options) { $params = self::validate_parameters(self::get_entries_by_search_parameters(), array('id' => $id, 'query' => $query, 'fullsearch' => $fullsearch, 'order' => core_text::strtoupper($order), 'sort' => core_text::strtoupper($sort), 'from' => $from, 'limit' => $limit, 'options' => $options)); $id = $params['id']; $query = $params['query']; $fullsearch = $params['fullsearch']; $order = $params['order']; $sort = $params['sort']; $from = $params['from']; $limit = $params['limit']; $options = $params['options']; $warnings = array(); if (!in_array($order, array('CONCEPT', 'CREATION', 'UPDATE'))) { throw new invalid_parameter_exception('invalidorder'); } else { if (!in_array($sort, array('ASC', 'DESC'))) { throw new invalid_parameter_exception('invalidsort'); } } // Get and validate the glossary. list($glossary, $context) = self::validate_glossary($id); // Fetching the entries. $entries = array(); list($records, $count) = glossary_get_entries_by_search($glossary, $context, $query, $fullsearch, $order, $sort, $from, $limit, $options); foreach ($records as $key => $record) { self::fill_entry_details($record, $context); $entries[] = $record; } return array('count' => $count, 'entries' => $entries, 'warnings' => $warnings); }
$printpivot = false; $field = $sortkey == 'CREATION' ? 'CREATION' : 'UPDATE'; list($allentries, $count) = glossary_get_entries_by_date($glossary, $context, $field, $sortorder, $offset, $pagelimit); unset($field); break; case GLOSSARY_APPROVAL_VIEW: $fullpivot = false; $printpivot = false; list($allentries, $count) = glossary_get_entries_to_approve($glossary, $context, $hook, $sortkey, $sortorder, $offset, $pagelimit); break; case GLOSSARY_STANDARD_VIEW: default: $fullpivot = false; switch ($mode) { case 'search': list($allentries, $count) = glossary_get_entries_by_search($glossary, $context, $hook, $fullsearch, $sortkey, $sortorder, $offset, $pagelimit); break; case 'term': $printpivot = false; list($allentries, $count) = glossary_get_entries_by_term($glossary, $context, $hook, $offset, $pagelimit); break; case 'entry': $printpivot = false; $entry = glossary_get_entry_by_id($hook); $canapprove = has_capability('mod/glossary:approve', $context); if ($entry && ($entry->glossaryid == $glossary->id || $entry->sourceglossaryid != $glossary->id) && (!empty($entry->approved) || $entry->userid == $USER->id || $canapprove)) { $count = 1; $allentries = array($entry); } else { $count = 0; $allentries = array();