Skip to content

Commit cf2d03d

Browse files
committed
fix: Link to correct pages from tag searches
Without this, the links generated in tag searches for collections and items link to the wrong place - generally resulting in an exception.
1 parent 6593186 commit cf2d03d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

locallib.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
* logic, should go here. Never include this file from your lib.php!
2222
*
2323
* @package mod_mediagallery
24-
* @copyright NetSpot Pty Ltd
25-
* @author Adam Olley <adam.olley@netspot.com.au>
24+
* @copyright Copyright (c) 2021 Open LMS.
25+
* @author Adam Olley <adam.olley@openlms.net>
2626
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2727
*/
2828

@@ -470,7 +470,7 @@ function mod_mediagallery_get_tagged_collections($tag, $exclusivemode = false, $
470470
context_helper::preload_from_record($item);
471471
$modinfo = get_fast_modinfo($item->courseid);
472472
$cm = $modinfo->get_cm($item->cmid);
473-
$pageurl = new moodle_url('/mod/mediagallery/view.php', array('g' => $item->id));
473+
$pageurl = new moodle_url('/mod/mediagallery/view.php', array('m' => $item->id));
474474
$pagename = format_string($item->name, true, array('context' => context_module::instance($item->cmid)));
475475
$pagename = html_writer::link($pageurl, $pagename);
476476
$courseurl = course_get_url($item->courseid, $cm->sectionnum);
@@ -621,7 +621,7 @@ function mod_mediagallery_get_tagged_items($tag, $exclusivemode = false, $fromct
621621

622622
// Build the SQL query.
623623
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
624-
$query = "SELECT mg.*, mi.id, mi.caption,
624+
$query = "SELECT mg.*, mg.id as galleryid, mi.id, mi.caption,
625625
cm.id AS cmid, c.id AS courseid, c.shortname, c.fullname, $ctxselect
626626
FROM {mediagallery_item} mi
627627
JOIN {mediagallery_gallery} mg ON mg.id = mi.galleryid
@@ -691,7 +691,7 @@ function mod_mediagallery_get_tagged_items($tag, $exclusivemode = false, $fromct
691691
context_helper::preload_from_record($item);
692692
$modinfo = get_fast_modinfo($item->courseid);
693693
$cm = $modinfo->get_cm($item->cmid);
694-
$pageurl = new moodle_url('/mod/mediagallery/view.php', array('g' => $item->id));
694+
$pageurl = new moodle_url('/mod/mediagallery/view.php', array('g' => $item->galleryid));
695695
$pagename = format_string($item->caption, true, array('context' => context_module::instance($item->cmid)));
696696
$pagename = html_writer::link($pageurl, $pagename);
697697
$courseurl = course_get_url($item->courseid, $cm->sectionnum);

0 commit comments

Comments
 (0)