See Release Notes
Long Term Support Release
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Define all the restore steps that will be used by the restore_book_activity_task 19 * 20 * @package mod_book 21 * @copyright 2010 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die; 26 27 /** 28 * Structure step to restore one book activity 29 */ 30 class restore_book_activity_structure_step extends restore_activity_structure_step { 31 32 protected function define_structure() { 33 $paths = array(); 34 35 $paths[] = new restore_path_element('book', '/activity/book'); 36 $paths[] = new restore_path_element('book_chapter', '/activity/book/chapters/chapter'); 37 $paths[] = new restore_path_element('book_chapter_tag', '/activity/book/chaptertags/tag'); 38 39 // Return the paths wrapped into standard activity structure 40 return $this->prepare_activity_structure($paths); 41 } 42 43 /** 44 * Process book tag information 45 * @param array $data information 46 */ 47 protected function process_book($data) { 48 global $DB; 49 50 $data = (object)$data; 51 $oldid = $data->id; 52 $data->course = $this->get_courseid(); 53 54 // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset. 55 // See MDL-9367. 56 57 $newitemid = $DB->insert_record('book', $data); 58 $this->apply_activity_instance($newitemid); 59 } 60 61 /** 62 * Process chapter tag information 63 * @param array $data information 64 */ 65 protected function process_book_chapter($data) { 66 global $DB; 67 68 $data = (object)$data; 69 $oldid = $data->id; 70 $data->course = $this->get_courseid(); 71 72 $data->bookid = $this->get_new_parentid('book'); 73 74 $newitemid = $DB->insert_record('book_chapters', $data); 75 $this->set_mapping('book_chapter', $oldid, $newitemid, true); 76 } 77 78 protected function process_book_chapter_tag($data) { 79 $data = (object)$data; 80 81 if (!core_tag_tag::is_enabled('mod_book', 'book_chapters')) { // Tags disabled in server, nothing to process. 82 return; 83 } 84 85 $tag = $data->rawname; 86 87 if (!$itemid = $this->get_mappingid('book_chapter', $data->itemid)) { 88 return; 89 } 90 91 $context = context_module::instance($this->task->get_moduleid()); 92 core_tag_tag::add_item_tag('mod_book', 'book_chapters', $itemid, $context, $tag); 93 } 94 95 protected function after_execute() { 96 global $DB; 97 98 // Add book related files 99 $this->add_related_files('mod_book', 'intro', null); 100 $this->add_related_files('mod_book', 'chapter', 'book_chapter'); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body