|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00028 class backup_chat_activity_structure_step extends backup_activity_structure_step { 00029 protected function define_structure() { 00030 $userinfo = $this->get_setting_value('userinfo'); 00031 00032 // Define each element separated 00033 $chat = new backup_nested_element('chat', array('id'), array( 00034 'name', 'intro', 'introformat', 'keepdays', 'studentlogs', 00035 'chattime', 'schedule', 'timemodified')); 00036 $messages = new backup_nested_element('messages'); 00037 00038 $message = new backup_nested_element('message', array('id'), array( 00039 'userid', 'groupid', 'system', 'message_text', 'timestamp')); 00040 00041 // it is not cool to have two tags with same name, so we need to rename message field to message_text 00042 $message->set_source_alias('message', 'message_text'); 00043 00044 // Build the tree 00045 $chat->add_child($messages); 00046 $messages->add_child($message); 00047 00048 // Define sources 00049 $chat->set_source_table('chat', array('id' => backup::VAR_ACTIVITYID)); 00050 00051 // User related messages only happen if we are including user info 00052 if ($userinfo) { 00053 $message->set_source_table('chat_messages', array('chatid'=>backup::VAR_PARENTID)); 00054 } 00055 00056 // Define id annotations 00057 $message->annotate_ids('user', 'userid'); 00058 $message->annotate_ids('group', 'groupid'); 00059 00060 // Annotate the file areas in chat module 00061 $chat->annotate_files('mod_chat', 'intro', null); // chat_intro area don't use itemid 00062 00063 // Return the root element (chat), wrapped into standard activity structure 00064 return $this->prepare_activity_structure($chat); 00065 } 00066 }