[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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-dbops 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 * Non instantiable helper class providing DB support to the @backup_controller 27 * 28 * This class contains various static methods available for all the DB operations 29 * performed by the backup_controller class 30 * 31 * TODO: Finish phpdocs 32 */ 33 abstract class backup_controller_dbops extends backup_dbops { 34 35 /** 36 * @var string Backup id for cached backup_includes_files result. 37 */ 38 protected static $includesfilescachebackupid; 39 40 /** 41 * @var int Cached backup_includes_files result 42 */ 43 protected static $includesfilescache; 44 45 /** 46 * Send one backup controller to DB 47 * 48 * @param backup_controller $controller controller to send to DB 49 * @param string $checksum hash of the controller to be checked 50 * @param bool $includeobj to decide if the object itself must be updated (true) or no (false) 51 * @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false) 52 * @return int id of the controller record in the DB 53 * @throws backup_controller_exception|backup_dbops_exception 54 */ 55 public static function save_controller($controller, $checksum, $includeobj = true, $cleanobj = false) { 56 global $DB; 57 // Check we are going to save one backup_controller 58 if (! $controller instanceof backup_controller) { 59 throw new backup_controller_exception('backup_controller_expected'); 60 } 61 // Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-). 62 if ($includeobj and !$controller->is_checksum_correct($checksum)) { 63 throw new backup_dbops_exception('backup_controller_dbops_saving_checksum_mismatch'); 64 } 65 // Cannot request to $includeobj and $cleanobj at the same time. 66 if ($includeobj and $cleanobj) { 67 throw new backup_dbops_exception('backup_controller_dbops_saving_cannot_include_and_delete'); 68 } 69 // Get all the columns 70 $rec = new stdclass(); 71 $rec->backupid = $controller->get_backupid(); 72 $rec->operation = $controller->get_operation(); 73 $rec->type = $controller->get_type(); 74 $rec->itemid = $controller->get_id(); 75 $rec->format = $controller->get_format(); 76 $rec->interactive = $controller->get_interactive(); 77 $rec->purpose = $controller->get_mode(); 78 $rec->userid = $controller->get_userid(); 79 $rec->status = $controller->get_status(); 80 $rec->execution = $controller->get_execution(); 81 $rec->executiontime= $controller->get_executiontime(); 82 $rec->checksum = $checksum; 83 // Serialize information 84 if ($includeobj) { 85 $rec->controller = base64_encode(serialize($controller)); 86 } else if ($cleanobj) { 87 $rec->controller = ''; 88 } 89 // Send it to DB 90 if ($recexists = $DB->get_record('backup_controllers', array('backupid' => $rec->backupid))) { 91 $rec->id = $recexists->id; 92 $rec->timemodified = time(); 93 $DB->update_record('backup_controllers', $rec); 94 } else { 95 $rec->timecreated = time(); 96 $rec->timemodified = 0; 97 $rec->id = $DB->insert_record('backup_controllers', $rec); 98 } 99 return $rec->id; 100 } 101 102 public static function load_controller($backupid) { 103 global $DB; 104 if (! $controllerrec = $DB->get_record('backup_controllers', array('backupid' => $backupid))) { 105 throw new backup_dbops_exception('backup_controller_dbops_nonexisting'); 106 } 107 $controller = unserialize(base64_decode($controllerrec->controller)); 108 // Check checksum is ok. Sounds silly but it isn't ;-) 109 if (!$controller->is_checksum_correct($controllerrec->checksum)) { 110 throw new backup_dbops_exception('backup_controller_dbops_loading_checksum_mismatch'); 111 } 112 return $controller; 113 } 114 115 public static function create_backup_ids_temp_table($backupid) { 116 global $CFG, $DB; 117 $dbman = $DB->get_manager(); // We are going to use database_manager services 118 119 $xmldb_table = new xmldb_table('backup_ids_temp'); 120 $xmldb_table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); 121 // Set default backupid (not needed but this enforce any missing backupid). That's hackery in action! 122 $xmldb_table->add_field('backupid', XMLDB_TYPE_CHAR, 32, null, XMLDB_NOTNULL, null, $backupid); 123 $xmldb_table->add_field('itemname', XMLDB_TYPE_CHAR, 160, null, XMLDB_NOTNULL, null, null); 124 $xmldb_table->add_field('itemid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null); 125 $xmldb_table->add_field('newitemid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, '0'); 126 $xmldb_table->add_field('parentitemid', XMLDB_TYPE_INTEGER, 10, null, null, null, null); 127 $xmldb_table->add_field('info', XMLDB_TYPE_TEXT, null, null, null, null, null); 128 $xmldb_table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); 129 $xmldb_table->add_key('backupid_itemname_itemid_uk', XMLDB_KEY_UNIQUE, array('backupid','itemname','itemid')); 130 $xmldb_table->add_index('backupid_parentitemid_ix', XMLDB_INDEX_NOTUNIQUE, array('backupid','itemname','parentitemid')); 131 $xmldb_table->add_index('backupid_itemname_newitemid_ix', XMLDB_INDEX_NOTUNIQUE, array('backupid','itemname','newitemid')); 132 133 $dbman->create_temp_table($xmldb_table); // And create it 134 135 } 136 137 public static function create_backup_files_temp_table($backupid) { 138 global $CFG, $DB; 139 $dbman = $DB->get_manager(); // We are going to use database_manager services 140 141 $xmldb_table = new xmldb_table('backup_files_temp'); 142 $xmldb_table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); 143 // Set default backupid (not needed but this enforce any missing backupid). That's hackery in action! 144 $xmldb_table->add_field('backupid', XMLDB_TYPE_CHAR, 32, null, XMLDB_NOTNULL, null, $backupid); 145 $xmldb_table->add_field('contextid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null); 146 $xmldb_table->add_field('component', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL, null, null); 147 $xmldb_table->add_field('filearea', XMLDB_TYPE_CHAR, 50, null, XMLDB_NOTNULL, null, null); 148 $xmldb_table->add_field('itemid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null); 149 $xmldb_table->add_field('info', XMLDB_TYPE_TEXT, null, null, null, null, null); 150 $xmldb_table->add_field('newcontextid', XMLDB_TYPE_INTEGER, 10, null, null, null, null); 151 $xmldb_table->add_field('newitemid', XMLDB_TYPE_INTEGER, 10, null, null, null, null); 152 $xmldb_table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); 153 $xmldb_table->add_index('backupid_contextid_component_filearea_itemid_ix', XMLDB_INDEX_NOTUNIQUE, array('backupid','contextid','component','filearea','itemid')); 154 155 $dbman->create_temp_table($xmldb_table); // And create it 156 } 157 158 public static function drop_backup_ids_temp_table($backupid) { 159 global $DB; 160 $dbman = $DB->get_manager(); // We are going to use database_manager services 161 162 $targettablename = 'backup_ids_temp'; 163 if ($dbman->table_exists($targettablename)) { 164 $table = new xmldb_table($targettablename); 165 $dbman->drop_table($table); // And drop it 166 } 167 } 168 169 /** 170 * Decode the info field from backup_ids_temp or backup_files_temp. 171 * 172 * @param mixed $info The info field data to decode, may be an object or a simple integer. 173 * @return mixed The decoded information. For simple types it returns, for complex ones we decode. 174 */ 175 public static function decode_backup_temp_info($info) { 176 // We encode all data except null. 177 if ($info != null) { 178 return unserialize(gzuncompress(base64_decode($info))); 179 } 180 return $info; 181 } 182 183 /** 184 * Encode the info field for backup_ids_temp or backup_files_temp. 185 * 186 * @param mixed $info string The info field data to encode. 187 * @return string An encoded string of data or null if the input is null. 188 */ 189 public static function encode_backup_temp_info($info) { 190 // We encode if there is any information to keep the translations simpler. 191 if ($info != null) { 192 // We compress if possible. It reduces db, network and memory storage. The saving is greater than CPU compression cost. 193 // Compression level 1 is chosen has it produces good compression with the smallest possible overhead, see MDL-40618. 194 return base64_encode(gzcompress(serialize($info), 1)); 195 } 196 return $info; 197 } 198 199 /** 200 * Given one type and id from controller, return the corresponding courseid 201 */ 202 public static function get_courseid_from_type_id($type, $id) { 203 global $DB; 204 if ($type == backup::TYPE_1COURSE) { 205 return $id; // id is the course id 206 207 } else if ($type == backup::TYPE_1SECTION) { 208 if (! $courseid = $DB->get_field('course_sections', 'course', array('id' => $id))) { 209 throw new backup_dbops_exception('course_not_found_for_section', $id); 210 } 211 return $courseid; 212 } else if ($type == backup::TYPE_1ACTIVITY) { 213 if (! $courseid = $DB->get_field('course_modules', 'course', array('id' => $id))) { 214 throw new backup_dbops_exception('course_not_found_for_moduleid', $id); 215 } 216 return $courseid; 217 } 218 } 219 220 /** 221 * Given one activity task, return the activity information and related settings 222 * Used by get_moodle_backup_information() 223 */ 224 private static function get_activity_backup_information($task) { 225 226 $contentinfo = array( 227 'moduleid' => $task->get_moduleid(), 228 'sectionid' => $task->get_sectionid(), 229 'modulename' => $task->get_modulename(), 230 'title' => $task->get_name(), 231 'directory' => 'activities/' . $task->get_modulename() . '_' . $task->get_moduleid()); 232 233 // Now get activity settings 234 // Calculate prefix to find valid settings 235 $prefix = basename($contentinfo['directory']); 236 $settingsinfo = array(); 237 foreach ($task->get_settings() as $setting) { 238 // Discard ones without valid prefix 239 if (strpos($setting->get_name(), $prefix) !== 0) { 240 continue; 241 } 242 // Validate level is correct (activity) 243 if ($setting->get_level() != backup_setting::ACTIVITY_LEVEL) { 244 throw new backup_controller_exception('setting_not_activity_level', $setting); 245 } 246 $settinginfo = array( 247 'level' => 'activity', 248 'activity' => $prefix, 249 'name' => $setting->get_name(), 250 'value' => $setting->get_value()); 251 $settingsinfo[$setting->get_name()] = (object)$settinginfo; 252 } 253 return array($contentinfo, $settingsinfo); 254 } 255 256 /** 257 * Given one section task, return the section information and related settings 258 * Used by get_moodle_backup_information() 259 */ 260 private static function get_section_backup_information($task) { 261 262 $contentinfo = array( 263 'sectionid' => $task->get_sectionid(), 264 'title' => $task->get_name(), 265 'directory' => 'sections/' . 'section_' . $task->get_sectionid()); 266 267 // Now get section settings 268 // Calculate prefix to find valid settings 269 $prefix = basename($contentinfo['directory']); 270 $settingsinfo = array(); 271 foreach ($task->get_settings() as $setting) { 272 // Discard ones without valid prefix 273 if (strpos($setting->get_name(), $prefix) !== 0) { 274 continue; 275 } 276 // Validate level is correct (section) 277 if ($setting->get_level() != backup_setting::SECTION_LEVEL) { 278 throw new backup_controller_exception('setting_not_section_level', $setting); 279 } 280 $settinginfo = array( 281 'level' => 'section', 282 'section' => $prefix, 283 'name' => $setting->get_name(), 284 'value' => $setting->get_value()); 285 $settingsinfo[$setting->get_name()] = (object)$settinginfo; 286 } 287 return array($contentinfo, $settingsinfo); 288 } 289 290 /** 291 * Given one course task, return the course information and related settings 292 * Used by get_moodle_backup_information() 293 */ 294 private static function get_course_backup_information($task) { 295 296 $contentinfo = array( 297 'courseid' => $task->get_courseid(), 298 'title' => $task->get_name(), 299 'directory' => 'course'); 300 301 // Now get course settings 302 // Calculate prefix to find valid settings 303 $prefix = basename($contentinfo['directory']); 304 $settingsinfo = array(); 305 foreach ($task->get_settings() as $setting) { 306 // Discard ones without valid prefix 307 if (strpos($setting->get_name(), $prefix) !== 0) { 308 continue; 309 } 310 // Validate level is correct (course) 311 if ($setting->get_level() != backup_setting::COURSE_LEVEL) { 312 throw new backup_controller_exception('setting_not_course_level', $setting); 313 } 314 $settinginfo = array( 315 'level' => 'course', 316 'name' => $setting->get_name(), 317 'value' => $setting->get_value()); 318 $settingsinfo[$setting->get_name()] = (object)$settinginfo; 319 } 320 return array($contentinfo, $settingsinfo); 321 } 322 323 /** 324 * Given one root task, return the course information and related settings 325 * Used by get_moodle_backup_information() 326 */ 327 private static function get_root_backup_information($task) { 328 329 // Now get root settings 330 $settingsinfo = array(); 331 foreach ($task->get_settings() as $setting) { 332 // Validate level is correct (root) 333 if ($setting->get_level() != backup_setting::ROOT_LEVEL) { 334 throw new backup_controller_exception('setting_not_root_level', $setting); 335 } 336 $settinginfo = array( 337 'level' => 'root', 338 'name' => $setting->get_name(), 339 'value' => $setting->get_value()); 340 $settingsinfo[$setting->get_name()] = (object)$settinginfo; 341 } 342 return array(null, $settingsinfo); 343 } 344 345 /** 346 * Get details information for main moodle_backup.xml file, extracting it from 347 * the specified controller. 348 * 349 * If you specify the progress monitor, this will start a new progress section 350 * to track progress in processing (in case this task takes a long time). 351 * 352 * @param string $backupid Backup ID 353 * @param \core\progress\base $progress Optional progress monitor 354 */ 355 public static function get_moodle_backup_information($backupid, 356 \core\progress\base $progress = null) { 357 358 // Start tracking progress if required (for load_controller). 359 if ($progress) { 360 $progress->start_progress('get_moodle_backup_information', 2); 361 } 362 363 $detailsinfo = array(); // Information details 364 $contentsinfo= array(); // Information about backup contents 365 $settingsinfo= array(); // Information about backup settings 366 $bc = self::load_controller($backupid); // Load controller 367 368 // Note that we have loaded controller. 369 if ($progress) { 370 $progress->progress(1); 371 } 372 373 // Details info 374 $detailsinfo['id'] = $bc->get_id(); 375 $detailsinfo['backup_id'] = $bc->get_backupid(); 376 $detailsinfo['type'] = $bc->get_type(); 377 $detailsinfo['format'] = $bc->get_format(); 378 $detailsinfo['interactive'] = $bc->get_interactive(); 379 $detailsinfo['mode'] = $bc->get_mode(); 380 $detailsinfo['execution'] = $bc->get_execution(); 381 $detailsinfo['executiontime'] = $bc->get_executiontime(); 382 $detailsinfo['userid'] = $bc->get_userid(); 383 $detailsinfo['courseid'] = $bc->get_courseid(); 384 385 386 // Init content placeholders 387 $contentsinfo['activities'] = array(); 388 $contentsinfo['sections'] = array(); 389 $contentsinfo['course'] = array(); 390 391 // Get tasks and start nested progress. 392 $tasks = $bc->get_plan()->get_tasks(); 393 if ($progress) { 394 $progress->start_progress('get_moodle_backup_information', count($tasks)); 395 $done = 1; 396 } 397 398 // Contents info (extract information from tasks) 399 foreach ($tasks as $task) { 400 401 if ($task instanceof backup_activity_task) { // Activity task 402 403 if ($task->get_setting_value('included')) { // Only return info about included activities 404 list($contentinfo, $settings) = self::get_activity_backup_information($task); 405 $contentsinfo['activities'][] = $contentinfo; 406 $settingsinfo = array_merge($settingsinfo, $settings); 407 } 408 409 } else if ($task instanceof backup_section_task) { // Section task 410 411 if ($task->get_setting_value('included')) { // Only return info about included sections 412 list($contentinfo, $settings) = self::get_section_backup_information($task); 413 $contentsinfo['sections'][] = $contentinfo; 414 $settingsinfo = array_merge($settingsinfo, $settings); 415 } 416 417 } else if ($task instanceof backup_course_task) { // Course task 418 419 list($contentinfo, $settings) = self::get_course_backup_information($task); 420 $contentsinfo['course'][] = $contentinfo; 421 $settingsinfo = array_merge($settingsinfo, $settings); 422 423 } else if ($task instanceof backup_root_task) { // Root task 424 425 list($contentinfo, $settings) = self::get_root_backup_information($task); 426 $settingsinfo = array_merge($settingsinfo, $settings); 427 } 428 429 // Report task handled. 430 if ($progress) { 431 $progress->progress($done++); 432 } 433 } 434 435 $bc->destroy(); // Always need to destroy controller to handle circular references 436 437 // Finish progress reporting. 438 if ($progress) { 439 $progress->end_progress(); 440 $progress->end_progress(); 441 } 442 443 return array(array((object)$detailsinfo), $contentsinfo, $settingsinfo); 444 } 445 446 /** 447 * Update CFG->backup_version and CFG->backup_release if change in 448 * version is detected. 449 */ 450 public static function apply_version_and_release() { 451 global $CFG; 452 453 if ($CFG->backup_version < backup::VERSION) { 454 set_config('backup_version', backup::VERSION); 455 set_config('backup_release', backup::RELEASE); 456 } 457 } 458 459 /** 460 * Given the backupid, detect if the backup includes "mnet" remote users or no 461 */ 462 public static function backup_includes_mnet_remote_users($backupid) { 463 global $CFG, $DB; 464 465 $sql = "SELECT COUNT(*) 466 FROM {backup_ids_temp} b 467 JOIN {user} u ON u.id = b.itemid 468 WHERE b.backupid = ? 469 AND b.itemname = 'userfinal' 470 AND u.mnethostid != ?"; 471 $count = $DB->count_records_sql($sql, array($backupid, $CFG->mnet_localhost_id)); 472 return (int)(bool)$count; 473 } 474 475 /** 476 * Given the backupid, determine whether this backup should include 477 * files from the moodle file storage system. 478 * 479 * @param string $backupid The ID of the backup. 480 * @return int Indicates whether files should be included in backups. 481 */ 482 public static function backup_includes_files($backupid) { 483 // This function is called repeatedly in a backup with many files. 484 // Loading the controller is a nontrivial operation (in a large test 485 // backup it took 0.3 seconds), so we do a temporary cache of it within 486 // this request. 487 if (self::$includesfilescachebackupid === $backupid) { 488 return self::$includesfilescache; 489 } 490 491 // Load controller, get value, then destroy controller and return result. 492 self::$includesfilescachebackupid = $backupid; 493 $bc = self::load_controller($backupid); 494 self::$includesfilescache = $bc->get_include_files(); 495 $bc->destroy(); 496 return self::$includesfilescache; 497 } 498 499 /** 500 * Given the backupid, detect if the backup contains references to external contents 501 * 502 * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} 503 * @return int 504 */ 505 public static function backup_includes_file_references($backupid) { 506 global $CFG, $DB; 507 508 $sql = "SELECT count(r.repositoryid) 509 FROM {files} f 510 LEFT JOIN {files_reference} r 511 ON r.id = f.referencefileid 512 JOIN {backup_ids_temp} bi 513 ON f.id = bi.itemid 514 WHERE bi.backupid = ? 515 AND bi.itemname = 'filefinal'"; 516 $count = $DB->count_records_sql($sql, array($backupid)); 517 return (int)(bool)$count; 518 } 519 520 /** 521 * Given the courseid, return some course related information we want to transport 522 * 523 * @param int $course the id of the course this backup belongs to 524 */ 525 public static function backup_get_original_course_info($courseid) { 526 global $DB; 527 return $DB->get_record('course', array('id' => $courseid), 'fullname, shortname, startdate, format'); 528 } 529 530 /** 531 * Sets the default values for the settings in a backup operation 532 * 533 * Based on the mode of the backup it will delegate the process to 534 * other methods like {@link apply_general_config_defaults} ... 535 * to get proper defaults loaded 536 * 537 * @param backup_controller $controller 538 */ 539 public static function apply_config_defaults(backup_controller $controller) { 540 // Based on the mode of the backup (general, automated, import, hub...) 541 // decide the action to perform to get defaults loaded 542 $mode = $controller->get_mode(); 543 544 switch ($mode) { 545 case backup::MODE_GENERAL: 546 // Load the general defaults 547 self::apply_general_config_defaults($controller); 548 break; 549 case backup::MODE_AUTOMATED: 550 // Load the automated defaults. 551 self::apply_auto_config_defaults($controller); 552 break; 553 default: 554 // Nothing to do for other modes (IMPORT/HUB...). Some day we 555 // can define defaults (admin UI...) for them if we want to 556 } 557 } 558 559 /** 560 * Sets the controller settings default values from the automated backup config. 561 * 562 * @param backup_controller $controller 563 */ 564 private static function apply_auto_config_defaults(backup_controller $controller) { 565 $settings = array( 566 // Config name => Setting name. 567 'backup_auto_users' => 'users', 568 'backup_auto_role_assignments' => 'role_assignments', 569 'backup_auto_activities' => 'activities', 570 'backup_auto_blocks' => 'blocks', 571 'backup_auto_filters' => 'filters', 572 'backup_auto_comments' => 'comments', 573 'backup_auto_badges' => 'badges', 574 'backup_auto_userscompletion' => 'userscompletion', 575 'backup_auto_logs' => 'logs', 576 'backup_auto_histories' => 'grade_histories', 577 'backup_auto_questionbank' => 'questionbank', 578 'backup_auto_groups' => 'groups' 579 ); 580 $plan = $controller->get_plan(); 581 foreach ($settings as $config => $settingname) { 582 $value = get_config('backup', $config); 583 if ($value === false) { 584 // The setting is not set. 585 $controller->log('Could not find a value for the config ' . $config, BACKUP::LOG_DEBUG); 586 continue; 587 } 588 if ($plan->setting_exists($settingname)) { 589 $setting = $plan->get_setting($settingname); 590 $setting->set_value($value); 591 } else { 592 $controller->log('Unknown setting: ' . $settingname, BACKUP::LOG_DEBUG); 593 } 594 } 595 } 596 597 /** 598 * Sets the controller settings default values from the backup config. 599 * 600 * @param backup_controller $controller 601 */ 602 private static function apply_general_config_defaults(backup_controller $controller) { 603 $settings = array( 604 // Config name => Setting name 605 'backup_general_users' => 'users', 606 'backup_general_anonymize' => 'anonymize', 607 'backup_general_role_assignments' => 'role_assignments', 608 'backup_general_activities' => 'activities', 609 'backup_general_blocks' => 'blocks', 610 'backup_general_filters' => 'filters', 611 'backup_general_comments' => 'comments', 612 'backup_general_badges' => 'badges', 613 'backup_general_userscompletion' => 'userscompletion', 614 'backup_general_logs' => 'logs', 615 'backup_general_histories' => 'grade_histories', 616 'backup_general_questionbank' => 'questionbank', 617 'backup_general_groups' => 'groups' 618 ); 619 $plan = $controller->get_plan(); 620 foreach ($settings as $config=>$settingname) { 621 $value = get_config('backup', $config); 622 if ($value === false) { 623 // Ignore this because the config has not been set. get_config 624 // returns false if a setting doesn't exist, '0' is returned when 625 // the configuration is set to false. 626 $controller->log('Could not find a value for the config ' . $config, BACKUP::LOG_DEBUG); 627 continue; 628 } 629 $locked = (get_config('backup', $config.'_locked') == true); 630 if ($plan->setting_exists($settingname)) { 631 $setting = $plan->get_setting($settingname); 632 if ($setting->get_value() != $value || 1==1) { 633 $setting->set_value($value); 634 if ($locked) { 635 $setting->set_status(base_setting::LOCKED_BY_CONFIG); 636 } 637 } 638 } else { 639 $controller->log('Unknown setting: ' . $setting, BACKUP::LOG_DEBUG); 640 } 641 } 642 } 643 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |