3 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
20 * @subpackage backup-moodle2
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
25 // Root backup settings
28 * root generic setting to store different things without dependencies
30 class backup_generic_setting extends root_backup_setting {
31 public function process_change($setting, $ctype, $oldv) {
32 // Nothing to do, no dependencies
37 * root setting to handle backup file names (no dependencies nor anything else)
39 class backup_filename_setting extends backup_generic_setting {
43 * root setting to control if backup will include user information
44 * A lot of other settings are dependant of this (module's user info,
45 * grades user info, messages, blogs...
47 class backup_users_setting extends backup_generic_setting {
51 * root setting to control if backup will include activities or no.
52 * A lot of other settings (_included at activity levels)
53 * are dependent of this setting
55 class backup_activities_setting extends backup_generic_setting {
59 * root setting to control if backup will generate anonymized
60 * user info or no, depends of @backup_users_setting so only is
61 * availabe if the former is enabled (apart from security
64 class backup_anonymize_setting extends root_backup_setting {
65 public function process_change($setting, $ctype, $oldv) {
66 // If change detected in backup_users_setting, proceed
67 if ($setting instanceof backup_users_setting) {
69 case self::CHANGED_VALUE: // backup_users = false, this too, and locked
70 if (!$setting->get_value()) {
71 $this->set_value(false);
72 $this->set_status(self::LOCKED_BY_HIERARCHY);
75 case self::CHANGED_VISIBILITY: // backup_users not visible, this too
76 if (!$setting->get_visibility()) {
77 $this->set_visibility(false);
80 case self::CHANGED_STATUS: // backup_users unlocked, this too
81 if ($setting->get_status() == self::NOT_LOCKED) {
82 $this->set_status(self::NOT_LOCKED);
91 * root setting to control if backup will include
92 * user files or no (images, local storage), depends of @backup_users_setting
93 * exactly in the same way than @backup_anonymize_setting so we extend from it
95 class backup_user_files_setting extends backup_anonymize_setting {
96 // Nothing to do. All the logic is in backup_anonymize_setting
100 * root setting to control if backup will include
101 * role assignments or no (any level), depends of @backup_users_setting
102 * exactly in the same way than @backup_anonymize_setting so we extend from it
104 class backup_role_assignments_setting extends backup_anonymize_setting {
105 // Nothing to do. All the logic is in backup_anonymize_setting
109 * root setting to control if backup will include
110 * logs or no (any level), depends of @backup_users_setting
111 * exactly in the same way than @backup_anonymize_setting so we extend from it
113 class backup_logs_setting extends backup_anonymize_setting {
114 // Nothing to do. All the logic is in backup_anonymize_setting
118 * root setting to control if backup will include
119 * comments or no (any level), depends of @backup_users_setting
120 * exactly in the same way than @backup_anonymize_setting so we extend from it
122 class backup_comments_setting extends backup_anonymize_setting {
123 // Nothing to do. All the logic is in backup_anonymize_setting
127 * root setting to control if backup will include
128 * users completion data or no (any level), depends of @backup_users_setting
129 * exactly in the same way than @backup_anonymize_setting so we extend from it
131 class backup_userscompletion_setting extends backup_anonymize_setting {
132 // Nothing to do. All the logic is in backup_anonymize_setting
135 // Section backup settings
138 * generic section setting to pass various settings between tasks and steps
140 class backup_section_generic_setting extends section_backup_setting {
141 public function process_change($setting, $ctype, $oldv) {
142 // Nothing to do, no dependencies
147 * Setting to define if one section is included or no. Activities _included
148 * settings depend of them if available
150 class backup_section_included_setting extends section_backup_setting {
151 public function process_change($setting, $ctype, $oldv) {
152 // Nothing to do, no dependencies
157 * section backup setting to control if section will include
158 * user information or no, depends of @backup_users_setting
160 class backup_section_userinfo_setting extends section_backup_setting {
161 public function process_change($setting, $ctype, $oldv) {
162 // If change detected in backup_users_setting
163 if ($setting instanceof backup_users_setting) {
165 case self::CHANGED_VALUE: // backup_users = false, this too, and locked
166 if (!$setting->get_value()) {
167 $this->set_value(false);
168 $this->set_status(self::LOCKED_BY_HIERARCHY);
171 case self::CHANGED_VISIBILITY: // backup_users not visible, this too
172 if (!$setting->get_visibility()) {
173 $this->set_visibility(false);
176 case self::CHANGED_STATUS: // backup_users unlocked, this too
177 if ($setting->get_status() == self::NOT_LOCKED) {
178 $this->set_status(self::NOT_LOCKED);
187 // Activity backup settings
190 * generic activity setting to pass various settings between tasks and steps
192 class backup_activity_generic_setting extends activity_backup_setting {
193 public function process_change($setting, $ctype, $oldv) {
194 // Nothing to do, no dependencies
199 * activity backup setting to control if activity will
200 * be included or no, depends of @backup_activities_setting and
201 * optionally parent section included setting
203 class backup_activity_included_setting extends activity_backup_setting {
204 public function process_change($setting, $ctype, $oldv) {
205 // If change detected in backup_activities_setting or backup_section_included_setting
206 if ($setting instanceof backup_activities_setting ||
207 $setting instanceof backup_section_included_setting) {
209 case self::CHANGED_VALUE: // backup_users = false, this too, and locked
210 if (!$setting->get_value()) {
211 $this->set_value(false);
212 $this->set_status(self::LOCKED_BY_HIERARCHY);
215 case self::CHANGED_VISIBILITY: // backup_users not visible, this too
216 if (!$setting->get_visibility()) {
217 $this->set_visibility(false);
220 case self::CHANGED_STATUS: // backup_users unlocked, this too
221 if ($setting->get_status() == self::NOT_LOCKED) {
222 $this->set_status(self::NOT_LOCKED);
231 * activity backup setting to control if activity will include
232 * user information or no, depends of @backup_users_setting
234 class backup_activity_userinfo_setting extends activity_backup_setting {
235 public function process_change($setting, $ctype, $oldv) {
236 // If change detected in backup_users_setting or backup_section_userinfo_setting
237 if ($setting instanceof backup_users_setting ||
238 $setting instanceof backup_section_userinfo_setting) {
240 case self::CHANGED_VALUE: // backup_users = false, this too, and locked
241 if (!$setting->get_value()) {
242 $this->set_value(false);
243 $this->set_status(self::LOCKED_BY_HIERARCHY);
246 case self::CHANGED_VISIBILITY: // backup_users not visible, this too
247 if (!$setting->get_visibility()) {
248 $this->set_visibility(false);
251 case self::CHANGED_STATUS: // backup_users unlocked, this too
252 if ($setting->get_status() == self::NOT_LOCKED) {
253 $this->set_status(self::NOT_LOCKED);