/** * Browse a glossary entries by letter. * * @param int $id The glossary ID. * @param string $letter A letter, or a special keyword. * @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_letter($id, $letter, $from, $limit, $options) { $params = self::validate_parameters(self::get_entries_by_letter_parameters(), array('id' => $id, 'letter' => $letter, 'from' => $from, 'limit' => $limit, 'options' => $options)); $id = $params['id']; $letter = $params['letter']; $from = $params['from']; $limit = $params['limit']; $options = $params['options']; $warnings = array(); // Get and validate the glossary. list($glossary, $context) = self::validate_glossary($id); // Validate the mode. $modes = self::get_browse_modes_from_display_format($glossary->displayformat); if (!in_array('letter', $modes)) { throw new invalid_parameter_exception('invalidbrowsemode'); } $entries = array(); list($records, $count) = glossary_get_entries_by_letter($glossary, $context, $letter, $from, $limit, $options); foreach ($records as $key => $record) { self::fill_entry_details($record, $context); $entries[] = $record; } return array('count' => $count, 'entries' => $entries, 'warnings' => $warnings); }
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(); } unset($entry, $canapprove); break; case 'letter': default: list($allentries, $count) = glossary_get_entries_by_letter($glossary, $context, $hook, $offset, $pagelimit); break; } break; }