MDL-71115 search: Only replace course search when equivalent

Not all global search configurations offer the same results as the
default course search does.

The default course search will return courses that the user can see
the details of even if they can see them via a category, even if
they are not enrolled and cannot enrol themselves on it.

The equivalent global search configuration is:

* Global search is enabled
* The course indexing is enabled
* All the name and summary of all courses are included in the results

This patch will only let global search replace the default course
search when those criteria are met.

It will also display on the global search configuration page if global
search will replace the legacy course search.
This commit is contained in:
Neill Magill
2021-11-10 09:11:19 +00:00
parent d135a1200a
commit e86bc4921e
4 changed files with 138 additions and 9 deletions
+12
View File
@@ -11316,6 +11316,18 @@ class admin_setting_searchsetupinfo extends admin_setting {
$row[1] = $status;
$table->data[] = $row;
// Replace front page search.
$row = array();
$url = new moodle_url("/admin/search.php?query=searchincludeallcourses");
$row[0] = '6. ' . html_writer::tag('a', get_string('replacefrontsearch', 'admin'),
array('href' => $url));
$status = html_writer::tag('span', get_string('no'), array('class' => 'badge badge-danger'));
if (\core_search\manager::can_replace_course_search()) {
$status = html_writer::tag('span', get_string('yes'), array('class' => 'badge badge-success'));
}
$row[1] = $status;
$table->data[] = $row;
$return .= html_writer::table($table);
return highlight($query, $return);