MDL-15111 label mod converted

This commit is contained in:
skodak 2008-06-03 23:44:16 +00:00
parent cd655b33f9
commit 1b81b0a412
4 changed files with 14 additions and 12 deletions

View File

@ -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;
}

View File

@ -18,7 +18,6 @@
// using the functions defined in lib/ddllib.php
function xmldb_label_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
$result = true;

View File

@ -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);

View File

@ -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)) {