summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6e24e52)
Searching of the glossary was returning results from all
glossaries on the site. It has now been returned to just
the glossary that you are currently viewing.
*
* @param array $terms Array of terms.
* @param bool $fullsearch Whether or not full search should be enabled.
*
* @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
*/
* @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;
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';
// 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');
$userfields = user_picture::fields('u', null, 'userdataid', 'userdata');