2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Description of book restore task
21 * @copyright 2010 Petr Skoda {@link http://skodak.org}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
27 require_once($CFG->dirroot
. '/mod/book/backup/moodle2/restore_book_stepslib.php'); // Because it exists (must)
29 class restore_book_activity_task
extends restore_activity_task
{
32 * Define (add) particular settings this activity can have
36 protected function define_my_settings() {
37 // No particular settings for this activity
41 * Define (add) particular steps this activity can have
45 protected function define_my_steps() {
46 // Choice only has one structure step
47 $this->add_step(new restore_book_activity_structure_step('book_structure', 'book.xml'));
51 * Define the contents in the activity that must be
52 * processed by the link decoder
56 static public function define_decode_contents() {
59 $contents[] = new restore_decode_content('book', array('intro'), 'book');
60 $contents[] = new restore_decode_content('book_chapters', array('content'), 'book_chapter');
66 * Define the decoding rules for links belonging
67 * to the activity to be executed by the link decoder
71 static public function define_decode_rules() {
74 // List of books in course
75 $rules[] = new restore_decode_rule('BOOKINDEX', '/mod/book/index.php?id=$1', 'course');
78 $rules[] = new restore_decode_rule('BOOKVIEWBYID', '/mod/book/view.php?id=$1', 'course_module');
79 $rules[] = new restore_decode_rule('BOOKVIEWBYIDCH', '/mod/book/view.php?id=$1&chapterid=$2', array('course_module', 'book_chapter'));
82 $rules[] = new restore_decode_rule('BOOKVIEWBYB', '/mod/book/view.php?b=$1', 'book');
83 $rules[] = new restore_decode_rule('BOOKVIEWBYBCH', '/mod/book/view.php?b=$1&chapterid=$2', array('book', 'book_chapter'));
85 // Convert old book links MDL-33362
86 $rules[] = new restore_decode_rule('BOOKSTART', '/mod/book/view.php?id=$1', 'course_module');
92 * Define the restore log rules that will be applied
93 * by the {@link restore_logs_processor} when restoring
94 * book logs. It must return one array
95 * of {@link restore_log_rule} objects
99 static public function define_restore_log_rules() {
102 $rules[] = new restore_log_rule('book', 'add', 'view.php?id={course_module}', '{book}');
103 $rules[] = new restore_log_rule('book', 'update', 'view.php?id={course_module}&chapterid={book_chapter}', '{book}');
104 $rules[] = new restore_log_rule('book', 'update', 'view.php?id={course_module}', '{book}');
105 $rules[] = new restore_log_rule('book', 'view', 'view.php?id={course_module}&chapterid={book_chapter}', '{book}');
106 $rules[] = new restore_log_rule('book', 'view', 'view.php?id={course_module}', '{book}');
107 $rules[] = new restore_log_rule('book', 'print', 'tool/print/index.php?id={course_module}&chapterid={book_chapter}', '{book}');
108 $rules[] = new restore_log_rule('book', 'print', 'tool/print/index.php?id={course_module}', '{book}');
109 $rules[] = new restore_log_rule('book', 'exportimscp', 'tool/exportimscp/index.php?id={course_module}', '{book}');
110 // To convert old 'generateimscp' log entries
111 $rules[] = new restore_log_rule('book', 'generateimscp', 'tool/generateimscp/index.php?id={course_module}', '{book}',
112 'book', 'exportimscp', 'tool/exportimscp/index.php?id={course_module}', '{book}');
118 * Define the restore log rules that will be applied
119 * by the {@link restore_logs_processor} when restoring
120 * course logs. It must return one array
121 * of {@link restore_log_rule} objects
123 * Note this rules are applied when restoring course logs
124 * by the restore final task, but are defined here at
125 * activity level. All them are rules not linked to any module instance (cmid = 0)
129 static public function define_restore_log_rules_for_course() {
132 $rules[] = new restore_log_rule('book', 'view all', 'index.php?id={course}', null);