Differences Between: [Versions 310 and 311] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 * Defines classes used to handle restore settings 20 * 21 * @package core_backup 22 * @subpackage moodle2 23 * @category backup 24 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 // TODO: Reduce these to the minimum because ui/dependencies are 100% separated 31 32 // Root restore settings 33 34 /** 35 * root generic setting to store different things without dependencies 36 */ 37 class restore_generic_setting extends root_backup_setting {} 38 39 /** 40 * root setting to control if restore will create user information 41 * A lot of other settings are dependent of this (module's user info, 42 * grades user info, messages, blogs... 43 */ 44 class restore_users_setting extends restore_generic_setting {} 45 46 /** 47 * root setting to control if restore will create override permission information by roles 48 */ 49 class restore_permissions_setting extends restore_generic_setting { 50 } 51 52 /** 53 * root setting to control if restore will create groups/grouping information. Depends on @restore_users_setting 54 * 55 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 56 * @copyright 2014 Matt Sammarco 57 */ 58 class restore_groups_setting extends restore_generic_setting { 59 } 60 61 /** 62 * root setting to control if restore will include custom field information 63 * 64 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 65 * @copyright 2018 Daniel Neis Araujo 66 */ 67 class restore_customfield_setting extends restore_generic_setting { 68 } 69 70 /** 71 * root setting to control if restore will create role assignments 72 * or no (any level), depends of @restore_users_setting 73 */ 74 class restore_role_assignments_setting extends root_backup_setting {} 75 76 /** 77 * root setting to control if restore will create activities 78 * A lot of other settings (_included at activity levels) 79 * are dependent of this setting 80 */ 81 class restore_activities_setting extends restore_generic_setting {} 82 83 /** 84 * root setting to control if restore will create 85 * comments or no, depends of @restore_users_setting 86 * exactly in the same way than @restore_role_assignments_setting so we extend from it 87 */ 88 class restore_comments_setting extends restore_role_assignments_setting {} 89 90 /** 91 * root setting to control if restore will create badges or not, 92 * depends on @restore_activities_setting 93 */ 94 class restore_badges_setting extends restore_generic_setting {} 95 96 /** 97 * root setting to control if competencies will also be restored. 98 */ 99 class restore_competencies_setting extends restore_generic_setting { 100 101 /** 102 * restore_competencies_setting constructor. 103 * @param bool $hascompetencies Flag whether to set the restore setting as checked and unlocked. 104 */ 105 public function __construct($hascompetencies) { 106 $defaultvalue = false; 107 $visibility = base_setting::HIDDEN; 108 $status = base_setting::LOCKED_BY_CONFIG; 109 if (\core_competency\api::is_enabled()) { 110 $visibility = base_setting::VISIBLE; 111 if ($hascompetencies) { 112 $defaultvalue = true; 113 $status = base_setting::NOT_LOCKED; 114 } 115 } 116 parent::__construct('competencies', base_setting::IS_BOOLEAN, $defaultvalue, $visibility, $status); 117 } 118 } 119 120 /** 121 * root setting to control if restore will create 122 * events or no, depends of @restore_users_setting 123 * exactly in the same way than @restore_role_assignments_setting so we extend from it 124 */ 125 class restore_calendarevents_setting extends restore_role_assignments_setting {} 126 127 /** 128 * root setting to control if restore will create 129 * completion info or no, depends of @restore_users_setting 130 * exactly in the same way than @restore_role_assignments_setting so we extend from it 131 */ 132 class restore_userscompletion_setting extends restore_role_assignments_setting {} 133 134 /** 135 * root setting to control if restore will create 136 * logs or no, depends of @restore_users_setting 137 * exactly in the same way than @restore_role_assignments_setting so we extend from it 138 */ 139 class restore_logs_setting extends restore_role_assignments_setting {} 140 141 /** 142 * root setting to control if restore will create 143 * grade_histories or no, depends of @restore_users_setting 144 * exactly in the same way than @restore_role_assignments_setting so we extend from it 145 */ 146 class restore_grade_histories_setting extends restore_role_assignments_setting {} 147 148 149 // Course restore settings 150 151 /** 152 * generic course setting to pass various settings between tasks and steps 153 */ 154 class restore_course_generic_setting extends course_backup_setting {} 155 156 /** 157 * Setting to define is we are going to overwrite course configuration 158 */ 159 class restore_course_overwrite_conf_setting extends restore_course_generic_setting {} 160 161 /** 162 * Setting to switch between current and new course name/startdate 163 * 164 * @copyright 2017 Marina Glancy 165 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 166 */ 167 class restore_course_defaultcustom_setting extends restore_course_generic_setting { 168 /** 169 * Validates that the value $value has type $vtype 170 * @param int $vtype 171 * @param mixed $value 172 * @return mixed 173 */ 174 public function validate_value($vtype, $value) { 175 if ($value === false) { 176 // Value "false" means default and is allowed for this setting type even if it does not match $vtype. 177 return $value; 178 } 179 return parent::validate_value($vtype, $value); 180 } 181 182 /** 183 * Special method for this element only. When value is "false" returns the default value. 184 * @return mixed 185 */ 186 public function get_normalized_value() { 187 $value = $this->get_value(); 188 if ($value === false && $this->get_ui() instanceof backup_setting_ui_defaultcustom) { 189 $attributes = $this->get_ui()->get_attributes(); 190 return $attributes['defaultvalue']; 191 } 192 return $value; 193 } 194 } 195 196 197 class restore_course_generic_text_setting extends restore_course_generic_setting { 198 199 public function __construct($name, $vtype, $value = null, $visibility = self::VISIBLE, $status = self::NOT_LOCKED) { 200 parent::__construct($name, $vtype, $value, $visibility, $status); 201 $this->set_ui(new backup_setting_ui_text($this, $name)); 202 } 203 204 } 205 206 // Section restore settings 207 208 /** 209 * generic section setting to pass various settings between tasks and steps 210 */ 211 class restore_section_generic_setting extends section_backup_setting {} 212 213 /** 214 * Setting to define if one section is included or no. Activities _included 215 * settings depend of them if available 216 */ 217 class restore_section_included_setting extends restore_section_generic_setting {} 218 219 /** 220 * section backup setting to control if section will include 221 * user information or no, depends of @restore_users_setting 222 */ 223 class restore_section_userinfo_setting extends restore_section_generic_setting {} 224 225 226 // Activity backup settings 227 228 /** 229 * generic activity setting to pass various settings between tasks and steps 230 */ 231 class restore_activity_generic_setting extends activity_backup_setting {} 232 233 /** 234 * activity backup setting to control if activity will 235 * be included or no, depends of @restore_activities_setting and 236 * optionally parent section included setting 237 */ 238 class restore_activity_included_setting extends restore_activity_generic_setting {} 239 240 /** 241 * activity backup setting to control if activity will include 242 * user information or no, depends of @restore_users_setting 243 */ 244 class restore_activity_userinfo_setting extends restore_activity_generic_setting {} 245 246 /** 247 * root setting to control if restore will create content bank content or no 248 */ 249 class restore_contentbankcontent_setting extends restore_generic_setting { 250 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body