MDL-21695 question: replaced help files with new help strings
[moodle.git] / mod / feedback / backuplib.php
index 80f2fce..091d772 100644 (file)
@@ -1,4 +1,4 @@
-<?php // $Id$
+<?php
     //This php script contains all the stuff to backup/restore
     //feedback mods
 
 
     //This function executes all the backup procedure about this mod
    function feedback_backup_mods($bf,$preferences) {
-      global $CFG;
+      global $CFG, $DB;
 
       $status = true;
 
       //Iterate over feedback table
-      $feedbacks = get_records ("feedback","course",$preferences->backup_course,"id");
+      $feedbacks = $DB->get_records ("feedback", array("course"=>$preferences->backup_course), "id");
       if ($feedbacks) {
          foreach ($feedbacks as $feedback) {
             if (backup_mod_selected($preferences,'feedback',$feedback->id)) {
             }
          }
       }
-      return $status;  
+      return $status;
    }
 
    function feedback_backup_one_mod($bf,$preferences,$feedback) {
-      global $CFG;
-    
+      global $CFG, $DB;
+
       if (is_numeric($feedback)) {
-         $feedback = get_record('feedback','id',$feedback);
+         $feedback = $DB->get_record('feedback', array('id'=>$feedback));
       }
-      
+
       $status = true;
       fwrite ($bf,start_tag("MOD",3,true));
       //Print feedback data
@@ -58,7 +58,7 @@
       fwrite ($bf,full_tag("MODTYPE",4,false,"feedback"));
       fwrite ($bf,full_tag("VERSION",4,false,1)); //version 1 steht fuer die neue Version
       fwrite ($bf,full_tag("NAME",4,false,$feedback->name));
-      fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->summary));
+      fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->intro));
       fwrite ($bf,full_tag("ANONYMOUS",4,false,$feedback->anonymous));
       fwrite ($bf,full_tag("EMAILNOTIFICATION",4,false,$feedback->email_notification));
       fwrite ($bf,full_tag("MULTIPLESUBMIT",4,false,$feedback->multiple_submit));
       fwrite ($bf,full_tag("TIMEOPEN",4,false,$feedback->timeopen));
       fwrite ($bf,full_tag("TIMECLOSE",4,false,$feedback->timeclose));
       fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$feedback->timemodified));
-       
+
       //backup the items of each feedback
       feedback_backup_data($bf, $preferences, $feedback->id);
-       
+
       //End mod
       $status =fwrite ($bf,end_tag("MOD",3,true));
       return $status;
    }
-   
+
    function feedback_backup_data($bf, $preferences, $feedbackid) {
-      global $CFG;
+      global $CFG, $DB;
+
       $status = true;
-      $feedbackitems = get_records('feedback_item', 'feedback', $feedbackid);
+      $feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedbackid));
       if(function_exists('backup_userdata_selected')) { //compatibility-hack for moodle 1.5.x
          $backup_userdata = backup_userdata_selected($preferences,'feedback',$feedbackid);
       }else {
             fwrite ($bf,full_tag("HASVALUE",6,false,$feedbackitem->hasvalue));
             fwrite ($bf,full_tag("POSITION",6,false,$feedbackitem->position));
             fwrite ($bf,full_tag("REQUIRED",6,false,$feedbackitem->required));
-            
+
             if ($backup_userdata) {
                //backup the values of items
-               $feedbackvalues = get_records('feedback_value', 'item', $feedbackitem->id);
+               $feedbackvalues = $DB->get_records('feedback_value', array('item'=>$feedbackitem->id));
                if($feedbackvalues) {
                   $status =fwrite ($bf,start_tag("FBVALUES",6,true));
                   foreach($feedbackvalues as $feedbackvalue) {
          }
          $status =fwrite ($bf,end_tag("ITEMS",4,true));
       }
-      
+
       if($backup_userdata) {
          //backup of feedback-completeds
-         $feedbackcompleteds = get_records('feedback_completed', 'feedback', $feedbackid);
+         $feedbackcompleteds = $DB->get_records('feedback_completed', array('feedback'=>$feedbackid));
          if($feedbackcompleteds) {
             fwrite ($bf,start_tag("COMPLETEDS",4,true));
             foreach ($feedbackcompleteds as $feedbackcompleted) {
                fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$feedbackcompleted->timemodified));
                fwrite ($bf,full_tag("RANDOMRESPONSE",6,false,$feedbackcompleted->random_response));
                fwrite ($bf,full_tag("ANONYMOUSRESPONSE",6,false,$feedbackcompleted->anonymous_response));
-               
+
                //End completed
                $status =fwrite ($bf,end_tag("COMPLETED",5,true));
             }
             $status =fwrite ($bf,end_tag("COMPLETEDS",4,true));
          }
-         
+
          //backup of tracking-data
-         $feedbacktrackings = get_records('feedback_tracking', 'feedback', $feedbackid);
+         $feedbacktrackings = $DB->get_records('feedback_tracking', array('feedback'=>$feedbackid));
          if($feedbacktrackings) {
             fwrite ($bf,start_tag("TRACKINGS",4,true));
             foreach ($feedbacktrackings as $feedbacktracking) {
                fwrite ($bf,full_tag("USERID",6,false,$feedbacktracking->userid));
                fwrite ($bf,full_tag("FEEDBACK",6,false,$feedbacktracking->feedback));
                fwrite ($bf,full_tag("COMPLETED",6,false,$feedbacktracking->completed));
-               fwrite ($bf,full_tag("COUNT",6,false,$feedbacktracking->count));
-               
+
                //End completed
                $status =fwrite ($bf,end_tag("TRACKING",5,true));
             }
             $status =fwrite ($bf,end_tag("TRACKINGS",4,true));
          }
-         
+
       }
 
    }
 
 
    function feedback_backup_template_data($bf, $templateid, $userinfo) {
-      global $CFG;
+      global $CFG, $DB;
+
       $status = true;
-      $templateitems = get_records('feedback_item', 'template', $templateid);
+      $templateitems = $DB->get_records('feedback_item', array('template'=>$templateid));
 
       if ($templateitems) {
          $status =fwrite ($bf,start_tag("ITEMS",5,true));
             fwrite ($bf,full_tag("HASVALUE",7,false,$templateitem->hasvalue));
             fwrite ($bf,full_tag("POSITION",7,false,$templateitem->position));
             fwrite ($bf,full_tag("REQUIRED",7,false,$templateitem->required));
-            
+
             //End item
             $status =fwrite ($bf,end_tag("ITEM",6,true));
          }
       //First the course data
       $info[0][0] = get_string("modulenameplural","feedback");
       $info[0][1] = feedback_count($course);
-      
+
       //Now, if requested, the user_data
-      
+
       if ($user_data) {
          $info[1][0] = get_string('ready_feedbacks','feedback');
          $info[1][1] = feedback_completed_count($course);
       }
-      
+
       return $info;
    }
 
    ////Return an array of info (name,value)
    function feedback_check_backup_mods_instances($instance,$backup_unique_code) {
+      global $DB;
+
       //First the course data
       $info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
       $info[$instance->id.'0'][1] = '';
       //Now, if requested, the user_data
       if (!empty($instance->userdata)) {
          $info[$instance->id.'1'][0] = get_string("responses","feedback");
-         if ($responses_count = count_records ('feedback_completed', 'feedback', $instance->id)) {
+         if ($responses_count = $DB->count_records ('feedback_completed', array('feedback'=>$instance->id))) {
                $info[$instance->id.'1'][1] = $responses_count;
          } else {
                $info[$instance->id.'1'][1] = 0;
 ///////////////////////////////////////////////////////////////
 //// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
 
-   //Returns an array of feedbacks ids 
+   //Returns an array of feedbacks ids
    function feedback_count ($course) {
-      global $CFG;
-      return count_records('feedback', 'course', $course);
+      global $DB;
+
+      return $DB->count_records('feedback', array('course'=>$course));
    }
-   
+
    function feedback_completed_count($course) {
-      global $CFG;
+      global $DB;
+
       $count = 0;
       //get all feedbacks
-      $feedbacks = get_records('feedback', 'course', $course);
+      $feedbacks = $DB->get_records('feedback', array('course'=>$course));
       if($feedbacks) {
          foreach($feedbacks as $feedback) {
-            $count += count_records('feedback_completed', 'feedback', $feedback->id);
+            $count += $DB->count_records('feedback_completed', array('feedback'=>$feedback->id));
          }
       }
       return $count;
    }
-   
-?>
+
+