Skip to content

Commit c257386

Browse files
Global search results linked to parent context, resolves CD-464.
1 parent 1802435 commit c257386

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

classes/search/elements.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ public function generate_additional_sql() {
142142
'select' => $select,
143143
'joins' => implode(' ', $joinsql),
144144
];
145-
146145
}
147146

148147
/**
@@ -188,6 +187,7 @@ public static function get_elements_search_areas() {
188187
$joinsql[] = " LEFT JOIN {$tablename} AS {$alias} ON {$alias}.id = co.instance AND ce.shortname='{$plugin}' ";
189188
}
190189
}
190+
191191
return [
192192
$titlesql ?? [],
193193
$contentsql ?? [],
@@ -242,7 +242,11 @@ public function get_doc_url(\core_search\document $doc) {
242242
$params = ['id' => $contextmodule->instanceid];
243243
$url = new \moodle_url('/mod/contentdesigner/view.php', $params);
244244

245-
$chapter = $DB->get_record('contentdesigner_content', ['id' => $doc->get('itemid')], 'chapter', IGNORE_MISSING);
245+
$chapter = $DB->get_record_sql('
246+
SELECT cc.chapter FROM {contentdesigner_options} co
247+
JOIN {contentdesigner_content} cc ON co.element = cc.element AND co.instance = cc.instance
248+
WHERE co.id=:id', ['id' => $doc->get('itemid')], IGNORE_MISSING);
249+
246250
if ($chapter) {
247251
$url->param('chapterid', $chapter->chapter);
248252
$url->set_anchor('chapters-list-' . $chapter->chapter);
@@ -258,6 +262,11 @@ public function get_doc_url(\core_search\document $doc) {
258262
* @return \moodle_url
259263
*/
260264
public function get_context_url(\core_search\document $doc) {
265+
266+
if ($url = $this->get_doc_url($doc)) {
267+
return $url;
268+
}
269+
261270
$contextmodule = \context::instance_by_id($doc->get('contextid'));
262271
return new \moodle_url('/mod/contentdesigner/view.php', ['id' => $contextmodule->instanceid]);
263272
}

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424

2525
defined('MOODLE_INTERNAL') || die();
26-
$plugin->version = 2025092300; // The current module version (Date: YYYYMMDDXX).
26+
$plugin->version = 2025092301; // The current module version (Date: YYYYMMDDXX).
2727
$plugin->requires = 2020061500; // Requires this Moodle version.
2828
$plugin->component = 'mod_contentdesigner'; // Full name of the plugin (used for diagnostics).
2929
$plugin->release = 'v1.6';

0 commit comments

Comments
 (0)