From 3de55d24583c5fb03cb0d4a109a29be4fc4691cd Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Thu, 25 Jul 2013 13:16:41 +0100 Subject: [PATCH] MDL-40867 External tools should launch pop-ups from the course page Without this fix, if an LTI tool is set to open in a pop-up, then clicking the link on the course page opens another almost blank page, which then tries to open the pop-up, which is almost invariably caught by your pop-up blocker. With this fix, clicking the link on the course page opens the pop-up directly, like for pop-up resources. --- mod/lti/lib.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mod/lti/lib.php b/mod/lti/lib.php index fa74bbcd426..0ee7c7d1fc2 100644 --- a/mod/lti/lib.php +++ b/mod/lti/lib.php @@ -169,7 +169,7 @@ function lti_delete_instance($id) { * For this module we just need to support external urls as * activity icons * - * @param cm_info $coursemodule + * @param stdClass $coursemodule * @return cached_cm_info info */ function lti_get_coursemodule_info($coursemodule) { @@ -177,7 +177,7 @@ function lti_get_coursemodule_info($coursemodule) { require_once($CFG->dirroot.'/mod/lti/locallib.php'); if (!$lti = $DB->get_record('lti', array('id' => $coursemodule->instance), - 'icon, secureicon, intro, introformat, name')) { + 'icon, secureicon, intro, introformat, name, toolurl, launchcontainer')) { return null; } @@ -196,6 +196,19 @@ function lti_get_coursemodule_info($coursemodule) { $info->content = format_module_intro('lti', $lti, $coursemodule->id, false); } + // Does the link open in a new window? + $tool = lti_get_tool_by_url_match($lti->toolurl); + if ($tool) { + $toolconfig = lti_get_type_config($tool->id); + } else { + $toolconfig = array(); + } + $launchcontainer = lti_get_launch_container($lti, $toolconfig); + if ($launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW) { + $launchurl = new moodle_url('/mod/lti/launch.php', array('id' => $coursemodule->id)); + $info->onclick = "window.open('" . $launchurl->out(false) . "', 'lti'); return false;"; + } + $info->name = $lti->name; return $info;