//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);
}
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;
////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) {
//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;
}
// using the functions defined in lib/ddllib.php
function xmldb_label_upgrade($oldversion=0) {
-
global $CFG, $THEME, $DB;
$result = true;
* 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);
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)) {