[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/backup/ -> restore_execute.html (source)

   1  <?php //$Id: restore_execute.html,v 1.62.4.2 2008/05/02 04:07:30 dongsheng Exp $
   2      //This page receives the required info and executes the restore
   3      //with the parameters suplied. Whe finished, delete temporary
   4      //data from backup_tables and temp directory
   5  
   6      //Get objects from session
   7      if ($SESSION) {
   8          $info = $SESSION->info;
   9          $course_header = $SESSION->course_header;
  10          $restore = $SESSION->restore;
  11      }
  12  
  13      //Add info->original_wwwroot to $restore to be able to use it in all the restore process
  14      //(mainly when decoding internal links)
  15      $restore->original_wwwroot = $info->original_wwwroot;
  16      //Add info->backup_version to $restore to be able to detect versions in the restore process
  17      //(to decide when to convert wiki texts to markdown...)
  18      $restore->backup_version = $info->backup_backup_version;
  19  
  20      //Check login
  21      require_login();
  22  
  23      //Check admin
  24      if (!empty($id)) {
  25          if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
  26              if (empty($to)) {
  27                  error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
  28              } else {
  29                  if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to)) 
  30                      && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
  31                      error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
  32                  }
  33              }
  34          }
  35      } else {
  36          if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
  37              error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
  38          }
  39      }
  40  
  41      //Check site
  42      if (!$site = get_site()) {
  43          error("Site not found!");
  44      }
  45      $errorstr = '';
  46  
  47      $status = restore_execute($restore,$info,$course_header,$errorstr);
  48  
  49      if (!$status) {
  50          error ("An error has occurred and the restore could not be completed!");
  51      }
  52  
  53      if (empty($restore->importing)) {
  54          //Print final message
  55          print_simple_box(get_string("restorefinished"),"center");
  56      } else {
  57          print_simple_box(get_string("importdatafinished"),"center");
  58          $file = $CFG->dataroot . '/' 
  59              . $SESSION->import_preferences->backup_course 
  60              . '/backupdata/' . $SESSION->import_preferences->backup_name;
  61          if (is_readable($file)) {
  62              unlink($file);
  63          }
  64          else {
  65              error_log("import course data: couldn't unlink $file");
  66          }
  67          unset($SESSION->restore);
  68      }
  69      print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
  70  
  71  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7