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/>.
19 * @subpackage backup-moodle2
20 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 defined('MOODLE_INTERNAL') || die();
26 require_once($CFG->dirroot . '/mod/chat/backup/moodle2/restore_chat_stepslib.php');
29 * chat restore task that provides all the settings and steps to perform one
30 * complete restore of the activity
32 class restore_chat_activity_task extends restore_activity_task {
35 * Define (add) particular settings this activity can have
37 protected function define_my_settings() {
38 // No particular settings for this activity.
42 * Define (add) particular steps this activity can have
44 protected function define_my_steps() {
45 // Chat only has one structure step.
46 $this->add_step(new restore_chat_activity_structure_step('chat_structure', 'chat.xml'));
50 * Define the contents in the activity that must be
51 * processed by the link decoder
53 static public function define_decode_contents() {
56 $contents[] = new restore_decode_content('chat', array('intro'), 'chat');
57 $contents[] = new restore_decode_content('chat_messages', array('message'), 'chat_message');
63 * Define the decoding rules for links belonging
64 * to the activity to be executed by the link decoder
66 static public function define_decode_rules() {
69 $rules[] = new restore_decode_rule('CHATVIEWBYID', '/mod/chat/view.php?id=$1', 'course_module');
70 $rules[] = new restore_decode_rule('CHATINDEX', '/mod/chat/index.php?id=$1', 'course');
77 * Define the restore log rules that will be applied
78 * by the {@link restore_logs_processor} when restoring
79 * chat logs. It must return one array
80 * of {@link restore_log_rule} objects
82 static public function define_restore_log_rules() {
85 $rules[] = new restore_log_rule('chat', 'add', 'view.php?id={course_module}', '{chat}');
86 $rules[] = new restore_log_rule('chat', 'update', 'view.php?id={course_module}', '{chat}');
87 $rules[] = new restore_log_rule('chat', 'view', 'view.php?id={course_module}', '{chat}');
88 $rules[] = new restore_log_rule('chat', 'talk', 'view.php?id={course_module}', '{chat}');
89 $rules[] = new restore_log_rule('chat', 'report', 'report.php?id={course_module}', '{chat}');
95 * Define the restore log rules that will be applied
96 * by the {@link restore_logs_processor} when restoring
97 * course logs. It must return one array
98 * of {@link restore_log_rule} objects
100 * Note this rules are applied when restoring course logs
101 * by the restore final task, but are defined here at
102 * activity level. All them are rules not linked to any module instance (cmid = 0)
104 static public function define_restore_log_rules_for_course() {
107 $rules[] = new restore_log_rule('chat', 'view all', 'index.php?id={course}', null);