MDL-22153 backup - delete all the old *.html files
authorEloy Lafuente <stronk7@moodle.org>
Fri, 17 Sep 2010 13:21:15 +0000 (13:21 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Fri, 17 Sep 2010 13:21:15 +0000 (13:21 +0000)
backup/backup_check.html [deleted file]
backup/backup_execute.html [deleted file]
backup/backup_form.html [deleted file]
backup/restore_check.html [deleted file]
backup/restore_execute.html [deleted file]
backup/restore_form.html [deleted file]
backup/restore_precheck.html [deleted file]

diff --git a/backup/backup_check.html b/backup/backup_check.html
deleted file mode 100644 (file)
index 3949dc8..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-<?php
-    //This page prints the backup todo list to see everything
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    // Init backupuserinfo
-    $backupuserinfo = false;
-
-    if (!empty($course->id)) {
-        if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id))) {
-            if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', $loginurl);
-            } else {
-                if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', $loginurl);
-                }
-            }
-        }
-        $backupuserinfo = has_capability('moodle/backup:userinfo', get_context_instance(CONTEXT_COURSE, $course->id));
-    } else {
-        if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', $loginurl);
-        }
-        $backupuserinfo = has_capability('moodle/backup:userinfo', get_context_instance(CONTEXT_SYSTEM));
-    }
-
-
-
-    $backupprefs = new StdClass;
-    $count = 0;
-    backup_fetch_prefs_from_request($backupprefs,$count,$course);
-
-
-
-    //Check site
-    $site = get_site();
-    if ($count == 0) {
-        notice("No backupable modules are installed!");
-    }
-
-    if (!$DB->delete_records("backup_ids", array('backup_code'=>$backupprefs->backup_unique_code))){
-        print_error('cannotdeletebackupids');
-    }
-
-?>
-
-<form id="form" method="post" action="backup.php">
-<table cellpadding="5" style="text-align:center;margin-left:auto;margin-right:auto">
-<?php
-    echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-
-    if (empty($to)) {
-        //Now print the Backup Name tr
-        echo "<tr>";
-        echo "<td align=\"right\"><b>";
-        echo get_string("name").":";
-        echo "</b></td><td>";
-        //Add as text field
-        echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backupprefs->backup_name."\" />";
-        echo "</td></tr>";
-
-        //Line
-        echo "<tr><td colspan=\"2\"><hr /></td></tr>";
-
-        //Now print the To Do list
-        echo "<tr>";
-        echo "<td colspan=\"2\" align=\"center\"><b>";
-
-    }
-
-    // Re-enforce 'moodle/backup:backupcourse' at system context to be able to backup all users
-    if ($backupprefs->backup_users == 0 and !has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
-        $backupprefs->backup_users = 1; // users => course
-    }
-
-    // Re-enforce moodle/backup:userinfo capability
-    if (!$backupuserinfo) {
-        $backupprefs->backup_users = 2; // users => none
-    }
-
-    //Here we check if backup_users = None. Then, we switch off every module
-    //user info, user_files, logs and exercises, workshop and messages & blogs backups. A Warning is showed to
-    //inform the user.
-    // TODO: Move this logic to one function to be shared by any (manual, scheduled) backup
-    if ($backupprefs->backup_users == 2) {
-        if ($allmods = $DB->get_records('modules') ) {
-            foreach ($allmods as $mod) {
-            /// Reset global user_info settings to "no" (0)
-                $modname = $mod->name;
-                $var = 'backup_user_info_'.$modname;
-                if (isset($backupprefs->$var)) {
-                    $backupprefs->$var = 0;
-                }
-            /// Reset each instance userinfo settings to "no" (0)
-                if (isset($backupprefs->mods[$modname])) {
-                /// Set the module userinfo to no (0)
-                    $backupprefs->mods[$modname]->userinfo = 0;
-                /// Set the instances to no (o)
-                    foreach ($backupprefs->mods[$modname]->instances as $key => $instance) {
-                        $backupprefs->mods[$modname]->instances[$key]->userinfo = 0;
-                        $var = 'backup_user_info_' . $modname . '_instance_' . $key;
-                        $backupprefs->$var = 0;
-                    }
-                }
-            /// If modules are workshop or exercise, disable their backup completely
-                if ($modname == 'exercise' || $modname == 'workshop') {
-                    $var = 'backup_'.$modname;
-                    if (isset($backupprefs->$var)) {
-                        $backupprefs->$var = 0;
-                    /// Reset each instance backup settings to "no" (0)
-                        if (isset($backupprefs->mods[$modname])) {
-                        /// Set the module backup to no (0)
-                            $backupprefs->mods[$modname]->backup = 0;
-                            $var = 'backup_' . $modname . '_instances';
-                            $backupprefs->$var = 0;
-                        /// Set the instances backup to no (o)
-                            foreach ($backupprefs->mods[$modname]->instances as $key => $instance) {
-                                $backupprefs->mods[$modname]->instances[$key]->backup = 0;
-                                $var = 'backup_' . $modname . '_instance_' . $key;
-                                $backupprefs->$var = 0;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        $backupprefs->backup_user_files = 0;
-        $backupprefs->backup_logs = 0;
-        $backupprefs->backup_messages = 0;
-        $backupprefs->backup_blogs = 0;
-        $backupprefs->backuproleassignments = array();
-
-        if ($backupuserinfo) { // Based on perms, decide the msg to show
-            $nousersmsgtoshow = 'backupnoneusersinfo';
-        } else {
-            $nousersmsgtoshow = 'backupmissinguserinfoperms';
-        }
-        echo $OUTPUT->box(get_string($nousersmsgtoshow), "noticebox");
-        echo "<hr />";
-    }
-
-    if (empty($to)) {
-        echo get_string("backupdetails").":";
-        echo "</b></td></tr>";
-    }
-
-    //This is the alignment of every row in the table
-    $table = new html_table();
-    $table->align = array ("left","right");
-
-    if ($allmods = $DB->get_records("modules") ) {
-        foreach ($allmods as $mod) {
-            $modname = $mod->name;
-            $modfile = $CFG->dirroot.'/mod/'.$modname.'/backuplib.php';
-            if (!file_exists($modfile)) {
-                continue;
-            }
-            require_once($modfile);
-            $modbackup = $modname."_backup_mods";
-            //If exists the lib & function
-            $var = "exists_".$modname;
-            if (isset($backupprefs->$var) && $backupprefs->$var) {
-                $var = "backup_".$modname;
-                //Only if selected
-                if (!empty($backupprefs->$var) and ($backupprefs->$var == 1)) {
-                    //Print the full tr
-                    echo "<tr>";
-                    echo "<td colspan=\"2\">";
-                    //Print the mod name
-                    echo "<b>".get_string("include")." ".get_string("modulenameplural",$modname)." ";
-                    //Now look for user-data status
-                    $backup_user_options[0] = get_string("withoutuserdata");
-                    $backup_user_options[1] = get_string("withuserdata");
-                    $var = "backup_user_info_".$modname;
-                    //Print the user info
-                    echo $backup_user_options[$backupprefs->$var]."</b>";
-                    //Call the check function to show more info
-                    $modcheckbackup = $modname."_check_backup_mods";
-                    $var = $modname.'_instances';
-                    $instancestopass = array();
-                    if (!empty($backupprefs->$var) && is_array($backupprefs->$var) && count($backupprefs->$var)) {
-                        $table->data = array();
-                        $countinstances = 0;
-                        foreach ($backupprefs->$var as $instance) {
-                            $var1 = 'backup_'.$modname.'_instance_'.$instance->id;
-                            $var2 = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
-                            if (!empty($backupprefs->$var1)) {
-                                $obj = new StdClass;
-                                $obj->name = $instance->name;
-                                $obj->userdata = $backupprefs->$var2;
-                                $obj->id = $instance->id;
-                                $instancestopass[$instance->id]= $obj;
-                                $countinstances++;
-
-                            }
-                        }
-                    }
-                    $table->data = $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code,$instancestopass);
-                    echo html_writer::table($table);
-                    echo "</td></tr>";
-                }
-            }
-        }
-
-
-        if (empty($to)) {
-            //Line
-            echo "<tr><td colspan=\"2\"><hr /></td></tr>";
-
-            //Now print the Users tr
-            echo "<tr>";
-            echo "<td colspan=\"2\"><b>";
-            $user_options[0] = get_string("includeallusers");
-            $user_options[1] = get_string("includecourseusers");
-            $user_options[2] = get_string("includenoneusers");
-            echo $user_options[$backupprefs->backup_users].'</b>';
-            //Print info
-            $table->data = user_check_backup($id,$backupprefs->backup_unique_code,$backupprefs->backup_users,$backupprefs->backup_messages, $backupprefs->backup_blogs);
-            echo html_writer::table($table);
-            echo "</td></tr>";
-
-        }
-
-        //Now print the Logs tr conditionally
-        if ($backupprefs->backup_logs && empty($to)) {
-            echo "<tr>";
-            echo "<td colspan=\"2\"><b>";
-            echo get_string("includelogentries").'</b>';
-            //Print info
-            $table->data = log_check_backup($id);
-            echo html_writer::table($table);
-            echo "</td></tr>";
-        }
-
-        //Now print the User Files tr conditionally
-        if ($backupprefs->backup_user_files) {
-            echo "<tr>";
-            echo "<td colspan=\"2\"><b>";
-            echo get_string("includeuserfiles").'</b>';
-            //Print info
-            $table->data = user_files_check_backup($id,$backupprefs->backup_unique_code);
-            echo html_writer::table($table);
-            echo "</td></tr>";
-        }
-
-        //Now print the Course Files tr conditionally
-        if ($backupprefs->backup_course_files) {
-            echo "<tr>";
-            echo "<td colspan=\"2\"><b>";
-            echo get_string("includecoursefiles").'</b>';
-            //Print info
-            $table->data = course_files_check_backup($id,$backupprefs->backup_unique_code);
-            echo html_writer::table($table);
-            echo "</td></tr>";
-        }
-
-        //Now print the site Files tr conditionally
-        if ($backupprefs->backup_site_files) {
-            echo "<tr>";
-            echo "<td colspan=\"2\"><b>";
-            echo get_string("includesitefiles").'</b>';
-            //Print info
-            $table->data = site_files_check_backup($id,$backupprefs->backup_unique_code);
-            echo html_writer::table($table);
-            echo "</td></tr>";
-        }
-
-        //Now print the role assignments information conditionally
-        if (!empty($backupprefs->backuproleassignments)) {
-            echo "<tr>";
-            echo "<td colspan=\"2\"><b>";
-            echo get_string("includeroleassignments").'</b>';
-            //Print info
-            $table->data = array(array(get_string('roles'), count($backupprefs->backuproleassignments)));
-            echo html_writer::table($table);
-            echo "</td></tr>";
-        }
-    }
-
-    // now keep it for next time.
-    $SESSION->backupprefs[$course->id] = $backupprefs;
-
-?>
-</table>
-<div style="text-align:center;margin-left:auto;margin-right:auto">
-<input type="hidden" name="to"     value="<?php p($to) ?>" />
-<input type="hidden" name="id"     value="<?php  p($id) ?>" />
-<input type="hidden" name="launch" value="execute" />
-<input type="submit" value="<?php  print_string("continue") ?>" />
-<input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
-</div>
-</form>
diff --git a/backup/backup_execute.html b/backup/backup_execute.html
deleted file mode 100644 (file)
index 5edf378..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-    //This page prints the backup todo list to see everything
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    if (!empty($course->id)) {
-        if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id))) {
-            if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', $loginurl);
-            } else {
-                if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', $loginurl);
-                }
-            }
-        }
-    } else {
-        if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', $loginurl);
-        }
-    }
-
-
-    //Check site
-    $site = get_site();
-
-    $preferences = new StdClass;
-    backup_fetch_prefs_from_request($preferences,$count,$course);
-    //Another Info
-    backup_add_static_preferences($preferences);
-
-    if ($count == 0) {
-        notice("No backupable modules are installed!");
-    }
-
-
-    if (empty($to)) {
-        //Start the main table
-        echo "<table cellpadding=\"5\">";
-
-        //Now print the Backup Name tr
-        echo "<tr>";
-        echo "<td align=\"right\"><b>";
-        echo get_string("name").":";
-        echo "</b></td><td>";
-        echo $preferences->backup_name;
-        echo "</td></tr>";
-
-        //Start the main tr, where all the backup progress is done
-        echo "<tr>";
-        echo "<td colspan=\"2\">";
-
-        //Start the main ul
-        echo "<ul>";
-    }
-
-    $errorstr = '';
-    $status = backup_execute($preferences, $errorstr);
-
-    //Ends th main ul
-    echo "</ul>";
-
-    //End the main tr, where all the backup is done
-    echo "</td></tr>";
-
-    //End the main table
-    echo "</table>";
-
-    if (!$status) {
-        print_error('error', 'error', "$CFG->wwwroot/course/view.php?id=$course->id");
-    }
-
-    if (empty($to)) {
-        //Print final message
-        echo $OUTPUT->box(get_string("backupfinished"));
-        $context = get_context_instance(CONTEXT_COURSE, $course->id);
-        echo $OUTPUT->continue_button("$CFG->wwwroot/files/index.php?contextid=".$context->id."&component=backup&filearea=course&itemid=0");
-    } else {
-        echo $OUTPUT->box(get_string('importdataexported'));
-        if (!empty($preferences->backup_destination)) {
-            $filename = $preferences->backup_destination."/".$preferences->backup_name;
-        } else {
-            $filename = $preferences->backup_course."/backupdata/".$preferences->backup_name;
-        }
-        error_log($filename);
-        $SESSION->import_preferences = $preferences;
-        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
-    }
-
-    $SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time.
-?>
diff --git a/backup/backup_form.html b/backup/backup_form.html
deleted file mode 100644 (file)
index 3e376ac..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-<?php
-    //This page prints the backup form to select everything
-    global $DB;
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    //Init backupuserinfo
-    $backupuserinfo = false;
-
-    if (!empty($course->id)) {
-        if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id))) {
-            if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', $loginurl);
-            } else {
-                if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', $loginurl);
-                }
-            }
-        }
-        $backupuserinfo = has_capability('moodle/backup:userinfo', get_context_instance(CONTEXT_COURSE, $course->id));
-    } else {
-        if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', $loginurl);
-        }
-        $backupuserinfo = has_capability('moodle/backup:userinfo', get_context_instance(CONTEXT_SYSTEM));
-    }
-
-    //Check site
-    $site = get_site();
-
-    //Checks for the required files/functions to backup every mod
-    //And check if there is data about it
-    $count = 0;
-    if ($allmods = $DB->get_records('modules', array('visible'=>1)) ) {
-        foreach ($allmods as $mod) {
-            $modname = $mod->name;
-            $modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
-            $modbackup = $modname."_backup_mods";
-            $modbackupone = $modname.'_backup_one_mod';
-            $modcheckbackup = $modname."_check_backup_mods";
-            if (file_exists($modfile)) {
-               include_once($modfile);
-               if (function_exists($modbackup) and function_exists($modcheckbackup)) {
-                   $var = "exists_".$modname;
-                   $$var = true;
-                   $count++;
-                   // check that there are instances and we can back them up individually
-                   if ($DB->count_records('course_modules',array('course'=>$course->id,'module'=>$mod->id)) && function_exists($modbackupone)) {
-                       $var = 'exists_one_'.$modname;
-                       $$var = true;
-                   }
-               }
-            }
-            //Check data
-            //Check module info
-            $var = "backup_".$modname;
-            $$var = optional_param( $var,1, PARAM_CLEAN);
-            //Check include user info
-            $var = "backup_user_info_".$modname;
-            $$var = optional_param( $var,1, PARAM_CLEAN);
-        }
-    }
-
-    //Check other parameters
-    $backup_metacourse = optional_param('backup_metacourse',1, PARAM_BOOL);
-    $backup_users = optional_param('backup_users',1, PARAM_BOOL);
-    $backup_logs = optional_param('backup_logs',0, PARAM_BOOL);
-    $backup_user_files = optional_param('backup_user_files',1, PARAM_BOOL);
-    $backup_course_files = optional_param('backup_course_files',1, PARAM_BOOL);
-    $backup_site_files = optional_param('backup_site_files',1, PARAM_BOOL);
-    $backup_gradebook_history =  optional_param('backup_gradebook_history', 0, PARAM_INT);
-    $backup_messages = optional_param('backup_messages',1, PARAM_BOOL);
-    $backup_blogs = optional_param('backup_blogs',1, PARAM_BOOL);
-
-    if ($count == 0) {
-        notice("No backupable modules are installed!");
-    }
-
-?>
-
-<script type="text/javascript">
-<!--
-function selectItemInMenuByName(formId, menuName, selectIndex ) {
-    myForm = document.getElementById(formId)
-    for (i=0,n=myForm.elements.length;i<n;i++) {
-        myLen = menuName.length;
-        myName = myForm.elements[i].name;
-        myType = myForm.elements[i].type;
-        if (myName.substring(0,myLen) == menuName && myType == "select-one") {
-            myForm.elements[i].options[selectIndex].selected = true;
-        }
-    }
-}
-
-function selectItemInRadioByName(formId, radioName, selectIndex ) {
-    myForm = document.getElementById(formId)
-    for (i=0,n=myForm.elements.length;i<n;i++) {
-        myLen = radioName.length;
-        myName = myForm.elements[i].name;
-        myType = myForm.elements[i].type;
-        if (myName.substring(0,myLen) == radioName && myType == "radio") {
-            myRadioGroup = myForm.elements[myName];
-            myRadioGroup[selectIndex].checked = true;
-        }
-    }
-}
-
-function selectItemInCheckboxByName(formId, checkName, checked ) {
-    myForm = document.getElementById(formId);
-    for (i=0,n=myForm.elements.length;i<n;i++) {
-        myLen = checkName.length;
-        myName = myForm.elements[i].name;
-        myType = myForm.elements[i].type;
-        if (myName.substring(0,myLen) == checkName && myType == "checkbox") {
-            myForm.elements[i].checked = checked;
-        }
-    }
-}
--->
-</script>
-<form id="form1" method="post" action="backup.php">
-<table cellpadding="5" style="margin-left:auto;margin-right:auto;">
-<?php
-    echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-
-/// Acummulator for hidden options and proper XHTML output
-    $hidden_options = '';
-    //Now, check modules and info and show posibilities
-    if ($allmods = $DB->get_records('modules', array('visible'=>1)) ) {
-        //Print option to select/deselect everything with 1 click.
-        echo "<tr>";
-        echo "<td align=\"right\">";
-        echo '<b>'.get_string("include")."</b>";
-        echo "</td><td>";
-        echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'backup_', true);\">". get_string("all")."</a>/";
-        echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'backup_', false);\">".  get_string("none")."</a>";
-        echo "</td>";
-        if (empty($to) and $backupuserinfo) {
-            echo "<td align=\"right\">";
-            echo '<b>&nbsp;</b>';
-            echo "</td><td>";
-            echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'backup_user_info_', true);\">". get_string("all")."</a>/";
-            echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'backup_user_info_', false);\">". get_string("none")."</a>";
-            echo "</td>";
-        } else {
-            echo "<td colspan=\"2\">&nbsp;</td>";
-        }
-        echo "</tr>";
-        echo "<tr><td colspan=\"4\"><hr /></td></tr>";
-        $currentrow = 0;
-        foreach ($allmods as $mod) {
-            $modname = $mod->name;
-            $modbackup = $modname."_backup_mods";
-            //If exists the lib & function
-            $var   = 'exists_'.$modname;
-            $exvar = 'exists_one_'.$modname;
-            if (!empty($$var) and !empty($$exvar)) {
-                //Print the full tr
-                echo "<tr class=\"r".$currentrow."\">";
-                echo "  <td align=\"right\">&nbsp;";
-                echo "</td><td>\n";
-                $backup_options[0] = get_string("no");
-                $backup_options[1] = get_string("yes");
-                $var = "backup_".$modname;
-                //Print the checkbox
-                print_checkbox($var, $$var, $$var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'backup_'.$modname.'\',this.checked)');
-                echo "</td><td align=\"right\">&nbsp;";
-                echo "</td><td>";
-                $var = "backup_user_info_".$modname;
-                if (empty($to) and $backupuserinfo) {
-                    $backup_user_options[0] = get_string("withoutuserdata");
-                    $backup_user_options[1] = get_string("withuserdata");
-                    print_checkbox($var, $$var, $$var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'backup_user_info_'.$modname.'\',this.checked)');
-                } else {
-                    echo '<input type="hidden" name="'.$var.'" value="0" />';
-                }
-                echo "</td></tr>\n";
-                echo '<tr><td></td><td colspan="3"><table class="backup-form-instances">';
-                $instances = get_all_instances_in_course($modname, $course, NULL, true);
-                $var = $exvar;
-                foreach ($instances as $instance) {
-                    echo '<tr><td>';
-                    $var = 'backup_'.$modname.'_instance_'.$instance->id;
-                    $$var = optional_param($var,1, PARAM_CLEAN);
-                    print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'backup_'.$modname.'\'].checked=1;');
-                    echo '</td><td align="right">&nbsp;';
-                    $var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
-                    $$var = optional_param($var,1, PARAM_CLEAN);
-                    if (empty($to) and $backupuserinfo) {
-                        print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'backup_user_info_'.$modname.'\'].checked=1;');
-                    } else {
-                        echo '<input type="hidden" name="'.$var.'" value="0" />';
-                    }
-                    echo '</td></tr>';
-                }
-                echo '</table></td></tr>';
-            }
-        }
-        //Line
-        echo "<tr><td colspan=\"4\"><hr /></td></tr>\n";
-
-        if (empty($to) && !empty($course->metacourse)) {
-            //Now print the Metacourse tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_metacourse">'.get_string ("metacourse").'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $meta_options[0] = get_string("no");
-            $meta_options[1] = get_string("yes");
-            echo html_writer::select($meta_options, "backup_metacourse", $backup_metacourse, false);
-            echo "</td></tr>";
-        }
-        else {
-            $hidden_options .= '<input type="hidden" name="backup_metacourse" value="0" />';
-        }
-
-        if (empty($to) and $backupuserinfo) {
-            //Now print the Users tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_users">'.get_string ("users").'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            if (has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
-                $user_options[0] = get_string("all");
-            }
-            $user_options[1] = get_string("course");
-            $user_options[2] = get_string("none");
-            echo html_writer::select($user_options, "backup_users", $backup_users, false);
-            echo "</td></tr>";
-        }
-        else {
-            $hidden_options .= '<input type="hidden" name="backup_users" value="2" />';
-        }
-
-        if (empty($to) and $backupuserinfo) {
-            //Now print the Logs tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_logs">'.get_string ("logs").'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $log_options[0] = get_string("no");
-            $log_options[1] = get_string("yes");
-            echo html_writer::select($log_options, "backup_logs", $backup_logs, false);
-            echo "</td></tr>";
-        }
-        else {
-            $hidden_options .= '<input type="hidden" name="backup_logs" value="0" />';
-        }
-
-        if (empty($to) and $backupuserinfo) {
-            //Now print the User Files tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_user_files">'.get_string ("userfiles").'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $user_file_options[0] = get_string("no");
-            $user_file_options[1] = get_string("yes");
-            echo html_writer::select($user_file_options, "backup_user_files", $backup_user_files, false);
-            echo "</td></tr>";
-        }
-        else {
-            $hidden_options .= '<input type="hidden" name="backup_user_files" value="0" />';
-        }
-
-        //Now print the Course Files tr
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menubackup_course_files">'.get_string ("coursefiles").'</label>';
-        echo "</b></td><td colspan=\"2\">";
-        $course_file_options[0] = get_string("no");
-        $course_file_options[1] = get_string("yes");
-        echo html_writer::select($course_file_options, "backup_course_files", $backup_course_files, false);
-        echo "</td></tr>";
-
-
-        if ($course->id != SITEID){
-            //Now print the site Files tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_site_files">'.get_string ("sitefilesused").'</label>';
-            echo $OUTPUT->old_help_icon('sitefilesused', get_string('sitefilesused'));
-            echo "</b></td><td colspan=\"2\">";
-            $course_file_options[0] = get_string("no");
-            $course_file_options[1] = get_string("yes");
-            echo html_writer::select($course_file_options, "backup_site_files", $backup_site_files, false);
-            echo "</td></tr>";
-        }
-
-        // do you want grade histories to be backed up?
-        if (empty($to) and $backupuserinfo and empty($CFG->disablegradehistory)) {
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_gradebook_history">'.get_string ('gradebookhistories', 'grades').'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $gradebook_history_options[0] = get_string("no");
-            $gradebook_history_options[1] = get_string("yes");
-            echo html_writer::select($gradebook_history_options, "backup_gradebook_history", $backup_gradebook_history, false);
-            echo "</td></tr>";
-        } else {
-            $hidden_options .= '<input type="hidden" name="backup_gradebook_history" value="0" />';
-        }
-
-        if (empty($to) and $backupuserinfo and $course->id == SITEID) {
-            //If we are in a SITEID backup print the Messages tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menubackup_messages">'.get_string ('messages', 'message').'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $mess_options[0] = get_string("no");
-            $mess_options[1] = get_string("yes");
-            echo html_writer::select($mess_options, "backup_messages", $backup_messages, false);
-            echo "</td></tr>";
-        }
-        else {
-            $hidden_options .= '<input type="hidden" name="backup_messages" value="0" />';
-        }
-
-        if (empty($to) and $backupuserinfo and $course->id == SITEID and !empty($CFG->bloglevel)) {
-            //If we are in a SITEID backup and blogs are enabled print the Blogs tr
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo get_string ('blogs','blog').":";
-            echo "</b></td><td colspan=\"2\">";
-            $blog_options[0] = get_string("no");
-            $blog_options[1] = get_string("yes");
-            echo html_writer::select($blog_options, "backup_blogs", $backup_blogs, false);
-            echo "</td></tr>";
-        }
-        else {
-            $hidden_options .= '<input type="hidden" name="backup_blogs" value="0" />';
-        }
-    }
-
-    //Now print a place to select which role assignments to back up.
-    if (empty($to) and $backupuserinfo) {
-        //Line
-        echo "<tr><td colspan=\"4\"><hr /></td></tr>\n";
-
-        echo "<tr>";
-        echo "<td align=\"right\" valign=\"top\" colspan=\"2\"><b>";
-        echo get_string("backuproleassignments");
-        echo "</b></td><td colspan=\"2\">";
-        $roles = get_all_roles();
-        foreach ($roles as $role) {
-            print_checkbox('backupassignments_' . $role->shortname, 1, true, strip_tags(format_string($role->name, true)));
-            echo "<br />";
-        }
-        echo "<a href=\"#\" onclick=\"selectItemInCheckboxByName('form1', 'backupassignments_', true); return false;\">". get_string("all")."</a>/";
-        echo "<a href=\"#\" onclick=\"selectItemInCheckboxByName('form1', 'backupassignments_', false); return false;\">". get_string("none")."</a>";
-        echo "</td></tr>";
-    }
-
-    $backup_unique_code = time();
-
-    //Calculate the backup string
-    //Calculate the backup unique code to allow simultaneus backups (to define
-    //the temp-directory name and records in backup temp tables
-    $backup_name = backup_get_zipfile_name($course, $backup_unique_code);
-
-
-?>
-</table>
-<div style="text-align:center;margin-left:auto;margin-right:auto">
-<?php
-/// Print captured hidden options, now that we have closed the table
-    echo $hidden_options;
-?>
-<input type="hidden" name="id"     value="<?php  p($id) ?>" />
-<input type="hidden" name="to"     value="<?php p($to) ?>" />
-<input type="hidden" name="backup_unique_code" value="<?php p($backup_unique_code); ?>" />
-<input type="hidden" name="backup_name" value="<?php p($backup_name); ?>" />
-<input type="hidden" name="launch" value="check" />
-<input type="submit" value="<?php  print_string("continue") ?>" />
-<input type="submit" name="cancel" value="<?php  print_string("cancel") ?>" />
-</div>
-</form>
diff --git a/backup/restore_check.html b/backup/restore_check.html
deleted file mode 100644 (file)
index 1711025..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-<?php
-
-    //This page receive all the restore_form data. Then, if existing course
-    //has been selected, shows a list of courses to select one.
-    //It cheks that the parammeter from restore_form are coherent.
-    //It puts all the restore info in the session.
-    //Finally, it calls restore_execute to do the hard work
-    //Get objects from session
-
-    global $DB, $OUTPUT;
-
-    if ($SESSION) {
-        $info = $SESSION->info;
-        $course_header = $SESSION->course_header;
-        if (isset($SESSION->restore)) {
-            $restore = $SESSION->restore;
-        }
-    }
-
-    //Detect if we are coming from the restore form
-    $fromform = optional_param ('fromform', 0, PARAM_INT);
-
-    ///Enforce SESSION->course_header rewrite (PHP 4.x needed because assigns are by value) MDL-8298
-    $SESSION->course_header = $course_header;
-
-    //If restore session info exists, but we are coming from the form
-    //it has prioriry
-    if (isset($restore) and !empty($fromform)) {
-        unset($restore);
-    }
-
-    // check for session objects
-    if (empty($info) or empty($course_header)) {
-      print_error('sessionmissing', 'debug', '',
-              'info and course_header');
-    }
-
-
-    //If the restore object doesn't exist, we are going
-    //to check every variable individually and create it
-
-    if (!isset($restore)) {
-        //Check that we have all we need
-        //backup_unique_code
-        $backup_unique_code = required_param('backup_unique_code', PARAM_INT);
-        //file
-        $file = required_param('file', PARAM_PATH);
-        //Checks for the required restoremod parameters
-        if ($allmods = $DB->get_records("modules")) {
-            foreach ($allmods as $mod) {
-                $modname = $mod->name;
-                $var = "restore_".$modname;
-                $$var = optional_param( $var,0, PARAM_CLEAN);
-                $var = "restore_user_info_".$modname;
-                $$var = optional_param( $var,0, PARAM_CLEAN);
-                $instances = !empty($info->mods[$mod->name]->instances) ? $info->mods[$mod->name]->instances : NULL;
-                if ($instances === NULL) {
-                    continue;
-                }
-                foreach ($instances as $instance) {
-                    $var = 'restore_'.$modname.'_instance_'.$instance->id;
-                    $$var = optional_param($var,0,PARAM_INT);
-                    $var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
-                    $$var = optional_param($var,0,PARAM_INT);
-                }
-            }
-        }
-        //restoreto
-        $restore_restoreto = required_param('restore_restoreto', PARAM_INT);
-        //restore_users
-        $restore_users = required_param('restore_users', PARAM_INT);
-
-        $restore_groups = required_param('restore_groups', PARAM_INT);
-        //restore_logs
-        $restore_logs = required_param('restore_logs', PARAM_INT);
-        //restore_user_files
-        $restore_user_files = required_param('restore_user_files', PARAM_INT);
-        //restore_course_files
-        $restore_course_files = required_param('restore_course_files', PARAM_INT);
-        //restore_site_files
-        $restore_site_files = required_param('restore_site_files', PARAM_INT);
-        //restore_gradebook_history
-        $restore_gradebook_history = required_param('restore_gradebook_history', PARAM_INT);
-        //restore_messages
-        $restore_messages = required_param('restore_messages', PARAM_INT);
-        //restore_blogs
-        $restore_blogs = required_param('restore_blogs', PARAM_INT);
-
-        //Check we've selected a course to restore to
-        $course_id = optional_param('course_id', 0, PARAM_INT);
-
-        //We are here, having all we need !!
-        //Create the restore object and put it in the session
-        $restore->backup_unique_code = $backup_unique_code;
-        $restore->file = $file;
-        if ($allmods = $DB->get_records("modules")) {
-            foreach ($allmods as $mod) {
-                $modname = $mod->name;
-                $var = "restore_".$modname;
-                $restore->mods[$modname]->restore=$$var;
-                $var = "restore_user_info_".$modname;
-                $restore->mods[$modname]->userinfo=$$var;
-                $instances = !empty($info->mods[$mod->name]->instances) ? $info->mods[$mod->name]->instances : NULL;
-                if ($instances === NULL) {
-                    continue;
-                }
-                foreach ($instances as $instance) {
-                    $var = 'restore_'.$modname.'_instance_'.$instance->id;
-                    $restore->mods[$modname]->instances[$instance->id]->restore = $$var;
-                    $var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
-                    $restore->mods[$modname]->instances[$instance->id]->userinfo = $$var;
-                }
-            }
-        }
-        $restore->restoreto=$restore_restoreto;
-        $restore->users=$restore_users;
-        $restore->groups=$restore_groups;
-        $restore->logs=$restore_logs;
-        $restore->user_files=$restore_user_files;
-        $restore->course_files=$restore_course_files;
-        $restore->site_files=$restore_site_files;
-        $restore->messages=$restore_messages;
-        $restore->blogs=$restore_blogs;
-        $restore->restore_gradebook_history=$restore_gradebook_history;
-        $restore->course_id=$course_id;
-        //add new vars to restore object
-        $restore->course_startdateoffset = $coursestartdatedateoffset;
-        $restore->course_shortname = $currentcourseshortname;
-
-        // create role mappings, not sure all should be here
-        if ($data2 = data_submitted()) {
-            foreach ($data2 as $tempname=>$tempdata) {
-                if (strstr($tempname, 'roles_')) {
-                    $temprole = explode('_', $tempname);
-                    $oldroleid = $temprole[1];
-                    $newroleid = $tempdata;
-                    $restore->rolesmapping[$oldroleid] = $newroleid;
-                }
-            }
-        }
-
-        // default role mapping for moodle < 1.7
-        if ($defaultteacheredit = optional_param('defaultteacheredit', 0, PARAM_INT)) {
-            $restore->rolesmapping['defaultteacheredit'] = $defaultteacheredit;
-        }
-        if ($defaultteacher = optional_param('defaultteacher', 0, PARAM_INT)) {
-            $restore->rolesmapping['defaultteacher'] = $defaultteacher;
-        }
-        if ($defaultstudent = optional_param('defaultstudent', 0, PARAM_INT)) {
-            $restore->rolesmapping['defaultstudent'] = $defaultstudent;
-        }
-
-    } else {
-        //We have the object, so check if we have a new course_id
-        //passed as parammeter
-        $course_id = optional_param('course_id', 0, PARAM_INT);
-        if ($course_id) {
-            $restore->course_id=$course_id;
-        }
-    }
-
-    // pass in the course category param
-    $restore->restore_restorecatto = optional_param('restore_restorecatto', 0, PARAM_INT);
-
-    //We have the object with data, put it in the session
-    $SESSION->restore = $restore;
-
-    //From here to the end of the script, only use the $restore object
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    //Init restoreuserinfo
-    $restoreuserinfo = false;
-
-
-    //Check admin
-    if (!empty($id)) {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
-            print_error("cannotuseadminadminorteacher", '', $loginurl);
-        }
-        $restoreuserinfo = has_capability('moodle/restore:userinfo', get_context_instance(CONTEXT_COURSE, $id));
-    } else {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', $loginurl);
-        }
-        $restoreuserinfo = has_capability('moodle/restore:userinfo', get_context_instance(CONTEXT_SYSTEM));
-    }
-
-    //Check site
-    $site = get_site();
-
-    // Get all the courses the user is able to restore to
-    //TODO: use better function which includes all courses for admins
-    $mycourses = get_user_courses_bycap($USER->id, 'moodle/restore:restorecourse');
-
-    // Calculate if the user can create courses
-    $cancreatecourses = user_can_create_courses();
-
-    if (empty($restore->course_id) && ($restore->restoreto == RESTORETO_CURRENT_DELETING || $restore->restoreto == RESTORETO_CURRENT_ADDING)) {
-        $restore->course_id = $id; /// Force restore to current course, disabling pick course from list
-    }
-
-    //Set restore->deleting as needed
-    if ($restore->restoreto == RESTORETO_CURRENT_DELETING || $restore->restoreto == RESTORETO_EXISTING_DELETING) {
-        $restore->deleting = true;
-    } else {
-        $restore->deleting = false;
-    }
-
-    //Now, select the course if needed
-    if (empty($restore->course_id) && ($restore->restoreto == RESTORETO_EXISTING_DELETING || $restore->restoreto == RESTORETO_EXISTING_ADDING)) {
-
-        if ($courses = $mycourses) {
-            echo $OUTPUT->heading(get_string("choosecourse"));
-            echo $OUTPUT->box_start();
-            foreach ($courses as $course) {
-                if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $course->id))) {
-                    continue;
-                }
-                if (empty($course->visible)) {
-                    $optdimmed = ' class="dimmed" ';
-                } else {
-                    $optdimmed = '';
-                }
-                echo "<a $optdimmed href=\"restore.php?course_id=$course->id&amp;launch=check&amp;id=$id&amp;file=$file\">".format_string($course->fullname).' ('.format_string($course->shortname).')</a><br />'."\n";
-            }
-            echo $OUTPUT->box_end();
-        } else {
-            echo $OUTPUT->heading(get_string("nocoursesyet"));
-            echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/index.php");
-        }
-    //Checks everything and execute restore
-    } else if (($restore->restoreto != RESTORETO_NEW_COURSE and !empty($restore->course_id)) or ($restore->restoreto == RESTORETO_NEW_COURSE)) {
-        //Final access control check
-        if (empty($restore->course_id) and !$cancreatecourses) {
-            print_error("cannotrestoreadminorcreator");
-        } else if (!empty($restore->course_id) and !has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $restore->course_id))) {
-            print_error("cannotrestoreadminoredit");
-        }
-        $show_continue_button = true;
-        $messages = array();
-
-        //Check and warn if we are restoring over frontpage (SITEID) course. MDL-19163
-        if ($restore->course_id == SITEID) {
-            if ($restore->restoreto == RESTORETO_CURRENT_DELETING) {
-                $messages[] = get_string ('restoretositedeleting');
-            } else if ($restore->restoreto == RESTORETO_CURRENT_ADDING) {
-                $messages[] = get_string ('restoretositeadding');
-            }
-        }
-
-        //Check if we've selected any mod's user info and restore->users
-        //is set to none. Change it to course and inform.
-        if ($restore->users == 2) {
-            $changed = false;
-            $mods = $restore->mods;
-            foreach ($mods as $mod) {
-                if ($mod->userinfo) {
-                    $changed = true;
-                }
-            }
-            //If we have selected user files or messages or blogs, then users must be restored too
-            if ($restore->user_files || $restore->messages || $restore->blogs) {
-                $changed = 1;
-            }
-            if ($changed) {
-                $messages[] = get_string ("noteuserschangednonetocourse");
-                $restore->users = 1;
-            }
-        }
-
-        // Re-enforce 'moodle/restore:restorecourse' at system context to be able to restore all users
-        if ($restore->users == 0 and !has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
-            $restore->users = 1; // users => course
-        }
-
-        // Re-enforce moodle/restore:userinfo capability
-        if (!$restoreuserinfo) {
-            $userinfocheck = true;
-            // Confirm that all the settings are properly set to no users
-            // if anything is wrong, message and stop
-            // First global settings
-            if ($restore->users != 2 or $restore->user_files or $restore->messages or $restore->blogs) {
-                $userinfocheck = false;
-
-            // Now all modules userinfo flag
-            } else {
-                $mods = $restore->mods;
-                foreach ($mods as $mod) {
-                    if ($mod->userinfo) {
-                        $userinfocheck = false;
-                    }
-                }
-            }
-
-            if (!$userinfocheck) { // Something was wrong
-                $messages[] = get_string('restoreuserinfofailed');
-                $show_continue_button = false;
-            }
-        }
-
-        // Re-check all the roles creation/mapping stuff
-        if (!empty($restore->course_id)) {
-            $contexttosearch = get_context_instance(CONTEXT_COURSE, $restore->course_id);
-        // if we know the target category, check capability on it
-        } else if (!empty($restore->restore_restorecatto)) {
-            $contexttosearch = get_context_instance(CONTEXT_COURSECAT, $restore->restore_restorecatto);
-        } else {
-            $contexttosearch = get_context_instance(CONTEXT_SYSTEM);
-        }
-        $cancreateroles = has_capability('moodle/role:manage', get_context_instance(CONTEXT_SYSTEM));
-        $canassignroles = has_capability('moodle/role:assign', $contexttosearch);
-        $canoverridecaps= has_capability('moodle/role:override', $contexttosearch) || has_capability('moodle/role:safeoverride', $contexttosearch);
-        if (!empty($restore->rolesmapping)) {
-            foreach ($restore->rolesmapping as $originalrole => $targetrole) {
-                // First, if new role is selected, check used really can do that
-                if (empty($targetrole) && !$cancreateroles) {
-                    $messages[] = get_string('restorecannotcreateorassignroles');
-                    $show_continue_button = false;
-                    break;
-                }
-                // Now, check that the target role is available for role assignments
-                if (!empty($targetrole) && !$canassignroles) {
-                    $messages[] = get_string('restorecannotassignroles');
-                    $show_continue_button = false;
-                    break;
-                }
-                // Now, check that the target role is available for capability overrides
-                if (!empty($targetrole) && !$canoverridecaps) {
-                    $messages[] = get_string('restorecannotoverrideperms');
-                    $show_continue_button = false;
-                    break;
-                }
-            }
-        }
-
-    /// If restoring users and backup has mnet remote users and we are restoring to different site, forbid restore to non-admins. MDL-17009
-        if ($restore->users != 2 &&                                                   /// If restoring users
-            !empty($info->mnet_remoteusers) && $info->mnet_remoteusers === 'true'  && /// and backup contains remote users
-            !backup_is_same_site($info)) {                              /// and backup is being restored to different site
-
-        /// If user is admin (by 'moodle/user:create' cap), warn about conversion to local auth if missing mnet hosts and continue restore
-            if (has_capability('moodle/user:create', get_context_instance(CONTEXT_SYSTEM))) {
-                $messages[] = get_string('mnetrestore_extusers_admin', 'admin');
-                $show_continue_button = true;
-
-        /// else, notify about the thing (suggesting to ask admin) and stop restore
-            } else {
-                $messages[] = get_string('mnetrestore_extusers_noadmin', 'admin');
-                $show_continue_button = false;
-            }
-        }
-
-        //Save the restore session object
-        $SESSION->restore = $restore;
-
-        // Calculate all session objects checksum and store them in session too
-        // so restore_execute.html (used by manual restore and import) will be
-        // able to detect any problem in session info.
-        restore_save_session_object_checksums($restore, $info, $course_header);
-
-        echo "<div style='text-align:center'>";
-
-    /// Printout messages
-        foreach ($messages as $message) {
-            echo '<p>' . $message . '</p>';
-        }
-
-    /// Warning and button
-        if ($show_continue_button) {
-            //Print the continue button to execute the restore NOW !!!!
-            //All is prepared !!!
-            $hidden["launch"]             = "execute";
-            $hidden["file"]               =  $file;
-            $hidden["id"]                 =  $id;
-            $hidden["sesskey"]            =  sesskey();
-            print_string('longtimewarning','admin');
-
-
-        /// Restore button
-            echo $OUTPUT->single_button(new moodle_url("restore.php", $hidden), get_string("restorecoursenow"));
-        }
-        echo "</div>";
-
-    //If we are here. Something must be wrong. Debug !!!
-    } else {
-        print_object($restore);
-        print_object($info);
-        print_object($course_header);
-        print_error('error');
-    }
-
diff --git a/backup/restore_execute.html b/backup/restore_execute.html
deleted file mode 100644 (file)
index 4f051c1..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-    //This page receives the required info and executes the restore
-    //with the parameters suplied. Whe finished, delete temporary
-    //data from backup_tables and temp directory
-
-    //Get objects from session
-    if ($SESSION) {
-        $info = $SESSION->info;
-        $course_header = $SESSION->course_header;
-        $restore = $SESSION->restore;
-
-        // Validate objects from session by checking their checksums
-        $status = false;
-        if (isset($SESSION->restore_checksums)) {
-            $checksums = $SESSION->restore_checksums;
-            if (isset($checksums['info']) && $checksums['info'] == md5(serialize($info)) &&
-                isset($checksums['course_header']) && $checksums['course_header'] == md5(serialize($course_header)) &&
-                isset($checksums['restore']) && $checksums['restore'] == md5(serialize($restore))) {
-
-                $status = true; // All session checksums were or, we can rely on that to continue restoring
-            }
-        }
-        if(!$status) { // Something was wrong checking objects from session, abort with error
-            print_error('restorechecksumfailed');
-        }
-    }
-
-    //Add info->original_wwwroot to $restore to be able to use it in all the restore process
-    //(mainly when decoding internal links)
-    $restore->original_wwwroot = $info->original_wwwroot;
-    // Copy $info->original_siteidentifier, is present, so backup_is_same_site can work.
-    if (isset($info->original_siteidentifier)) {
-        $restore->original_siteidentifier = $info->original_siteidentifier;
-    }
-    //Add info->backup_version to $restore to be able to detect versions in the restore process
-    //(to decide when to convert wiki texts to markdown...)
-    $restore->backup_version = $info->backup_backup_version;
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    //Check admin
-    if (!empty($id)) {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
-            if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', $loginurl);
-            } else {
-                if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $to))
-                    && !has_capability('moodle/restore:restoretargetimport',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', $loginurl);
-                }
-            }
-        }
-    } else {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', $loginurl);
-        }
-    }
-
-    //Check site
-    $site = get_site();
-    $errorstr = '';
-
-    $status = restore_execute($restore,$info,$course_header,$errorstr);
-
-    if (!$status) {
-        print_error ("cannotrestore");
-    }
-
-    if (empty($restore->importing)) {
-        //Print final message
-        echo $OUTPUT->box(get_string("restorefinished"));
-    } else {
-        echo $OUTPUT->box(get_string("importdatafinished"));
-        $file = $CFG->dataroot . '/'
-            . $SESSION->import_preferences->backup_course
-            . '/backupdata/' . $SESSION->import_preferences->backup_name;
-        if (is_readable($file)) {
-            unlink($file);
-        }
-        else {
-            error_log("import course data: couldn't unlink $file");
-        }
-        unset($SESSION->restore);
-    }
-    echo $OUTPUT->continue_button("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
diff --git a/backup/restore_form.html b/backup/restore_form.html
deleted file mode 100644 (file)
index 0e29385..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-<?php
-    //This page prints the restore form to select everything yo want
-    //to restore. Form is dinamically buid, depending of "info" object
-    //that contains the backup contents and depending of every mod
-    //capabilities.
-
-    global $DB;
-
-    //Get objects from session
-    if (!($info = $SESSION->info)) {
-      print_error('sessionmissing' ,'debug', '', 'info');
-    }
-    if (!($course_header = $SESSION->course_header)) {
-      print_error('sessionmissing' ,'debug', '', 'course_header');
-    }
-
-    $restore_gradebook_history =  optional_param('restore_gradebook_history', 0, PARAM_INT);
-
-    //Check that we have all we need
-    //backup_unique_code
-    $backup_unique_code = required_param('backup_unique_code', PARAM_INT);
-    //file
-    $file = required_param('file', PARAM_PATH);
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    //Init restoreuserinfo
-    $restoreuserinfo = false;
-
-    //Check admin
-    if (!empty($id)) {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
-            print_error('cannotuseadminadminorteacher', '', $loginurl);
-        }
-        $restoreuserinfo = has_capability('moodle/restore:userinfo', get_context_instance(CONTEXT_COURSE, $id));
-    } else {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error('cannotuseadmin', '', $loginurl);
-        }
-        $restoreuserinfo = has_capability('moodle/restore:userinfo', get_context_instance(CONTEXT_SYSTEM));
-    }
-
-    //Check site
-    $site = get_site();
-
-    //Checks for the required files/functions to restore every mod
-    $count = 0;
-    if ($allmods = $DB->get_records("modules") ) {
-        foreach ($allmods as $mod) {
-            $modname = $mod->name;
-            $modfile = "$CFG->dirroot/mod/$modname/restorelib.php";
-            $modrestore = $modname."_restore_mods";
-            if (file_exists($modfile)) {
-               include_once($modfile);
-               if (function_exists($modrestore)) {
-                   $var = "exists_".$modname;
-                   $$var = true;
-                   $count++;
-               }
-            }
-            //Check data
-            //Check module info
-            $var = "restore_".$modname;
-            if (!isset($$var)) {
-                $$var = 1;
-            }
-            //Check include user info
-            $var = "restore_user_info_".$modname;
-            if (!isset($$var) && $restoreuserinfo) {
-                $$var = 1;
-            } else {
-                $$var = 0;
-            }
-        }
-    }
-
-    if (!isset($restore_users)) {
-        $restore_users = 1;
-    }
-
-    if (!isset($restore_groups)) {
-        $restore_groups = RESTORE_GROUPS_GROUPINGS;
-    }
-
-    if (!isset($restore_logs)) {
-        $restore_logs = 1;
-    }
-
-    if (!isset($restore_user_files)) {
-        $restore_user_files = 1;
-    }
-
-    if (!isset($restore_course_files)) {
-        $restore_course_files = 1;
-    }
-
-    if (!isset($restore_site_files)) {
-        $restore_site_files = 1;
-    }
-
-    if (!isset($restore_messages)) {
-        $restore_messages = 1;
-    }
-
-    if (!isset($restore_blogs)) {
-        $restore_blogs = 1;
-    }
-
-    $cancreatecourses = user_can_create_courses();
-    if (!isset($restore_restoreto)) {
-        if (!$cancreatecourses) {
-            $restore_restoreto = RESTORETO_CURRENT_ADDING;
-        } else {
-            $restore_restoreto = RESTORETO_NEW_COURSE;
-        }
-    }
-
-    if (!isset($course_header->category->id)) {
-        $course_header->category->id = 0;
-    }
-
-    if(!isset($form1->startdate)) {
-        $form1->startdate = $course_header->course_startdate; //$course_header->course_startdate;
-    }
-
-    if (empty($form1->shortname)) {
-       $form1->shortname = $course_header->course_shortname; //'_shortname'; //$course_header->course_shortname;
-    }
-
-    if (empty($form1->fullname)) {
-      $form1->fullname = $course_header->course_fullname; // '_fullname';   //$course_header->course_fullname;
-    }
-
-    if ($count == 0) {
-        notice("No restorable modules are installed!");
-    }
-
-?>
-
-<script type="text/javascript">
-<!--
-function selectItemInMenuByName(formId, menuName, selectIndex ) {
-    myForm = document.getElementById(formId)
-    for (i=0,n=myForm.elements.length;i<n;i++) {
-        myLen = menuName.length;
-        myName = myForm.elements[i].name;
-        myType = myForm.elements[i].type;
-        if (myName.substring(0,myLen) == menuName && myType == "select-one") {
-            myForm.elements[i].options[selectIndex].selected = true;
-        }
-    }
-}
-
-function selectItemInRadioByName(formId, radioName, selectIndex ) {
-    myForm = document.getElementById(formId)
-    for (i=0,n=myForm.elements.length;i<n;i++) {
-        myLen = radioName.length;
-        myName = myForm.elements[i].name;
-        myType = myForm.elements[i].type;
-        if (myName.substring(0,myLen) == radioName && myType == "radio") {
-            myRadioGroup = myForm.elements[myName];
-            myRadioGroup[selectIndex].checked = true;
-        }
-    }
-}
-
-function selectItemInCheckboxByName(formId, checkName, checked ) {
-    myForm = document.getElementById(formId)
-    for (i=0,n=myForm.elements.length;i<n;i++) {
-        myLen = checkName.length;
-        myName = myForm.elements[i].name;
-        myType = myForm.elements[i].type;
-        if (myName.substring(0,myLen) == checkName && myType == "checkbox") {
-            myForm.elements[i].checked = checked;
-        }
-    }
-}
--->
-</script>
-
-<form id="form1" method="post" action="restore.php">
-<div>
-<table cellpadding="5" class="boxaligncenter">
-<?php
-
-    //First, course destination
-    //Print the full tr
-    echo "<tr>";
-    echo "<td align=\"right\"><b>";
-    echo '<label for="menurestore_restoreto">'.get_string ('restoreto').'</label>';
-    echo "</b>";
-    echo "</td><td colspan=\"3\">";
-
-    // permission should have been checked already
-
-    //TODO: use better function which includes all courses for admins
-    $mycourses = get_user_courses_bycap($USER->id, 'moodle/restore:restorecourse');
-
-    // if the user can restore to current course, grant the "current" options
-    if (has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))){
-        $restore_restoreto_options[RESTORETO_CURRENT_DELETING] = get_string("currentcoursedeleting");
-        $restore_restoreto_options[RESTORETO_CURRENT_ADDING] = get_string("currentcourseadding");
-    }
-
-    // if user can create any course, grant the "new course" option
-    if ($cancreatecourses) {
-        $restore_restoreto_options[RESTORETO_NEW_COURSE] = get_string("newcourse");
-    }
-
-    // if the user can restore to 2 or more courses (or to just 1 but different from current), grant the "existing" options
-    if (count($mycourses) > 1 || (count($mycourses) == 1 && $mycourses[0]->id != $id)) {
-        $restore_restoreto_options[RESTORETO_EXISTING_DELETING] = get_string("existingcoursedeleting");
-        $restore_restoreto_options[RESTORETO_EXISTING_ADDING] = get_string("existingcourseadding");
-    }
-
-/// Acummulator for hidden options and proper XHTML output
-    $hidden_options = '';
-
-    echo html_writer::select($restore_restoreto_options, "restore_restoreto", $restore_restoreto, false);
-    echo "</td></tr>";
-    if ($cancreatecourses) {  //display these fields conditionally
-
-        // find the list of cates user can edit
-        echo "<tr valign=\"top\" >";
-        echo "<td align=\"right\">";
-        echo '<label for="menurestore_restorecatto">'.get_string ('category').'</label>';
-        echo "</td>";
-        echo "<td>";
-        // Get the list of categories where the user can create courses
-        make_categories_list($categories, $parents, 'moodle/course:create');
-        $category_default = null;
-        // Best default 1: restoring in same site, use category of original course if available
-        if (backup_is_same_site($info) &&
-            !empty($course_header->category->id) &&
-            array_key_exists($course_header->category->id, $categories)) {
-            $category_default = $course_header->category->id;
-        // Best default 2: restore to the category of the course we are restoring from if available
-        } else {
-            $fromcat = $DB->get_field('course', 'category', array('id' => $id));
-            if (!empty($fromcat) &&
-                array_key_exists($fromcat, $categories)) {
-                $category_default = $fromcat;
-            }
-        }
-        echo html_writer::select($categories, 'restore_restorecatto', $category_default, false);
-        echo "</td>";
-        echo "</tr>";
-
-        echo "<tr valign=\"top\" >";
-        echo "<td align=\"right\">";
-        echo '<label for="shortnamefield">'.get_string ('shortname').'</label>';
-        echo "</td>";
-        echo "<td><input type=\"text\" id=\"shortnamefield\" name=\"shortname\" maxlength=\"100\"  size=\"20\" value=\"".s($form1->shortname)."\" alt=\"".get_string("shortname")."\"  />" ;
-        echo $OUTPUT->help_icon('shortnamecourse'));
-        if (isset($err["shortname"])) echo $OUTPUT->error_text($err["shortname"]);
-        echo "</td>";
-        echo "</tr>";
-        echo "<tr valign=\"top\" >";
-        echo "<td align=\"right\">";
-        echo '<label for="fullnamefield">'.get_string ('fullname').'</label>';
-        echo "</td>";
-        echo "<td><input type=\"text\" id=\"fullnamefield\" name=\"fullname\" maxlength=\"254\" size=\"50\" value=\"".s($form1->fullname)."\" alt=\" ".get_string("fullname")."\"  />" ;
-        echo $OUTPUT->help_icon('fullnamecourse');
-        if (isset($err["fullname"])) echo $OUTPUT->error_text($err["fullname"]);
-        echo"</td></tr>";
-    } else {
-        // nothing to show here if the user cannot create users
-    }
-
-    // If user can roll dates (in any course is enough for now) show the roll dates option.
-    // Important: The final restore check step will validate, once we know the final category/course
-    // where the restore is happening, if the user is really capable of rolling dates there, noticing
-    // and disabling roll if not allowed.
-    if (restore_user_can_roll_dates()) {
-        echo "<tr valign=\"top\"> ";
-        echo "<td align=\"right\"> ";
-        print_string("startdate");
-        echo "</td><td>";
-    /// Show the roll dates option only if the backup course has a start date
-    /// (some formats like main page, social..., haven't it and rolling dates
-    /// from 0 produces crazy dates. MDL-10125
-        if ($form1->startdate) {
-            $dayselector = html_writer::select_time('days', "startday", $form1->startdate);
-            $monthselector = html_writer::select_time('months', "startmonth", $form1->startdate);
-            $yearselector = html_writer::select_time('years', "startyear", $form1->startdate);
-
-            echo $dayselector . $monthselector . $yearselector;
-            echo $OUTPUT->help_icon('startdate'));
-        } else {
-            print_string('notavailable');
-            echo '<input type="hidden" name="startyear" value="0" />';
-            echo '<input type="hidden" name="startmonth" value="0" />';
-            echo '<input type="hidden" name="startday" value="0" />';
-        }
-        echo "</td></tr>";
-    } else {
-    /// If user lacks the moodle/restore:rolldates completely, prevent any change in startyear/month/day (so restore won't perform any roll)
-        echo '<input type="hidden" name="startyear" value="0" />';
-        echo '<input type="hidden" name="startmonth" value="0" />';
-        echo '<input type="hidden" name="startday" value="0" />';
-    }
-    //Line
-    echo "<tr><td colspan=\"4\"><hr /></td></tr>";
-    //Now, check modules and info and show posibilities
-    if ($allmods = $DB->get_records("modules") ) {
-        //Print option to select/deselect everything with 1 click.
-        echo "<tr>";
-        echo "<td align=\"right\">";
-        echo '<b>'.get_string("include")."</b>";
-        echo "</td><td>";
-        echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', true);\">".
-             get_string("all")."</a>/";
-        echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', false);\">".
-             get_string("none")."</a>";
-        echo "</td>";
-        if ($restoreuserinfo) {
-            echo "<td align=\"right\">";
-            echo '<b>&nbsp;</b>';
-            echo "</td><td>";
-            echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', true);\">".
-                 get_string("all")."</a>/";
-            echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', false);\">".
-                 get_string("none")."</a>";
-            echo "</td>";
-        } else {
-            echo "<td colspan=\"2\">&nbsp;</td>";
-        }
-        echo "</tr>";
-        echo "<tr><td colspan=\"4\"><hr /></td></tr>";
-        $currentrow = 0;
-        $nonrestmod = '';
-        foreach ($allmods as $mod) {
-            $modname = $mod->name;
-            $modrestore = $modname."_restore_mods";
-            //If exists the lib & function
-            $exist = "exists_".$modname;
-            $restore_var = "restore_".$modname;
-            $user_info_var = "restore_user_info_".$modname;
-            if (isset($$exist)) {
-                if ($$exist) {
-                    //Now check that we have that module info in the backup file
-                    if (isset($info->mods[$modname]) && $info->mods[$modname]->backup == "true") {
-                        //Print the full tr
-                        echo "<tr class=\"r".$currentrow."\">";
-                        echo "<td align=\"right\">&nbsp;";
-                        echo "</td><td>";
-                        $restore_options[1] = get_string("yes");
-                        $restore_options[0] = get_string("no");
-                        //Print the checkbox
-                        print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'restore_'.$modname.'\',this.checked)');
-                        //If backup contains user data, then show menu, else fix it to
-                        //without user data
-                        echo "</td><td align=\"right\">&nbsp;";
-                        echo "</td><td>";
-                        if ($info->mods[$modname]->userinfo == "true" && $restoreuserinfo) {
-                            $restore_user_options[1] = get_string("yes");
-                            $restore_user_options[0] = get_string("no");
-                            print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'restore_user_info_'.$modname.'\',this.checked)');
-                        } else {
-                            //Module haven't userdata
-                            echo get_string("withoutuserdata");
-                            echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
-                        }
-                        echo "</td></tr>";
-                        if (isset($info->mods[$modname]->instances)) {
-                            $instances = $info->mods[$modname]->instances;
-                        }
-                        if (!empty($instances) && is_array($instances)) {
-                            echo '<tr><td></td><td colspan="3"><table class="restore-form-instances">';
-                            foreach ($instances as $instance) {
-                                echo '<tr><td>';
-                                $var = 'restore_'.$modname.'_instance_'.$instance->id;
-                                $$var = optional_param($var,1, PARAM_CLEAN);
-                                print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'restore_'.$modname.'\'].checked=1;');
-                                echo '</td><td align="right">&nbsp;';
-                                $var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
-                                $$var = optional_param($var,1, PARAM_CLEAN);
-                                if (!empty($info->mods[$modname]->instances) && ($info->mods[$modname]->instances[$instance->id]->userinfo == 'true') && $restoreuserinfo) {
-                                    print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'restore_user_info_'.$modname.'\'].checked=1;');
-                                } else {
-                                    echo '<input type="hidden" name="'.$var.'" value="0" />';
-                                }
-                                echo '</td></tr>';
-                            }
-                            echo '</table></td></tr>';
-                        }
-                    } else {
-                        //Module isn't restorable
-                        $nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
-                        $nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
-                    }
-                } else {
-                    //Module isn't restorable
-                    $nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
-                    $nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
-                }
-            } else {
-                //Module isn't restorable
-                $nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
-                $nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
-            }
-            $currentrow = ($currentrow + 1) % 2;
-        }
-        //Line
-        echo "<tr><td colspan=\"4\">$nonrestmod<hr /></td></tr>";
-
-        //Now print the Users tr
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menurestore_users">'.get_string ("users").'</label>';
-        echo "</b></td><td colspan=\"2\">";
-        //If some user is present in the backup file
-        if (($info->backup_users == "all" or $info->backup_users == "course") and $restoreuserinfo) {
-            $user_options = array();
-            //If all users are in the backup file and user has 'moodle/restore:restorecourse' at system level
-            if ($info->backup_users == "all" and has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
-                $user_options[0] = get_string("all");
-            }
-            $user_options[1] = get_string("course");
-            $user_options[2] = get_string("none");
-            echo html_writer::select($user_options, "restore_users", $restore_users, false);
-        } else {
-            echo get_string("none");
-            echo "<input type=\"hidden\" id=\"menurestore_users\" name=\"restore_users\" value=\"2\" />";
-
-        }
-        echo "</td></tr>";
-
-        //Now print the Groups tr (assume there is no $info->backup_groups)
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menurestore_groups">'.get_string ("groups").'</label>'.$helplink;
-        echo "</b></td><td colspan=\"2\">";
-        $group_options[RESTORE_GROUPS_NONE] = get_string('none');
-        $group_options[RESTORE_GROUPS_ONLY] = get_string('groupsonly', 'group');
-        $group_options[RESTORE_GROUPINGS_ONLY] = get_string('groupingsonly', 'group');
-        $group_options[RESTORE_GROUPS_GROUPINGS] = get_string('groupsgroupings', 'group'); //all.
-        echo html_writer::select($group_options, 'restore_groups', $restore_groups, false);
-        echo "</td></tr>";
-
-        //Now print the Logs tr
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menurestore_logs">'.get_string ("logs").'</label>';
-        echo "</b></td><td colspan=\"2\">";
-        //If logs are in the backup file, show menu, else fixed to no
-        if ($info->backup_logs == "true" and $restoreuserinfo) {
-            $log_options = array();
-            $log_options[0] = get_string("no");
-            $log_options[1] = get_string("yes");
-            echo html_writer::select($log_options, "restore_logs", $restore_logs, false);
-        } else {
-            echo get_string("no");
-            echo "<input type=\"hidden\" id=\"menurestore_logs\" name=\"restore_logs\" value=\"0\" />";
-        }
-        echo "</td></tr>";
-
-        //Now print the User Files tr
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menurestore_user_files">'.get_string ("userfiles").'</label>';
-        echo "</b></td><td colspan=\"2\">";
-        //If user files are in the backup file, show menu, else fixed to no
-        if ($info->backup_user_files == "true" and $restoreuserinfo) {
-            $user_file_options = array();
-            $user_file_options[0] = get_string("no");
-            $user_file_options[1] = get_string("yes");
-            echo html_writer::select($user_file_options, "restore_user_files", $restore_user_files, false);
-        } else {
-            echo get_string("no");
-            echo "<input type=\"hidden\" id=\"menurestore_user_files\" name=\"restore_user_files\" value=\"0\" />";
-        }
-        echo "</td></tr>";
-
-        //Now print the Course Files tr
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menurestore_course_files">'.get_string ("coursefiles").'</label>';
-        echo "</b></td><td colspan=\"2\">";
-        echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
-        echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
-        //If course files are in the backup file, show menu, else fixed to no
-        if ($info->backup_course_files == "true") {
-            $course_file_options = array();
-            $course_file_options[0] = get_string("no");
-            $course_file_options[1] = get_string("yes");
-            echo html_writer::select($course_file_options, "restore_course_files", $restore_course_files, false);
-        } else {
-            echo get_string("no");
-            echo "<input type=\"hidden\" id=\"menurestore_course_files\" name=\"restore_course_files\" value=\"0\" />";
-        }
-        echo "</td></tr>";
-
-
-        //Now print the Site Files tr
-        echo "<tr>";
-        echo "<td align=\"right\" colspan=\"2\"><b>";
-        echo '<label for="menurestore_site_files">'.get_string ("sitefiles").'</label>';
-        echo "</b></td><td colspan=\"2\">";
-        //If site files are in the backup file, show menu, else fixed to no
-        if (isset($info->backup_site_files) && $info->backup_site_files == "true") {
-            $site_file_options = array();
-            $site_file_options[0] = get_string("no");
-            $site_file_options[1] = get_string("yes");
-            echo html_writer::select($site_file_options, "restore_site_files", $restore_site_files, false);
-        } else {
-            echo get_string("no");
-            echo "<input type=\"hidden\" id=\"menurestore_site_files\" name=\"restore_site_files\" value=\"0\" />";
-        }
-        echo "</td></tr>";
-
-        // do you want grade histories to be restored?
-        if (empty($CFG->disablegradehistory) and $restoreuserinfo) {
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menurestore_gradebook_history">'.get_string ('gradebookhistories', 'grades').'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            if (isset($info->gradebook_histories) && $info->gradebook_histories == "true") {
-                $gradebook_history_options = array();
-                $gradebook_history_options[0] = get_string("no");
-                $gradebook_history_options[1] = get_string("yes");
-                echo html_writer::select($gradebook_history_options, "restore_gradebook_history", $restore_gradebook_history, false);
-            } else {
-                echo get_string("no");
-                echo "<input type=\"hidden\" id=\"menurestore_gradebook_history\" name=\"restore_gradebook_history\" value=\"0\" />";
-            }
-            echo "</td></tr>";
-        } else {
-            $hidden_options .= '<input type="hidden" name="restore_gradebook_history" value="0" />';
-        }
-
-        //This tr is slighty different. Everything becomes hidden if
-        //we haven't messages is the backup, to avoid confusions to users.
-        //If messages are in the backup file, show menu, else fixed to no and show nothing
-        //Also, messaging must be enabled in the destination site
-        if (isset($info->backup_messages) && $info->backup_messages == "true" && !empty($CFG->messaging) and $restoreuserinfo) {
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menurestore_messages">'.get_string ('messages', 'message').'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $message_options = array();
-            $message_options[0] = get_string("no");
-            $message_options[1] = get_string("yes");
-            echo html_writer::select($message_options, "restore_messages", $restore_messages, false);
-            echo "</td></tr>";
-        } else {
-            $hidden_options .= '<input type="hidden" name="restore_messages" value="0" />';
-        }
-
-        //This tr is slighty different. Everything becomes hidden if
-        //we haven't blogs is the backup, to avoid confusions to users.
-        //If blogs are in the backup file, show menu, else fixed to no and show nothing
-        //Also, blogs must be enabled in the destination site
-        if (isset($info->backup_blogs) && $info->backup_blogs == "true" && !empty($CFG->bloglevel) and $restoreuserinfo) {
-            echo "<tr>";
-            echo "<td align=\"right\" colspan=\"2\"><b>";
-            echo '<label for="menurestore_blogs">'.get_string ('blogs', 'blog').'</label>';
-            echo "</b></td><td colspan=\"2\">";
-            $blog_options = array();
-            $blog_options[0] = get_string("no");
-            $blog_options[1] = get_string("yes");
-            echo html_writer::select($blog_options, "restore_blogs", $restore_blogs, false);
-            echo "</td></tr>";
-        } else {
-            $hidden_options .= '<input type="hidden" name="restore_blogs" value="0" />';
-        }
-
-    }
-?>
-</table>
-
diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html
deleted file mode 100644 (file)
index 3a92521..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-    //This page copies th zip to the temp directory,
-    //unzip it, check that it is a valid backup file
-    //inform about its contents and fill all the necesary
-    //variables to continue with the restore.
-
-    //Checks we have the file variable
-    if (!isset($file)) {
-        print_error('nofile');
-    }
-
-    //Check login
-    require_login();
-
-    $loginurl = get_login_url();
-
-    //Check admin
-    if (!empty($id)) {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
-            if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', $loginurl);
-            } else {
-                if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $to))
-                    && !has_capability('moodle/restore:restoretargetimport',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', $loginurl);
-                }
-            }
-        }
-    } else {
-        if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', $loginurl);
-        }
-    }
-
-    //Check site
-    $site = get_site();
-
-    $errorstr = '';
-    if (!empty($SESSION->restore->importing)) {
-        define('RESTORE_SILENTLY',true);
-    }
-    $status = restore_precheck($id,$file,$errorstr);
-
-    if (!$status) {
-        print_error("pleasereport");
-    }