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 * Defines backup_forum_activity_task class 20 * 21 * @package mod_forum 22 * @category backup 23 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 require_once($CFG->dirroot . '/mod/forum/backup/moodle2/backup_forum_stepslib.php'); 30 require_once($CFG->dirroot . '/mod/forum/backup/moodle2/backup_forum_settingslib.php'); 31 32 /** 33 * Provides the steps to perform one complete backup of the Forum instance 34 */ 35 class backup_forum_activity_task extends backup_activity_task { 36 37 /** 38 * No specific settings for this activity 39 */ 40 protected function define_my_settings() { 41 } 42 43 /** 44 * Defines a backup step to store the instance data in the forum.xml file 45 */ 46 protected function define_my_steps() { 47 $this->add_step(new backup_forum_activity_structure_step('forum structure', 'forum.xml')); 48 } 49 50 /** 51 * Encodes URLs to the index.php, view.php and discuss.php scripts 52 * 53 * @param string $content some HTML text that eventually contains URLs to the activity instance scripts 54 * @return string the content with the URLs encoded 55 */ 56 static public function encode_content_links($content) { 57 global $CFG; 58 59 $base = preg_quote($CFG->wwwroot,"/"); 60 61 // Link to the list of forums 62 $search="/(".$base."\/mod\/forum\/index.php\?id\=)([0-9]+)/"; 63 $content= preg_replace($search, '$@FORUMINDEX*$2@$', $content); 64 65 // Link to forum view by moduleid 66 $search="/(".$base."\/mod\/forum\/view.php\?id\=)([0-9]+)/"; 67 $content= preg_replace($search, '$@FORUMVIEWBYID*$2@$', $content); 68 69 // Link to forum view by forumid 70 $search="/(".$base."\/mod\/forum\/view.php\?f\=)([0-9]+)/"; 71 $content= preg_replace($search, '$@FORUMVIEWBYF*$2@$', $content); 72 73 // Link to forum discussion with parent syntax 74 $search = "/(".$base."\/mod\/forum\/discuss.php\?d\=)([0-9]+)(?:\&|\&)parent\=([0-9]+)/"; 75 $content= preg_replace($search, '$@FORUMDISCUSSIONVIEWPARENT*$2*$3@$', $content); 76 77 // Link to forum discussion with relative syntax 78 $search="/(".$base."\/mod\/forum\/discuss.php\?d\=)([0-9]+)\#([0-9]+)/"; 79 $content= preg_replace($search, '$@FORUMDISCUSSIONVIEWINSIDE*$2*$3@$', $content); 80 81 // Link to forum discussion by discussionid 82 $search="/(".$base."\/mod\/forum\/discuss.php\?d\=)([0-9]+)/"; 83 $content= preg_replace($search, '$@FORUMDISCUSSIONVIEW*$2@$', $content); 84 85 return $content; 86 } 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body