From: gbateson Date: Thu, 14 Sep 2006 07:29:22 +0000 (+0000) Subject: add get_coursemodule_from_id/instance functions for compatability with Moodles <1.7 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=29f4a60ffe599c56b1fdf9d5a5a0d3647c7e07e4;p=moodle.git add get_coursemodule_from_id/instance functions for compatability with Moodles <1.7 --- diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index e7c0eb838e..d37d875fb4 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -2134,7 +2134,7 @@ function hotpot_string_id($str) { if (isset($str) && $str<>'') { // get the id from the table if it is already there - $md5key = md5($str); + $md5key = md5($str); if (!$id = get_field('hotpot_strings', 'id', 'md5key', $md5key, 'string', $str)) { // create a string record @@ -2195,6 +2195,46 @@ if (!function_exists('set_user_preference')) { return false; } } +if (!function_exists('get_coursemodule_from_id')) { + // add this function for Moodle < 1.5.4 + function get_coursemodule_from_id($modulename, $cmid, $courseid=0) { + global $CFG; + return get_record_sql(" + SELECT + cm.*, m.name, md.name as modname + FROM + {$CFG->prefix}course_modules cm, + {$CFG->prefix}modules md, + {$CFG->prefix}$modulename m + WHERE + ".($courseid ? "cm.course = '$courseid' AND " : '')." + cm.id = '$cmid' AND + cm.instance = m.id AND + md.name = '$modulename' AND + md.id = cm.module + "); + } +} +if (!function_exists('get_coursemodule_from_instance')) { + // add this function for Moodle < 1.5.4 + function get_coursemodule_from_instance($modulename, $instance, $courseid=0) { + global $CFG; + return get_record_sql(" + SELECT + cm.*, m.name, md.name as modname + FROM + {$CFG->prefix}course_modules cm, + {$CFG->prefix}modules md, + {$CFG->prefix}$modulename m + WHERE + ".($courseid ? "cm.course = '$courseid' AND" : '')." + cm.instance = m.id AND + md.name = '$modulename' AND + md.id = cm.module AND + m.id = '$instance' + "); + } +} function hotpot_utf8_to_html_entity($char) { // http://www.zend.com/codex.php?id=835&single=1