MDL-29806 - When a Feedback activity is restore the "Site after submit" URL is not...
[moodle.git] / mod / feedback / backup / moodle2 / restore_feedback_activity_task.class.php
CommitLineData
731ca13c
DM
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-moodle2
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
25defined('MOODLE_INTERNAL') || die();
26
27require_once($CFG->dirroot . '/mod/feedback/backup/moodle2/restore_feedback_stepslib.php'); // Because it exists (must)
28
29/**
30 * feedback restore task that provides all the settings and steps to perform one
31 * complete restore of the activity
32 */
33class restore_feedback_activity_task extends restore_activity_task {
34
35 /**
36 * Define (add) particular settings this activity can have
37 */
38 protected function define_my_settings() {
39 // No particular settings for this activity
40 }
41
42 /**
43 * Define (add) particular steps this activity can have
44 */
45 protected function define_my_steps() {
46 // feedback only has one structure step
47 $this->add_step(new restore_feedback_activity_structure_step('feedback_structure', 'feedback.xml'));
48 }
49
50 /**
51 * Define the contents in the activity that must be
52 * processed by the link decoder
53 */
54 static public function define_decode_contents() {
55 $contents = array();
56
7e4b0986 57 $contents[] = new restore_decode_content('feedback', array('intro', 'site_after_submit', 'page_after_submit'), 'feedback');
d68c337f
EL
58 $contents[] = new restore_decode_content('feedback_item', array('presentation'), 'feedback_item');
59 $contents[] = new restore_decode_content('feedback_value', array('value'), 'feedback_value');
731ca13c
DM
60
61 return $contents;
62 }
63
64 /**
65 * Define the decoding rules for links belonging
66 * to the activity to be executed by the link decoder
67 */
68 static public function define_decode_rules() {
69 $rules = array();
70
731ca13c 71 $rules[] = new restore_decode_rule('FEEDBACKINDEX', '/mod/feedback/index.php?id=$1', 'course');
d68c337f
EL
72 $rules[] = new restore_decode_rule('FEEDBACKVIEWBYID', '/mod/feedback/view.php?id=$1', 'course_module');
73 $rules[] = new restore_decode_rule('FEEDBACKANALYSISBYID', '/mod/feedback/analysis.php?id=$1', 'course_module');
74 $rules[] = new restore_decode_rule('FEEDBACKSHOWENTRIESBYID', '/mod/feedback/show_entries.php?id=$1', 'course_module');
731ca13c
DM
75
76 return $rules;
77
78 }
0f66aced
EL
79
80 /**
81 * Define the restore log rules that will be applied
82 * by the {@link restore_logs_processor} when restoring
83 * feedback logs. It must return one array
84 * of {@link restore_log_rule} objects
85 */
86 static public function define_restore_log_rules() {
87 $rules = array();
88
89 $rules[] = new restore_log_rule('feedback', 'add', 'view.php?id={course_module}', '{feedback}');
90 $rules[] = new restore_log_rule('feedback', 'update', 'view.php?id={course_module}', '{feedback}');
91 $rules[] = new restore_log_rule('feedback', 'view', 'view.php?id={course_module}', '{feedback}');
92 $rules[] = new restore_log_rule('feedback', 'submit', 'view.php?id={course_module}', '{feedback}');
93 $rules[] = new restore_log_rule('feedback', 'startcomplete', 'view.php?id={course_module}', '{feedback}');
94
95 return $rules;
96 }
97
98 /**
99 * Define the restore log rules that will be applied
100 * by the {@link restore_logs_processor} when restoring
101 * course logs. It must return one array
102 * of {@link restore_log_rule} objects
103 *
104 * Note this rules are applied when restoring course logs
105 * by the restore final task, but are defined here at
106 * activity level. All them are rules not linked to any module instance (cmid = 0)
107 */
108 static public function define_restore_log_rules_for_course() {
109 $rules = array();
110
111 $rules[] = new restore_log_rule('feedback', 'view all', 'index.php?id={course}', null);
112
113 return $rules;
114 }
731ca13c 115}