Skip to content

Commit

Permalink
add get_coursemodule_from_id/instance functions for compatability wit…
Browse files Browse the repository at this point in the history
…h Moodles <1.7
  • Loading branch information
gbateson committed Sep 14, 2006
1 parent 2a532aa commit 29f4a60
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion mod/hotpot/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2195,6 +2195,46 @@ function set_user_preference($name, $value, $otheruser=NULL) {
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

Expand Down

0 comments on commit 29f4a60

Please sign in to comment.