From: Eloy Lafuente (stronk7) Date: Mon, 7 Nov 2011 18:52:34 +0000 (+0100) Subject: MDL-20534 lti: B3, A6, apply new external icons support to lti (MDL-30175) X-Git-Tag: v2.2.0-beta~12^2~17 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=6c64e8ac17e8d3c2ddecf94a045c0ee202388e6c MDL-20534 lti: B3, A6, apply new external icons support to lti (MDL-30175) --- diff --git a/mod/lti/lib.php b/mod/lti/lib.php index ced97156b55..7989313f246 100644 --- a/mod/lti/lib.php +++ b/mod/lti/lib.php @@ -163,21 +163,31 @@ function lti_delete_instance($id) { return $DB->delete_records("lti", array("id" => $basiclti->id)); } +/** + * Given a coursemodule object, this function returns the extra + * information needed to print this activity in various places. + * For this module we just need to support external urls as + * activity icons + * + * @param cm_info $coursemodule + * @return cached_cm_info info + */ function lti_get_coursemodule_info($coursemodule) { global $DB; - $lti = $DB->get_record('lti', array('id' => $coursemodule->instance), 'icon, secureicon'); + if (!$lti = $DB->get_record('lti', array('id' => $coursemodule->instance), + 'icon, secureicon')) { + return null; + } - $info = new stdClass(); + $info = new cached_cm_info(); - //We want to use the right icon based on whether the current page is being requested over http or https. - //There's a potential problem here as the icon URLs are cached in the modinfo field and won't be updated for each request. + // We want to use the right icon based on whether the + // current page is being requested over http or https. if (lti_request_is_using_ssl() && !empty($lti->secureicon)) { - $info->icon = $lti->secureicon; - } else { - if (!empty($lti->icon)) { - $info->icon = $lti->icon; - } + $info->iconurl = new moodle_url($lti->secureicon); + } else if (!empty($lti->icon)) { + $info->iconurl = new moodle_url($lti->icon); } return $info;