Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php// This file is part of Moodle - http://moodle.org///// Moodle is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.//// Moodle is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with Moodle. If not, see <http://www.gnu.org/licenses/>./*** @package moodlecore* @subpackage backup* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later*//*** Abstract class defining common stuff to be used by the backup stuff** This class defines various constants and methods that will be used* by different classes, all related with the backup process. Just provides* the top hierarchy of the backup controller/worker stuff.** TODO: Finish phpdocs*/abstract class backup implements checksumable {// Backup typeconst TYPE_1ACTIVITY = 'activity';const TYPE_1SECTION = 'section';const TYPE_1COURSE = 'course';// Backup formatconst FORMAT_MOODLE = 'moodle2';const FORMAT_MOODLE1 = 'moodle1';const FORMAT_IMSCC1 = 'imscc1';const FORMAT_IMSCC11 = 'imscc11';const FORMAT_UNKNOWN = 'unknown';// Interactiveconst INTERACTIVE_YES = true;const INTERACTIVE_NO = false;/** Release the session during backup/restore */const RELEASESESSION_YES = true;/** Don't release the session during backup/restore */const RELEASESESSION_NO = false;// Predefined modes (purposes) of the backupconst MODE_GENERAL = 10;/*** This is used for importing courses, and for duplicating activities.** This mode will ensure that files are not included in the backup generation, and* during a restore they are copied from the existing file record.*/const MODE_IMPORT = 20;const MODE_HUB = 30;/*** This mode is intended for duplicating courses and cases where the backup target is* within the same site.** This mode will ensure that files are not included in the backup generation, and* during a restore they are copied from the existing file record.** For creating a backup for archival purposes or greater longevity, use MODE_GENERAL.*/const MODE_SAMESITE = 40;const MODE_AUTOMATED = 50;const MODE_CONVERTED = 60;/*** This mode is for asynchronous backups.* These backups will run via adhoc scheduled tasks.*/const MODE_ASYNC = 70;/*** This mode is for course copies.* It is similar to async, but identifies back up and restore tasks* as course copies.** These copies will run via adhoc scheduled tasks.*/const MODE_COPY = 80;// Target (new/existing/current/adding/deleting)const TARGET_CURRENT_DELETING = 0;const TARGET_CURRENT_ADDING = 1;const TARGET_NEW_COURSE = 2;const TARGET_EXISTING_DELETING= 3;const TARGET_EXISTING_ADDING = 4;// Execution modeconst EXECUTION_INMEDIATE = 1;const EXECUTION_DELAYED = 2;// Status of the backup_controllerconst STATUS_CREATED = 100;const STATUS_REQUIRE_CONV= 200;const STATUS_PLANNED = 300;const STATUS_CONFIGURED = 400;const STATUS_SETTING_UI = 500;const STATUS_NEED_PRECHECK=600;const STATUS_AWAITING = 700;const STATUS_EXECUTING = 800;const STATUS_FINISHED_ERR= 900;const STATUS_FINISHED_OK =1000;// Logging levelsconst LOG_DEBUG = 50;const LOG_INFO = 40;const LOG_WARNING = 30;const LOG_ERROR = 20;const LOG_NONE = 10;// Some constants used to identify some helpfull processor variables// (using negative numbers to avoid any collision posibility// To be used when defining backup structuresconst VAR_COURSEID = -1; // To reference id of course in a processorconst VAR_SECTIONID = -11; // To reference id of section in a processorconst VAR_ACTIVITYID = -21; // To reference id of activity in a processorconst VAR_MODID = -31; // To reference id of course_module in a processorconst VAR_MODNAME = -41; // To reference name of module in a processorconst VAR_BLOCKID = -51; // To reference id of block in a processorconst VAR_BLOCKNAME = -61; // To reference name of block in a processorconst VAR_CONTEXTID = -71; // To reference context id in a processorconst VAR_PARENTID = -81; // To reference the first parent->id in a backup structure// Used internally by the backup processconst VAR_BACKUPID = -1001; // To reference the backupid being processedconst VAR_BASEPATH = -1011; // To reference the dir where the file is generated// Type of operationconst OPERATION_BACKUP ='backup'; // We are performing one backupconst OPERATION_RESTORE ='restore';// We are performing one restore// Options for "Include enrolment methods" restore setting.const ENROL_NEVER = 0;const ENROL_WITHUSERS = 1;const ENROL_ALWAYS = 2;// Version and release (to keep CFG->backup_version (and release) updated automatically)./*** Usually same than major release version, this is used to mark important* point is backup when some behavior/approach channged, in order to allow* conditional coding based on it.*/const VERSION = 2024042200;/*** Usually same than major release zero version, mainly for informative/historic purposes.*/const RELEASE = '4.4';/*** Cipher to be used in backup and restore operations.*/const CIPHER = 'aes-256-cbc';/*** Bytes enforced for key, using the cypher above. Restrictive? Yes, but better than unsafe lengths*/const CIPHERKEYLEN = 32;}/** Exception class used by all the @backup stuff*/abstract class backup_exception extends moodle_exception {public function __construct($errorcode, $a=NULL, $debuginfo=null) {parent::__construct($errorcode, 'error', '', $a, $debuginfo);}}