Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
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.
8
//
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.
13
//
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/>.
16
 
17
/**
18
 * @package    mod_chat
19
 * @subpackage backup-moodle2
20
 * @copyright 2010 onwards Dongsheng Cai <dongsheng@moodle.com>
21
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
/**
25
 * Define all the backup steps that will be used by the backup_chat_activity_task
26
 */
27
class backup_chat_activity_structure_step extends backup_activity_structure_step {
28
    protected function define_structure() {
29
        $userinfo = $this->get_setting_value('userinfo');
30
 
31
        // Define each element separated.
32
        $chat = new backup_nested_element('chat', array('id'), array(
33
            'name', 'intro', 'introformat', 'keepdays', 'studentlogs',
34
            'chattime', 'schedule', 'timemodified'));
35
        $messages = new backup_nested_element('messages');
36
 
37
        $message = new backup_nested_element('message', array('id'), array(
38
            'userid', 'groupid', 'system', 'message_text', 'timestamp'));
39
 
40
        // It is not cool to have two tags with same name, so we need to rename message field to message_text.
41
        $message->set_source_alias('message', 'message_text');
42
        // Renamed 'issystem' into 'system', for backward compatibility: 'system' is now a reserved word in MySQL 8.0.3+.
43
        $message->set_source_alias('issystem', 'system');
44
 
45
        // Build the tree.
46
        $chat->add_child($messages);
47
        $messages->add_child($message);
48
 
49
        // Define sources.
50
        $chat->set_source_table('chat', array('id' => backup::VAR_ACTIVITYID));
51
 
52
        // User related messages only happen if we are including user info.
53
        if ($userinfo) {
54
            $message->set_source_table('chat_messages', array('chatid' => backup::VAR_PARENTID));
55
        }
56
 
57
        // Define id annotations.
58
        $message->annotate_ids('user', 'userid');
59
        $message->annotate_ids('group', 'groupid');
60
 
61
        // Annotate the file areas in chat module.
62
        $chat->annotate_files('mod_chat', 'intro', null); // The chat_intro area doesn't use itemid.
63
 
64
        // Return the root element (chat), wrapped into standard activity structure.
65
        return $this->prepare_activity_structure($chat);
66
    }
67
}