[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/backup/ -> backup.class.php (source)

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * @package moodlecore
  20   * @subpackage backup
  21   * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  /**
  26   * Abstract class defining common stuff to be used by the backup stuff
  27   *
  28   * This class defines various constants and methods that will be used
  29   * by different classes, all related with the backup process. Just provides
  30   * the top hierarchy of the backup controller/worker stuff.
  31   *
  32   * TODO: Finish phpdocs
  33   */
  34  abstract class backup implements checksumable {
  35  
  36      // Backup type
  37      const TYPE_1ACTIVITY = 'activity';
  38      const TYPE_1SECTION  = 'section';
  39      const TYPE_1COURSE   = 'course';
  40  
  41      // Backup format
  42      const FORMAT_MOODLE  = 'moodle2';
  43      const FORMAT_MOODLE1 = 'moodle1';
  44      const FORMAT_IMSCC1  = 'imscc1';
  45      const FORMAT_IMSCC11 = 'imscc11';
  46      const FORMAT_UNKNOWN = 'unknown';
  47  
  48      // Interactive
  49      const INTERACTIVE_YES = true;
  50      const INTERACTIVE_NO  = false;
  51  
  52      // Predefined modes (purposes) of the backup
  53      const MODE_GENERAL   = 10;
  54  
  55      /**
  56       * This is used for importing courses, and for duplicating activities.
  57       *
  58       * This mode will ensure that files are not included in the backup generation, and
  59       * during a restore they are copied from the existing file record.
  60       */
  61      const MODE_IMPORT    = 20;
  62      const MODE_HUB       = 30;
  63  
  64      /**
  65       * This mode is intended for duplicating courses and cases where the backup target is
  66       * within the same site.
  67       *
  68       * This mode will ensure that files are not included in the backup generation, and
  69       * during a restore they are copied from the existing file record.
  70       *
  71       * For creating a backup for archival purposes or greater longevity, use MODE_GENERAL.
  72       */
  73      const MODE_SAMESITE  = 40;
  74      const MODE_AUTOMATED = 50;
  75      const MODE_CONVERTED = 60;
  76  
  77      // Target (new/existing/current/adding/deleting)
  78      const TARGET_CURRENT_DELETING = 0;
  79      const TARGET_CURRENT_ADDING   = 1;
  80      const TARGET_NEW_COURSE       = 2;
  81      const TARGET_EXISTING_DELETING= 3;
  82      const TARGET_EXISTING_ADDING  = 4;
  83  
  84      // Execution mode
  85      const EXECUTION_INMEDIATE = 1;
  86      const EXECUTION_DELAYED   = 2;
  87  
  88      // Status of the backup_controller
  89      const STATUS_CREATED     = 100;
  90      const STATUS_REQUIRE_CONV= 200;
  91      const STATUS_PLANNED     = 300;
  92      const STATUS_CONFIGURED  = 400;
  93      const STATUS_SETTING_UI  = 500;
  94      const STATUS_NEED_PRECHECK=600;
  95      const STATUS_AWAITING    = 700;
  96      const STATUS_EXECUTING   = 800;
  97      const STATUS_FINISHED_ERR= 900;
  98      const STATUS_FINISHED_OK =1000;
  99  
 100      // Logging levels
 101      const LOG_DEBUG   = 50;
 102      const LOG_INFO    = 40;
 103      const LOG_WARNING = 30;
 104      const LOG_ERROR   = 20;
 105      const LOG_NONE    = 10;
 106  
 107      // Some constants used to identify some helpfull processor variables
 108      // (using negative numbers to avoid any collision posibility
 109      // To be used when defining backup structures
 110      const VAR_COURSEID   = -1;  // To reference id of course in a processor
 111      const VAR_SECTIONID  = -11; // To reference id of section in a processor
 112      const VAR_ACTIVITYID = -21; // To reference id of activity in a processor
 113      const VAR_MODID      = -31; // To reference id of course_module in a processor
 114      const VAR_MODNAME    = -41; // To reference name of module in a processor
 115      const VAR_BLOCKID    = -51; // To reference id of block in a processor
 116      const VAR_BLOCKNAME  = -61; // To reference name of block in a processor
 117      const VAR_CONTEXTID  = -71; // To reference context id in a processor
 118      const VAR_PARENTID   = -81; // To reference the first parent->id in a backup structure
 119  
 120      // Used internally by the backup process
 121      const VAR_BACKUPID   = -1001; // To reference the backupid being processed
 122      const VAR_BASEPATH   = -1011; // To reference the dir where the file is generated
 123  
 124      // Type of operation
 125      const OPERATION_BACKUP  ='backup'; // We are performing one backup
 126      const OPERATION_RESTORE ='restore';// We are performing one restore
 127  
 128      // Version and release (to keep CFG->backup_version (and release) updated automatically).
 129      /**
 130       * Usually same than major release version, this is used to mark important
 131       * point is backup when some behavior/approach channged, in order to allow
 132       * conditional coding based on it.
 133       */
 134      const VERSION = 2016052300;
 135      /**
 136       * Usually same than major release zero version, mainly for informative/historic purposes.
 137       */
 138      const RELEASE = '3.2';
 139  }
 140  
 141  /*
 142   * Exception class used by all the @backup stuff
 143   */
 144  abstract class backup_exception extends moodle_exception {
 145  
 146      public function __construct($errorcode, $a=NULL, $debuginfo=null) {
 147          parent::__construct($errorcode, 'error', '', $a, $debuginfo);
 148      }
 149  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1