MDL-24203 unused string removed
[moodle.git] / backup / backup_execute.html
1 <?php
2     //This page prints the backup todo list to see everything
4     //Check login
5     require_login();
7     $loginurl = get_login_url();
9     if (!empty($course->id)) {
10         if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id))) {
11             if (empty($to)) {
12                 print_error("cannotuseadminadminorteacher", '', $loginurl);
13             } else {
14                 if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $to))) {
15                     print_error("cannotuseadminadminorteacher", '', $loginurl);
16                 }
17             }
18         }
19     } else {
20         if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
21             print_error("cannotuseadmin", '', $loginurl);
22         }
23     }
26     //Check site
27     $site = get_site();
29     $preferences = new StdClass;
30     backup_fetch_prefs_from_request($preferences,$count,$course);
31     //Another Info
32     backup_add_static_preferences($preferences);
34     if ($count == 0) {
35         notice("No backupable modules are installed!");
36     }
39     if (empty($to)) {
40         //Start the main table
41         echo "<table cellpadding=\"5\">";
43         //Now print the Backup Name tr
44         echo "<tr>";
45         echo "<td align=\"right\"><b>";
46         echo get_string("name").":";
47         echo "</b></td><td>";
48         echo $preferences->backup_name;
49         echo "</td></tr>";
51         //Start the main tr, where all the backup progress is done
52         echo "<tr>";
53         echo "<td colspan=\"2\">";
55         //Start the main ul
56         echo "<ul>";
57     }
59     $errorstr = '';
60     $status = backup_execute($preferences, $errorstr);
62     //Ends th main ul
63     echo "</ul>";
65     //End the main tr, where all the backup is done
66     echo "</td></tr>";
68     //End the main table
69     echo "</table>";
71     if (!$status) {
72         print_error('error', 'error', "$CFG->wwwroot/course/view.php?id=$course->id");
73     }
75     if (empty($to)) {
76         //Print final message
77         echo $OUTPUT->box(get_string("backupfinished"));
78         $context = get_context_instance(CONTEXT_COURSE, $course->id);
79         echo $OUTPUT->continue_button("$CFG->wwwroot/files/index.php?contextid=".$context->id."&component=backup&filearea=course&itemid=0");
80     } else {
81         echo $OUTPUT->box(get_string('importdataexported'));
82         if (!empty($preferences->backup_destination)) {
83             $filename = $preferences->backup_destination."/".$preferences->backup_name;
84         } else {
85             $filename = $preferences->backup_course."/backupdata/".$preferences->backup_name;
86         }
87         error_log($filename);
88         $SESSION->import_preferences = $preferences;
89         echo $OUTPUT->continue_button($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
90     }
92     $SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time.
93 ?>