mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-73651 calendar: search in localised module type names as well
This commit is contained in:
parent
c352b70022
commit
a159527748
1 changed files with 14 additions and 1 deletions
|
@ -410,7 +410,7 @@ class event_vault implements event_vault_interface {
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
protected function generate_search_subquery(?string $searchvalue): ?array {
|
protected function generate_search_subquery(?string $searchvalue): ?array {
|
||||||
global $DB;
|
global $CFG, $DB;
|
||||||
if (!$searchvalue) {
|
if (!$searchvalue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -427,6 +427,19 @@ class event_vault implements event_vault_interface {
|
||||||
$whereconditions[] = $DB->sql_like('e.modulename', ':modulename', false);
|
$whereconditions[] = $DB->sql_like('e.modulename', ':modulename', false);
|
||||||
$params['modulename'] = '%' . $DB->sql_like_escape($searchvalue) . '%';
|
$params['modulename'] = '%' . $DB->sql_like_escape($searchvalue) . '%';
|
||||||
|
|
||||||
|
// Activity type searching (localised type name).
|
||||||
|
require_once($CFG->dirroot . '/course/lib.php');
|
||||||
|
// Search in modules' singular and plural names.
|
||||||
|
$modules = array_keys(array_merge(
|
||||||
|
preg_grep('/' . $searchvalue . '/i', get_module_types_names()) ?: [],
|
||||||
|
preg_grep('/' . $searchvalue . '/i', get_module_types_names(true)) ?: [],
|
||||||
|
));
|
||||||
|
if ($modules) {
|
||||||
|
[$insql, $inparams] = $DB->get_in_or_equal($modules, SQL_PARAMS_NAMED, 'exactmodulename');
|
||||||
|
$whereconditions[] = 'e.modulename ' . $insql;
|
||||||
|
$params += $inparams;
|
||||||
|
}
|
||||||
|
|
||||||
$whereclause = '(' . implode(' OR ', $whereconditions) . ')';
|
$whereclause = '(' . implode(' OR ', $whereconditions) . ')';
|
||||||
|
|
||||||
return ['where' => $whereclause, 'params' => $params];
|
return ['where' => $whereclause, 'params' => $params];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue