[ 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 * Defines restore_final_task class 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 /** 31 * Final task that provides all the final steps necessary in order to finish one 32 * restore like gradebook, interlinks... apart from some final cleaning 33 * 34 * TODO: Finish phpdocs 35 */ 36 class restore_final_task extends restore_task { 37 38 /** 39 * Create all the steps that will be part of this task 40 */ 41 public function build() { 42 43 // Move all the CONTEXT_MODULE question qcats to their 44 // final (newly created) module context 45 $this->add_step(new restore_move_module_questions_categories('move_module_question_categories')); 46 47 // Create all the question files now that every question is in place 48 // and every category has its final contextid associated 49 $this->add_step(new restore_create_question_files('create_question_files')); 50 51 // Review all the block_position records in backup_ids in order 52 // match them now that all the contexts are created populating DB 53 // as needed. Only if we are restoring blocks. 54 if ($this->get_setting_value('blocks')) { 55 $this->add_step(new restore_review_pending_block_positions('review_block_positions')); 56 } 57 58 // Gradebook. Don't restore the gradebook unless activities are being restored. 59 if ($this->get_setting_value('activities')) { 60 $this->add_step(new restore_gradebook_structure_step('gradebook_step','gradebook.xml')); 61 $this->add_step(new restore_grade_history_structure_step('grade_history', 'grade_history.xml')); 62 } 63 64 // Course completion. 65 $this->add_step(new restore_course_completion_structure_step('course_completion', 'completion.xml')); 66 67 // Conditionally restore course badges. 68 if ($this->get_setting_value('badges')) { 69 $this->add_step(new restore_badges_structure_step('course_badges', 'badges.xml')); 70 } 71 72 // Review all the legacy module_availability records in backup_ids in 73 // order to match them with existing modules / grade items and convert 74 // into the new system. 75 $this->add_step(new restore_process_course_modules_availability('process_modules_availability')); 76 77 // Update restored availability data to account for changes in IDs 78 // during backup/restore. 79 $this->add_step(new restore_update_availability('update_availability')); 80 81 // Decode all the interlinks 82 $this->add_step(new restore_decode_interlinks('decode_interlinks')); 83 84 // Restore course logs (conditionally). They are restored here because we need all 85 // the activities to be already restored. 86 if ($this->get_setting_value('logs')) { 87 // Legacy logs. 88 $this->add_step(new restore_course_logs_structure_step('course_logs', 'course/logs.xml')); 89 // New log stores. 90 $this->add_step(new restore_course_logstores_structure_step('course_logstores', 'course/logstores.xml')); 91 } 92 93 // Review all the executed tasks having one after_restore method 94 // executing it to perform some final adjustments of information 95 // not available when the task was executed. 96 // This step is always the last one performing modifications on restored information 97 // Don't add any new step after it. Only aliases queue, cache rebuild and clean are allowed. 98 $this->add_step(new restore_execute_after_restore('executing_after_restore')); 99 100 // All files were sent to the filepool by now. We need to process 101 // the aliases yet as they were not actually created but stashed for us instead. 102 // We execute this step after executing_after_restore so that there can't be no 103 // more files sent to the filepool after this. 104 $this->add_step(new restore_process_file_aliases_queue('process_file_aliases_queue')); 105 106 // Rebuild course cache to see results, whoah! 107 $this->add_step(new restore_rebuild_course_cache('rebuild_course_cache')); 108 109 // Clean the temp dir (conditionally) and drop temp table 110 $this->add_step(new restore_drop_and_clean_temp_stuff('drop_and_clean_temp_stuff')); 111 112 $this->built = true; 113 } 114 115 /** 116 * Special method, only available in the restore_final_task, able to invoke the 117 * restore_plan execute_after_restore() method, so restore_execute_after_restore step 118 * will be able to launch all the after_restore() methods of the executed tasks 119 */ 120 public function launch_execute_after_restore() { 121 $this->plan->execute_after_restore(); 122 } 123 124 /** 125 * Define the restore log rules that will be applied 126 * by the {@link restore_logs_processor} when restoring 127 * course logs. It must return one array 128 * of {@link restore_log_rule} objects 129 * 130 * Note these are course logs, but are defined and restored 131 * in final task because we need all the activities to be 132 * restored in order to handle some log records properly 133 */ 134 static public function define_restore_log_rules() { 135 $rules = array(); 136 137 // module 'course' rules 138 $rules[] = new restore_log_rule('course', 'view', 'view.php?id={course}', '{course}'); 139 $rules[] = new restore_log_rule('course', 'guest', 'view.php?id={course}', null); 140 $rules[] = new restore_log_rule('course', 'user report', 'user.php?id={course}&user={user}&mode=[mode]', null); 141 $rules[] = new restore_log_rule('course', 'add mod', '../mod/[modname]/view.php?id={course_module}', '[modname] {[modname]}'); 142 $rules[] = new restore_log_rule('course', 'update mod', '../mod/[modname]/view.php?id={course_module}', '[modname] {[modname]}'); 143 $rules[] = new restore_log_rule('course', 'delete mod', 'view.php?id={course}', null); 144 $rules[] = new restore_log_rule('course', 'update', 'view.php?id={course}', ''); 145 $rules[] = new restore_log_rule('course', 'enrol', 'view.php?id={course}', '{user}'); 146 $rules[] = new restore_log_rule('course', 'unenrol', 'view.php?id={course}', '{user}'); 147 $rules[] = new restore_log_rule('course', 'editsection', 'editsection.php?id={course_section}', null); 148 $rules[] = new restore_log_rule('course', 'new', 'view.php?id={course}', ''); 149 $rules[] = new restore_log_rule('course', 'recent', 'recent.php?id={course}', ''); 150 $rules[] = new restore_log_rule('course', 'report log', 'report/log/index.php?id={course}', '{course}'); 151 $rules[] = new restore_log_rule('course', 'report live', 'report/live/index.php?id={course}', '{course}'); 152 $rules[] = new restore_log_rule('course', 'report outline', 'report/outline/index.php?id={course}', '{course}'); 153 $rules[] = new restore_log_rule('course', 'report participation', 'report/participation/index.php?id={course}', '{course}'); 154 $rules[] = new restore_log_rule('course', 'report stats', 'report/stats/index.php?id={course}', '{course}'); 155 $rules[] = new restore_log_rule('course', 'view section', 'view.php?id={course}§ionid={course_section}', '{course_section}'); 156 157 // module 'grade' rules 158 $rules[] = new restore_log_rule('grade', 'update', 'report/grader/index.php?id={course}', null); 159 160 // module 'user' rules 161 $rules[] = new restore_log_rule('user', 'view', 'view.php?id={user}&course={course}', '{user}'); 162 $rules[] = new restore_log_rule('user', 'change password', 'view.php?id={user}&course={course}', '{user}'); 163 $rules[] = new restore_log_rule('user', 'login', 'view.php?id={user}&course={course}', '{user}'); 164 $rules[] = new restore_log_rule('user', 'logout', 'view.php?id={user}&course={course}', '{user}'); 165 $rules[] = new restore_log_rule('user', 'view all', 'index.php?id={course}', ''); 166 $rules[] = new restore_log_rule('user', 'update', 'view.php?id={user}&course={course}', ''); 167 168 // rules from other tasks (activities) not belonging to one module instance (cmid = 0), so are restored here 169 $rules = array_merge($rules, restore_logs_processor::register_log_rules_for_course()); 170 171 // Calendar rules. 172 $rules[] = new restore_log_rule('calendar', 'add', 'event.php?action=edit&id={event}', '[name]'); 173 $rules[] = new restore_log_rule('calendar', 'edit', 'event.php?action=edit&id={event}', '[name]'); 174 $rules[] = new restore_log_rule('calendar', 'edit all', 'event.php?action=edit&id={event}', '[name]'); 175 176 // TODO: Other logs like 'upload'... will go here 177 178 return $rules; 179 } 180 181 182 // Protected API starts here 183 184 /** 185 * Define the common setting that any restore type will have 186 */ 187 protected function define_settings() { 188 // This task has not settings (could have them, like destination or so in the future, let's see) 189 } 190 }
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 |