MDL-44152 mod_chat: unified @package use
[moodle.git] / mod / chat / backup / moodle2 / backup_chat_activity_task.class.php
CommitLineData
79447c50
DC
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/**
63baccbc 19 * Defines backup_chat_activity_task class
79447c50 20 *
63baccbc
DM
21 * @package mod_chat
22 * @category backup
23 * @copyright 2010 onwards Dongsheng Cai <dongsheng@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
79447c50 25 */
63baccbc
DM
26
27defined('MOODLE_INTERNAL') || die();
28
29require_once($CFG->dirroot . '/mod/chat/backup/moodle2/backup_chat_stepslib.php');
79447c50
DC
30
31/**
63baccbc 32 * Provides the steps to perform one complete backup of the Chat instance
79447c50
DC
33 */
34class backup_chat_activity_task extends backup_activity_task {
35
36 /**
63baccbc 37 * No specific settings for this activity
79447c50
DC
38 */
39 protected function define_my_settings() {
79447c50
DC
40 }
41
42 /**
63baccbc 43 * Defines a backup step to store the instance data in the chat.xml file
79447c50
DC
44 */
45 protected function define_my_steps() {
79447c50
DC
46 $this->add_step(new backup_chat_activity_structure_step('chat_structure', 'chat.xml'));
47 }
48
49 /**
63baccbc 50 * Encodes URLs to the index.php and view.php scripts
79447c50 51 *
63baccbc
DM
52 * @param string $content some HTML text that eventually contains URLs to the activity instance scripts
53 * @return string the content with the URLs encoded
79447c50
DC
54 */
55 static public function encode_content_links($content) {
56 global $CFG;
57
58 $base = preg_quote($CFG->wwwroot.'/mod/chat','#');
59
60 //Link to the list of chats
61 $pattern = "#(".$base."\/index.php\?id\=)([0-9]+)#";
62 $content = preg_replace($pattern, '$@CHATINDEX*$2@$', $content);
63
64 //Link to chat view by moduleid
65 $pattern = "#(".$base."\/view.php\?id\=)([0-9]+)#";
66 $content = preg_replace($pattern, '$@CHATVIEWBYID*$2@$', $content);
67
68 return $content;
69 }
70}