Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 and 403]
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 /** Release the session during backup/restore */ 53 const RELEASESESSION_YES = true; 54 /** Don't release the session during backup/restore */ 55 const RELEASESESSION_NO = false; 56 57 // Predefined modes (purposes) of the backup 58 const MODE_GENERAL = 10; 59 60 /** 61 * This is used for importing courses, and for duplicating activities. 62 * 63 * This mode will ensure that files are not included in the backup generation, and 64 * during a restore they are copied from the existing file record. 65 */ 66 const MODE_IMPORT = 20; 67 const MODE_HUB = 30; 68 69 /** 70 * This mode is intended for duplicating courses and cases where the backup target is 71 * within the same site. 72 * 73 * This mode will ensure that files are not included in the backup generation, and 74 * during a restore they are copied from the existing file record. 75 * 76 * For creating a backup for archival purposes or greater longevity, use MODE_GENERAL. 77 */ 78 const MODE_SAMESITE = 40; 79 const MODE_AUTOMATED = 50; 80 const MODE_CONVERTED = 60; 81 82 /** 83 * This mode is for asynchronous backups. 84 * These backups will run via adhoc scheduled tasks. 85 */ 86 const MODE_ASYNC = 70; 87 88 /** 89 * This mode is for course copies. 90 * It is similar to async, but identifies back up and restore tasks 91 * as course copies. 92 * 93 * These copies will run via adhoc scheduled tasks. 94 */ 95 const MODE_COPY = 80; 96 97 // Target (new/existing/current/adding/deleting) 98 const TARGET_CURRENT_DELETING = 0; 99 const TARGET_CURRENT_ADDING = 1; 100 const TARGET_NEW_COURSE = 2; 101 const TARGET_EXISTING_DELETING= 3; 102 const TARGET_EXISTING_ADDING = 4; 103 104 // Execution mode 105 const EXECUTION_INMEDIATE = 1; 106 const EXECUTION_DELAYED = 2; 107 108 // Status of the backup_controller 109 const STATUS_CREATED = 100; 110 const STATUS_REQUIRE_CONV= 200; 111 const STATUS_PLANNED = 300; 112 const STATUS_CONFIGURED = 400; 113 const STATUS_SETTING_UI = 500; 114 const STATUS_NEED_PRECHECK=600; 115 const STATUS_AWAITING = 700; 116 const STATUS_EXECUTING = 800; 117 const STATUS_FINISHED_ERR= 900; 118 const STATUS_FINISHED_OK =1000; 119 120 // Logging levels 121 const LOG_DEBUG = 50; 122 const LOG_INFO = 40; 123 const LOG_WARNING = 30; 124 const LOG_ERROR = 20; 125 const LOG_NONE = 10; 126 127 // Some constants used to identify some helpfull processor variables 128 // (using negative numbers to avoid any collision posibility 129 // To be used when defining backup structures 130 const VAR_COURSEID = -1; // To reference id of course in a processor 131 const VAR_SECTIONID = -11; // To reference id of section in a processor 132 const VAR_ACTIVITYID = -21; // To reference id of activity in a processor 133 const VAR_MODID = -31; // To reference id of course_module in a processor 134 const VAR_MODNAME = -41; // To reference name of module in a processor 135 const VAR_BLOCKID = -51; // To reference id of block in a processor 136 const VAR_BLOCKNAME = -61; // To reference name of block in a processor 137 const VAR_CONTEXTID = -71; // To reference context id in a processor 138 const VAR_PARENTID = -81; // To reference the first parent->id in a backup structure 139 140 // Used internally by the backup process 141 const VAR_BACKUPID = -1001; // To reference the backupid being processed 142 const VAR_BASEPATH = -1011; // To reference the dir where the file is generated 143 144 // Type of operation 145 const OPERATION_BACKUP ='backup'; // We are performing one backup 146 const OPERATION_RESTORE ='restore';// We are performing one restore 147 148 // Options for "Include enrolment methods" restore setting. 149 const ENROL_NEVER = 0; 150 const ENROL_WITHUSERS = 1; 151 const ENROL_ALWAYS = 2; 152 153 // Version and release (to keep CFG->backup_version (and release) updated automatically). 154 /** 155 * Usually same than major release version, this is used to mark important 156 * point is backup when some behavior/approach channged, in order to allow 157 * conditional coding based on it. 158 */ 159 const VERSION = 2023042400; 160 /** 161 * Usually same than major release zero version, mainly for informative/historic purposes. 162 */ 163 const RELEASE = '4.2'; 164 165 /** 166 * Cipher to be used in backup and restore operations. 167 */ 168 const CIPHER = 'aes-256-cbc'; 169 /** 170 * Bytes enforced for key, using the cypher above. Restrictive? Yes, but better than unsafe lengths 171 */ 172 const CIPHERKEYLEN = 32; 173 } 174 175 /* 176 * Exception class used by all the @backup stuff 177 */ 178 abstract class backup_exception extends moodle_exception { 179 180 public function __construct($errorcode, $a=NULL, $debuginfo=null) { 181 parent::__construct($errorcode, 'error', '', $a, $debuginfo); 182 } 183 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body