Commit | Line | Data |
---|---|---|
c6cc9726 EL |
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 | |
3930e8b8 EL |
37 | const TYPE_1ACTIVITY = 'activity'; |
38 | const TYPE_1SECTION = 'section'; | |
39 | const TYPE_1COURSE = 'course'; | |
c6cc9726 EL |
40 | |
41 | // Backup format | |
42 | const FORMAT_MOODLE = 'moodle2'; | |
f60f4666 | 43 | const FORMAT_MOODLE1 = 'moodle1'; |
c6cc9726 | 44 | const FORMAT_IMSCC = 'imscc'; |
f60f4666 | 45 | const FORMAT_UNKNOWN = 'unknown'; |
c6cc9726 EL |
46 | |
47 | // Interactive | |
48 | const INTERACTIVE_YES = true; | |
49 | const INTERACTIVE_NO = false; | |
50 | ||
51 | // Predefined modes (purposes) of the backup | |
bac233d3 SH |
52 | const MODE_GENERAL = 10; |
53 | const MODE_IMPORT = 20; | |
54 | const MODE_HUB = 30; | |
55 | const MODE_SAMESITE = 40; | |
56 | const MODE_AUTOMATED = 50; | |
c6cc9726 | 57 | |
754a102b EL |
58 | // Target (new/existing/current/adding/deleting) |
59 | const TARGET_CURRENT_DELETING = 0; | |
60 | const TARGET_CURRENT_ADDING = 1; | |
61 | const TARGET_NEW_COURSE = 2; | |
62 | const TARGET_EXISTING_DELETING= 3; | |
63 | const TARGET_EXISTING_ADDING = 4; | |
64 | ||
c6cc9726 EL |
65 | // Execution mode |
66 | const EXECUTION_INMEDIATE = 1; | |
67 | const EXECUTION_DELAYED = 2; | |
68 | ||
69 | // Status of the backup_controller | |
70 | const STATUS_CREATED = 100; | |
f60f4666 EL |
71 | const STATUS_REQUIRE_CONV= 200; |
72 | const STATUS_PLANNED = 300; | |
73 | const STATUS_CONFIGURED = 400; | |
74 | const STATUS_SETTING_UI = 500; | |
dc5a2f8a EL |
75 | const STATUS_NEED_PRECHECK=600; |
76 | const STATUS_AWAITING = 700; | |
77 | const STATUS_EXECUTING = 800; | |
78 | const STATUS_FINISHED_ERR= 900; | |
79 | const STATUS_FINISHED_OK =1000; | |
c6cc9726 EL |
80 | |
81 | // Logging levels | |
82 | const LOG_DEBUG = 50; | |
83 | const LOG_INFO = 40; | |
84 | const LOG_WARNING = 30; | |
85 | const LOG_ERROR = 20; | |
86 | const LOG_NONE = 10; | |
87 | ||
88 | // Some constants used to identify some helpfull processor variables | |
89 | // (using negative numbers to avoid any collision posibility | |
90 | // To be used when defining backup structures | |
91 | const VAR_COURSEID = -1; // To reference id of course in a processor | |
92 | const VAR_SECTIONID = -11; // To reference id of section in a processor | |
93 | const VAR_ACTIVITYID = -21; // To reference id of activity in a processor | |
94 | const VAR_MODID = -31; // To reference id of course_module in a processor | |
95 | const VAR_MODNAME = -41; // To reference name of module in a processor | |
96 | const VAR_BLOCKID = -51; // To reference id of block in a processor | |
97 | const VAR_BLOCKNAME = -61; // To reference name of block in a processor | |
98 | const VAR_CONTEXTID = -71; // To reference context id in a processor | |
99 | const VAR_PARENTID = -81; // To reference the first parent->id in a backup structure | |
100 | ||
101 | // Used internally by the backup process | |
102 | const VAR_BACKUPID = -1001; // To reference the backupid being processed | |
103 | const VAR_BASEPATH = -1011; // To reference the dir where the file is generated | |
104 | ||
f60f4666 EL |
105 | // Type of operation |
106 | const OPERATION_BACKUP ='backup'; // We are performing one backup | |
107 | const OPERATION_RESTORE ='restore';// We are performing one restore | |
108 | ||
c6cc9726 | 109 | // Version (to keep CFG->backup_version (and release) updated automatically) |
295474bd EL |
110 | const VERSION = 2010111800; |
111 | const RELEASE = '2.0'; | |
c6cc9726 EL |
112 | } |
113 | ||
114 | /* | |
115 | * Exception class used by all the @backup stuff | |
116 | */ | |
ce937f99 | 117 | abstract class backup_exception extends moodle_exception { |
c6cc9726 EL |
118 | |
119 | public function __construct($errorcode, $a=NULL, $debuginfo=null) { | |
120 | parent::__construct($errorcode, 'error', '', $a, null, $debuginfo); | |
121 | } | |
122 | } |