See Release Notes
Long Term Support Release
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 mod_forum 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 25 defined('MOODLE_INTERNAL') || die(); 26 27 require_once($CFG->dirroot . '/mod/forum/backup/moodle2/restore_forum_stepslib.php'); // Because it exists (must) 28 29 /** 30 * forum restore task that provides all the settings and steps to perform one 31 * complete restore of the activity 32 */ 33 class restore_forum_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 // Choice only has one structure step 47 $this->add_step(new restore_forum_activity_structure_step('forum_structure', 'forum.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 57 $contents[] = new restore_decode_content('forum', array('intro'), 'forum'); 58 $contents[] = new restore_decode_content('forum_posts', array('message'), 'forum_post'); 59 60 return $contents; 61 } 62 63 /** 64 * Define the decoding rules for links belonging 65 * to the activity to be executed by the link decoder 66 */ 67 static public function define_decode_rules() { 68 $rules = array(); 69 70 // List of forums in course 71 $rules[] = new restore_decode_rule('FORUMINDEX', '/mod/forum/index.php?id=$1', 'course'); 72 // Forum by cm->id and forum->id 73 $rules[] = new restore_decode_rule('FORUMVIEWBYID', '/mod/forum/view.php?id=$1', 'course_module'); 74 $rules[] = new restore_decode_rule('FORUMVIEWBYF', '/mod/forum/view.php?f=$1', 'forum'); 75 // Link to forum discussion 76 $rules[] = new restore_decode_rule('FORUMDISCUSSIONVIEW', '/mod/forum/discuss.php?d=$1', 'forum_discussion'); 77 // Link to discussion with parent and with anchor posts 78 $rules[] = new restore_decode_rule('FORUMDISCUSSIONVIEWPARENT', '/mod/forum/discuss.php?d=$1&parent=$2', 79 array('forum_discussion', 'forum_post')); 80 $rules[] = new restore_decode_rule('FORUMDISCUSSIONVIEWINSIDE', '/mod/forum/discuss.php?d=$1#$2', 81 array('forum_discussion', 'forum_post')); 82 83 return $rules; 84 } 85 86 /** 87 * Define the restore log rules that will be applied 88 * by the {@link restore_logs_processor} when restoring 89 * forum logs. It must return one array 90 * of {@link restore_log_rule} objects 91 */ 92 static public function define_restore_log_rules() { 93 $rules = array(); 94 95 $rules[] = new restore_log_rule('forum', 'add', 'view.php?id={course_module}', '{forum}'); 96 $rules[] = new restore_log_rule('forum', 'update', 'view.php?id={course_module}', '{forum}'); 97 $rules[] = new restore_log_rule('forum', 'view', 'view.php?id={course_module}', '{forum}'); 98 $rules[] = new restore_log_rule('forum', 'view forum', 'view.php?id={course_module}', '{forum}'); 99 $rules[] = new restore_log_rule('forum', 'mark read', 'view.php?f={forum}', '{forum}'); 100 $rules[] = new restore_log_rule('forum', 'start tracking', 'view.php?f={forum}', '{forum}'); 101 $rules[] = new restore_log_rule('forum', 'stop tracking', 'view.php?f={forum}', '{forum}'); 102 $rules[] = new restore_log_rule('forum', 'subscribe', 'view.php?f={forum}', '{forum}'); 103 $rules[] = new restore_log_rule('forum', 'unsubscribe', 'view.php?f={forum}', '{forum}'); 104 $rules[] = new restore_log_rule('forum', 'subscriber', 'subscribers.php?id={forum}', '{forum}'); 105 $rules[] = new restore_log_rule('forum', 'subscribers', 'subscribers.php?id={forum}', '{forum}'); 106 $rules[] = new restore_log_rule('forum', 'view subscribers', 'subscribers.php?id={forum}', '{forum}'); 107 $rules[] = new restore_log_rule('forum', 'add discussion', 'discuss.php?d={forum_discussion}', '{forum_discussion}'); 108 $rules[] = new restore_log_rule('forum', 'view discussion', 'discuss.php?d={forum_discussion}', '{forum_discussion}'); 109 $rules[] = new restore_log_rule('forum', 'move discussion', 'discuss.php?d={forum_discussion}', '{forum_discussion}'); 110 $rules[] = new restore_log_rule('forum', 'delete discussi', 'view.php?id={course_module}', '{forum}', 111 null, 'delete discussion'); 112 $rules[] = new restore_log_rule('forum', 'delete discussion', 'view.php?id={course_module}', '{forum}'); 113 $rules[] = new restore_log_rule('forum', 'add post', 'discuss.php?d={forum_discussion}&parent={forum_post}', '{forum_post}'); 114 $rules[] = new restore_log_rule('forum', 'update post', 'discuss.php?d={forum_discussion}#p{forum_post}&parent={forum_post}', '{forum_post}'); 115 $rules[] = new restore_log_rule('forum', 'update post', 'discuss.php?d={forum_discussion}&parent={forum_post}', '{forum_post}'); 116 $rules[] = new restore_log_rule('forum', 'prune post', 'discuss.php?d={forum_discussion}', '{forum_post}'); 117 $rules[] = new restore_log_rule('forum', 'delete post', 'discuss.php?d={forum_discussion}', '[post]'); 118 119 return $rules; 120 } 121 122 /** 123 * Define the restore log rules that will be applied 124 * by the {@link restore_logs_processor} when restoring 125 * course logs. It must return one array 126 * of {@link restore_log_rule} objects 127 * 128 * Note this rules are applied when restoring course logs 129 * by the restore final task, but are defined here at 130 * activity level. All them are rules not linked to any module instance (cmid = 0) 131 */ 132 static public function define_restore_log_rules_for_course() { 133 $rules = array(); 134 135 $rules[] = new restore_log_rule('forum', 'view forums', 'index.php?id={course}', null); 136 $rules[] = new restore_log_rule('forum', 'subscribeall', 'index.php?id={course}', '{course}'); 137 $rules[] = new restore_log_rule('forum', 'unsubscribeall', 'index.php?id={course}', '{course}'); 138 $rules[] = new restore_log_rule('forum', 'user report', 'user.php?course={course}&id={user}&mode=[mode]', '{user}'); 139 $rules[] = new restore_log_rule('forum', 'search', 'search.php?id={course}&search=[searchenc]', '[search]'); 140 141 return $rules; 142 } 143 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body