*
* @param array $terms Array of terms.
* @param bool $fullsearch Whether or not full search should be enabled.
+ * @param int $glossaryid The ID of a glossary to reduce the search results.
* @return array The first element being the where clause, the second array of parameters.
* @since Moodle 3.1
*/
-function glossary_get_search_terms_sql(array $terms, $fullsearch = true) {
+function glossary_get_search_terms_sql(array $terms, $fullsearch = true, $glossaryid = null) {
global $DB;
static $i = 0;
}
}
+ // Reduce the search results by restricting it to one glossary.
+ if (isset($glossaryid)) {
+ $conditions[] = 'AND ge.glossaryid = :glossaryid';
+ $params['glossaryid'] = $glossaryid;
+ }
+
// When there are no conditions we add a negative one to ensure that we don't return anything.
if (empty($conditions)) {
$conditions[] = '1 = 2';
}
}
- list($searchcond, $params) = glossary_get_search_terms_sql($terms, $fullsearch);
+ list($searchcond, $params) = glossary_get_search_terms_sql($terms, $fullsearch, $glossary->id);
$userfields = user_picture::fields('u', null, 'userdataid', 'userdata');