From 1b81b0a4125850ca13ad22b8268c5b7e82402671 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 3 Jun 2008 23:44:16 +0000 Subject: [PATCH] MDL-15111 label mod converted --- mod/label/backuplib.php | 13 +++++++------ mod/label/db/upgrade.php | 1 - mod/label/lib.php | 4 +++- mod/label/view.php | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/mod/label/backuplib.php b/mod/label/backuplib.php index 5918b7ea40..6b075572bd 100644 --- a/mod/label/backuplib.php +++ b/mod/label/backuplib.php @@ -18,12 +18,12 @@ //This function executes all the backup procedure about this mod function label_backup_mods($bf,$preferences) { - global $CFG; + global $CFG, $DB; $status = true; ////Iterate over label table - if ($labels = get_records ("label","course", $preferences->backup_course,"id")) { + if ($labels = $DB->get_records ("label","course", array($preferences->backup_course=>"id"))) { foreach ($labels as $label) { if (backup_mod_selected($preferences,'label',$label->id)) { $status = label_backup_one_mod($bf,$preferences,$label); @@ -34,11 +34,10 @@ } function label_backup_one_mod($bf,$preferences,$label) { - - global $CFG; + global $CFG, $DB; if (is_numeric($label)) { - $label = get_record('label','id',$label); + $label = $DB->get_record('label', array('id'=>$label)); } $status = true; @@ -59,6 +58,8 @@ ////Return an array of info (name,value) function label_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) { + global $DB; + if (!empty($instances) && is_array($instances) && count($instances)) { $info = array(); foreach ($instances as $id => $instance) { @@ -69,7 +70,7 @@ //First the course data $info[0][0] = get_string("modulenameplural","label"); - $info[0][1] = count_records("label", "course", "$course"); + $info[0][1] = $DB->count_records("label", array("course"=>$course)); return $info; } diff --git a/mod/label/db/upgrade.php b/mod/label/db/upgrade.php index c1046254e7..4b7e6b5300 100644 --- a/mod/label/db/upgrade.php +++ b/mod/label/db/upgrade.php @@ -18,7 +18,6 @@ // using the functions defined in lib/ddllib.php function xmldb_label_upgrade($oldversion=0) { - global $CFG, $THEME, $DB; $result = true; diff --git a/mod/label/lib.php b/mod/label/lib.php index 9a7d6959c1..9d36666f6f 100644 --- a/mod/label/lib.php +++ b/mod/label/lib.php @@ -74,7 +74,9 @@ function label_get_participants($labelid) { * See get_array_of_activities() in course/lib.php */ function label_get_coursemodule_info($coursemodule) { - if ($label = get_record('label', 'id', $coursemodule->instance, '', '', '', '', 'id, content, name')) { + global $DB; + + if ($label = $DB->get_record('label', array('id'=>$coursemodule->instance), 'id, content, name')) { $info = new object(); $info->extra = urlencode($label->content); $info->name = urlencode($label->name); diff --git a/mod/label/view.php b/mod/label/view.php index f450a55dd3..51261cfc43 100644 --- a/mod/label/view.php +++ b/mod/label/view.php @@ -10,19 +10,19 @@ print_error("Course Module ID was incorrect"); } - if (! $course = get_record("course", "id", $cm->course)) { + if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { print_error("Course is misconfigured"); } - if (! $label = get_record("label", "id", $cm->instance)) { + if (! $label = $DB->get_record("label", array("id"=>$cm->instance))) { print_error("Course module is incorrect"); } } else { - if (! $label = get_record("label", "id", $l)) { + if (! $label = $DB->get_record("label", array("id"=>$l))) { print_error("Course module is incorrect"); } - if (! $course = get_record("course", "id", $label->course)) { + if (! $course = $DB->get_record("course", array("id"=>$label->course)) ){ print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id)) { -- 2.39.5