From c61b92fd4904b7e8e7ed0bce46366800ffb8ea1f Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Fri, 30 Jul 2010 23:01:20 +0000 Subject: [PATCH] MDL-23479 backup - label revised & old code deleted (but restore logs) --- .../restore_label_activity_task.class.php | 14 +-- mod/label/backuplib.php | 112 ------------------ mod/label/restorelib.php | 83 ------------- 3 files changed, 2 insertions(+), 207 deletions(-) delete mode 100644 mod/label/backuplib.php diff --git a/mod/label/backup/moodle2/restore_label_activity_task.class.php b/mod/label/backup/moodle2/restore_label_activity_task.class.php index 6de3e2dd2b1..aff0f947bf5 100644 --- a/mod/label/backup/moodle2/restore_label_activity_task.class.php +++ b/mod/label/backup/moodle2/restore_label_activity_task.class.php @@ -52,11 +52,7 @@ class restore_label_activity_task extends restore_activity_task { * processed by the link decoder */ static public function define_decode_contents() { - $contents = array(); - - $contents[] = new restore_decode_content('label', array('intro'), 'label'); - - return $contents; + return array(); } /** @@ -64,12 +60,6 @@ class restore_label_activity_task extends restore_activity_task { * to the activity to be executed by the link decoder */ static public function define_decode_rules() { - $rules = array(); - - $rules[] = new restore_decode_rule('LABELVIEWBYID', '/mod/label/view.php?id=$1', 'course_module'); - $rules[] = new restore_decode_rule('LABELINDEX', '/mod/label/index.php?id=$1', 'course'); - - return $rules; - + return array(); } } diff --git a/mod/label/backuplib.php b/mod/label/backuplib.php deleted file mode 100644 index 0e28c2cdad8..00000000000 --- a/mod/label/backuplib.php +++ /dev/null @@ -1,112 +0,0 @@ -. - -/** - * Backup supportfor label module - * - * @package mod - * @subpackage label - * @copyright 2003 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die; - - //This php script contains all the stuff to backup/restore - //label mods - - //This is the "graphical" structure of the label mod: - // - // label - // (CL,pk->id) - // - // Meaning: pk->primary key field of the table - // fk->foreign key to link with parent - // nt->nested field (recursive data) - // CL->course level info - // UL->user level info - // files->table may have files) - // - //----------------------------------------------------------- - - //This function executes all the backup procedure about this mod - function label_backup_mods($bf,$preferences) { - global $CFG, $DB; - - $status = true; - - ////Iterate over label table - 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); - } - } - } - return $status; - } - - function label_backup_one_mod($bf,$preferences,$label) { - global $CFG, $DB; - - if (is_numeric($label)) { - $label = $DB->get_record('label', array('id'=>$label)); - } - - $status = true; - - //Start mod - fwrite ($bf,start_tag("MOD",3,true)); - //Print assignment data - fwrite ($bf,full_tag("ID",4,false,$label->id)); - fwrite ($bf,full_tag("MODTYPE",4,false,"label")); - fwrite ($bf,full_tag("NAME",4,false,$label->name)); - fwrite ($bf,full_tag("CONTENT",4,false,$label->intro)); - fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$label->timemodified)); - //End mod - $status = fwrite ($bf,end_tag("MOD",3,true)); - - return $status; - } - - ////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) { - $info += label_check_backup_mods_instances($instance,$backup_unique_code); - } - return $info; - } - - //First the course data - $info[0][0] = get_string("modulenameplural","label"); - $info[0][1] = $DB->count_records("label", array("course"=>$course)); - return $info; - } - - ////Return an array of info (name,value) - function label_check_backup_mods_instances($instance,$backup_unique_code) { - //First the course data - $info[$instance->id.'0'][0] = ''.$instance->name.''; - $info[$instance->id.'0'][1] = ''; - return $info; - } - - diff --git a/mod/label/restorelib.php b/mod/label/restorelib.php index 6cfc5789d6e..9eb4ae2e7f9 100644 --- a/mod/label/restorelib.php +++ b/mod/label/restorelib.php @@ -43,89 +43,6 @@ defined('MOODLE_INTERNAL') || die; // //----------------------------------------------------------- - //This function executes all the restore procedure about this mod - function label_restore_mods($mod,$restore) { - global $CFG, $DB; - - $status = true; - - //Get record from backup_ids - $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id); - - if ($data) { - //Now get completed xmlized object - $info = $data->info; - //traverse_xmlize($info); //Debug - //print_object ($GLOBALS['traverse_array']); //Debug - //$GLOBALS['traverse_array']=""; //Debug - - //Now, build the LABEL record structure - $label->course = $restore->course_id; - $label->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); - $label->intro = backup_todb($info['MOD']['#']['CONTENT']['0']['#']); - $label->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#']; - - //The structure is equal to the db, so insert the label - $newid = $DB->insert_record ("label",$label); - - //Do some output - if (!defined('RESTORE_SILENTLY')) { - echo "
  • ".get_string("modulename","label")." \"".format_string($label->name,true)."\"
  • "; - } - backup_flush(300); - - if ($newid) { - //We have the newid, update backup_ids - backup_putid($restore->backup_unique_code,$mod->modtype, - $mod->id, $newid); - - } else { - $status = false; - } - } else { - $status = false; - } - - return $status; - } - - function label_decode_content_links_caller($restore) { - global $CFG, $DB; - $status = true; - - if ($labels = $DB->get_records('label', array('course'=>$restore->course_id), '', "id,content")) { - $i = 0; //Counter to send some output to the browser to avoid timeouts - foreach ($labels as $label) { - //Increment counter - $i++; - $content = $label->intro; - $result = restore_decode_content_links_worker($content,$restore); - - if ($result != $content) { - //Update record - $label->intro = $result; - $status = $DB->update_record("label", $label); - if (debugging()) { - if (!defined('RESTORE_SILENTLY')) { - echo '

    '.s($content).'
    changed to
    '.s($result).'

    '; - } - } - } - //Do some output - if (($i+1) % 5 == 0) { - if (!defined('RESTORE_SILENTLY')) { - echo "."; - if (($i+1) % 100 == 0) { - echo "
    "; - } - } - backup_flush(300); - } - } - } - return $status; - } - //This function returns a log record with all the necessay transformations //done. It's used by restore_log_module() to restore modules log. function label_restore_logs($restore,$log) {