[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/chat/backup/moodle2/ -> backup_chat_stepslib.php (source)

   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  
  43          // Build the tree.
  44          $chat->add_child($messages);
  45              $messages->add_child($message);
  46  
  47          // Define sources.
  48          $chat->set_source_table('chat', array('id' => backup::VAR_ACTIVITYID));
  49  
  50          // User related messages only happen if we are including user info.
  51          if ($userinfo) {
  52              $message->set_source_table('chat_messages', array('chatid' => backup::VAR_PARENTID));
  53          }
  54  
  55          // Define id annotations.
  56          $message->annotate_ids('user', 'userid');
  57          $message->annotate_ids('group', 'groupid');
  58  
  59          // Annotate the file areas in chat module.
  60          $chat->annotate_files('mod_chat', 'intro', null); // The chat_intro area doesn't use itemid.
  61  
  62          // Return the root element (chat), wrapped into standard activity structure.
  63          return $this->prepare_activity_structure($chat);
  64      }
  65  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1