Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/backup/backup.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 require_once('../config.php');
00019 require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
00020 require_once($CFG->dirroot . '/backup/moodle2/backup_plan_builder.class.php');
00021 
00022 
00023 $courseid = required_param('id', PARAM_INT);
00024 $sectionid = optional_param('section', null, PARAM_INT);
00025 $cmid = optional_param('cm', null, PARAM_INT);
00029 $backupid = optional_param('backup', false, PARAM_ALPHANUM);
00030 
00031 $url = new moodle_url('/backup/backup.php', array('id'=>$courseid));
00032 if ($sectionid !== null) {
00033     $url->param('section', $sectionid);
00034 }
00035 if ($cmid !== null) {
00036     $url->param('cm', $cmid);
00037 }
00038 $PAGE->set_url($url);
00039 $PAGE->set_pagelayout('admin');
00040 
00041 $id = $courseid;
00042 $cm = null;
00043 $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
00044 $type = backup::TYPE_1COURSE;
00045 if (!is_null($sectionid)) {
00046     $section = $DB->get_record('course_sections', array('course'=>$course->id, 'id'=>$sectionid), '*', MUST_EXIST);
00047     $type = backup::TYPE_1SECTION;
00048     $id = $sectionid;
00049 }
00050 if (!is_null($cmid)) {
00051     $cm = get_coursemodule_from_id(null, $cmid, $course->id, false, MUST_EXIST);
00052     $type = backup::TYPE_1ACTIVITY;
00053     $id = $cmid;
00054 }
00055 require_login($course, false, $cm);
00056 
00057 switch ($type) {
00058     case backup::TYPE_1COURSE :
00059         require_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id));
00060         $heading = get_string('backupcourse', 'backup', $course->shortname);
00061         break;
00062     case backup::TYPE_1SECTION :
00063         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
00064         require_capability('moodle/backup:backupsection', $coursecontext);
00065         if (!empty($section->name)) {
00066             $sectionname = format_string($section->name, true, array('context' => $coursecontext));
00067             $heading = get_string('backupsection', 'backup', $sectionname);
00068             $PAGE->navbar->add($sectionname);
00069         } else {
00070             $heading = get_string('backupsection', 'backup', $section->section);
00071             $PAGE->navbar->add(get_string('section').' '.$section->section);
00072         }
00073         break;
00074     case backup::TYPE_1ACTIVITY :
00075         require_capability('moodle/backup:backupactivity', get_context_instance(CONTEXT_MODULE, $cm->id));
00076         $heading = get_string('backupactivity', 'backup', $cm->name);
00077         break;
00078     default :
00079         print_error('unknownbackuptype');
00080 }
00081 
00082 if (!($bc = backup_ui::load_controller($backupid))) {
00083     $bc = new backup_controller($type, $id, backup::FORMAT_MOODLE,
00084                             backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id);
00085 }
00086 $backup = new backup_ui($bc);
00087 $backup->process();
00088 if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
00089     $backup->execute();
00090 } else {
00091     $backup->save_controller();
00092 }
00093 
00094 $PAGE->set_title($heading.': '.$backup->get_stage_name());
00095 $PAGE->set_heading($heading);
00096 $PAGE->navbar->add($backup->get_stage_name());
00097 
00098 $renderer = $PAGE->get_renderer('core','backup');
00099 echo $OUTPUT->header();
00100 if ($backup->enforce_changed_dependencies()) {
00101     echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
00102 }
00103 echo $renderer->progress_bar($backup->get_progress_bar());
00104 echo $backup->display();
00105 $backup->destroy();
00106 unset($backup);
00107 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations