[ Index ]

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

title

Body

[close]

/backup/ -> backup_execute.html (source)

   1  <?php //$Id: backup_execute.html,v 1.48.4.1 2008/05/02 04:07:29 dongsheng Exp $
   2      //This page prints the backup todo list to see everything
   3  
   4      //Check login   
   5      require_login();
   6  
   7      if (!empty($course->id)) {
   8          if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
   9              if (empty($to)) {
  10                  error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
  11              } else {
  12                  if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
  13                      error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
  14                  }
  15              }
  16          }
  17      } else {
  18          if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
  19              error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
  20          }
  21      }
  22  
  23  
  24      //Check site
  25      if (!$site = get_site()) {
  26          error("Site not found!");
  27      }
  28  
  29      $preferences = new StdClass;
  30      backup_fetch_prefs_from_request($preferences,$count,$course);
  31      //Another Info
  32      backup_add_static_preferences($preferences);
  33  
  34      if ($count == 0) {
  35          notice("No backupable modules are installed!");
  36      }
  37  
  38  
  39      if (empty($to)) {
  40          //Start the main table
  41          echo "<table cellpadding=\"5\">";
  42          
  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>";
  50          
  51          //Start the main tr, where all the backup progress is done
  52          echo "<tr>";
  53          echo "<td colspan=\"2\">";
  54          
  55          //Start the main ul
  56          echo "<ul>";
  57      }
  58  
  59      $errorstr = '';
  60      $status = backup_execute($preferences, $errorstr);
  61  
  62      //Ends th main ul
  63      echo "</ul>";
  64  
  65      //End the main tr, where all the backup is done
  66      echo "</td></tr>";
  67  
  68      //End the main table
  69      echo "</table>";
  70      
  71      if (!$status) {
  72          error ("The backup did not complete successfully", 
  73                 "$CFG->wwwroot/course/view.php?id=$course->id");
  74      }
  75  
  76      if (empty($to)) {
  77          //Print final message
  78          print_simple_box(get_string("backupfinished"),"center");
  79          print_continue("$CFG->wwwroot/files/index.php?id=".$preferences->backup_course."&amp;wdir=/backupdata");    
  80      } else {
  81          print_simple_box(get_string('importdataexported'),"CENTER");
  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          print_continue($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
  90      }
  91  
  92      $SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time.
  93  ?>


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