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 | |
37 | const TYPE_1ACTIVITY = '1act'; | |
38 | const TYPE_1SECTION = '1sec'; | |
39 | const TYPE_1COURSE = '1cou'; | |
40 | ||
41 | // Backup format | |
42 | const FORMAT_MOODLE = 'moodle2'; | |
43 | const FORMAT_IMSCC = 'imscc'; | |
44 | ||
45 | // Interactive | |
46 | const INTERACTIVE_YES = true; | |
47 | const INTERACTIVE_NO = false; | |
48 | ||
49 | // Predefined modes (purposes) of the backup | |
50 | const MODE_GENERAL = 10; | |
51 | const MODE_IMPORT = 20; | |
52 | const MODE_HUB = 30; | |
53 | const MODE_SAMESITE = 40; | |
54 | ||
55 | // Execution mode | |
56 | const EXECUTION_INMEDIATE = 1; | |
57 | const EXECUTION_DELAYED = 2; | |
58 | ||
59 | // Status of the backup_controller | |
60 | const STATUS_CREATED = 100; | |
61 | const STATUS_PLANNED = 200; | |
62 | const STATUS_CONFIGURED = 300; | |
63 | const STATUS_SETTING_UI = 400; | |
64 | const STATUS_AWAITING = 500; | |
65 | const STATUS_EXECUTING = 600; | |
66 | const STATUS_FINISHED_OK = 700; | |
67 | const STATUS_FINISHED_ERR= 800; | |
68 | ||
69 | // Logging levels | |
70 | const LOG_DEBUG = 50; | |
71 | const LOG_INFO = 40; | |
72 | const LOG_WARNING = 30; | |
73 | const LOG_ERROR = 20; | |
74 | const LOG_NONE = 10; | |
75 | ||
76 | // Some constants used to identify some helpfull processor variables | |
77 | // (using negative numbers to avoid any collision posibility | |
78 | // To be used when defining backup structures | |
79 | const VAR_COURSEID = -1; // To reference id of course in a processor | |
80 | const VAR_SECTIONID = -11; // To reference id of section in a processor | |
81 | const VAR_ACTIVITYID = -21; // To reference id of activity in a processor | |
82 | const VAR_MODID = -31; // To reference id of course_module in a processor | |
83 | const VAR_MODNAME = -41; // To reference name of module in a processor | |
84 | const VAR_BLOCKID = -51; // To reference id of block in a processor | |
85 | const VAR_BLOCKNAME = -61; // To reference name of block in a processor | |
86 | const VAR_CONTEXTID = -71; // To reference context id in a processor | |
87 | const VAR_PARENTID = -81; // To reference the first parent->id in a backup structure | |
88 | ||
89 | // Used internally by the backup process | |
90 | const VAR_BACKUPID = -1001; // To reference the backupid being processed | |
91 | const VAR_BASEPATH = -1011; // To reference the dir where the file is generated | |
92 | ||
93 | // Version (to keep CFG->backup_version (and release) updated automatically) | |
94 | const VERSION = 2010022500; | |
95 | const RELEASE = '2.0 dev'; | |
96 | } | |
97 | ||
98 | /* | |
99 | * Exception class used by all the @backup stuff | |
100 | */ | |
101 | class backup_exception extends moodle_exception { | |
102 | ||
103 | public function __construct($errorcode, $a=NULL, $debuginfo=null) { | |
104 | parent::__construct($errorcode, 'error', '', $a, null, $debuginfo); | |
105 | } | |
106 | } |