Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   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 Eloy Lafuente (stronk7) {@link http://stronk7.com}
  21   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  defined('MOODLE_INTERNAL') || die();
  25  
  26  require_once($CFG->dirroot . '/mod/chat/backup/moodle2/restore_chat_stepslib.php');
  27  
  28  /**
  29   * chat restore task that provides all the settings and steps to perform one
  30   * complete restore of the activity
  31   */
  32  class restore_chat_activity_task extends restore_activity_task {
  33  
  34      /**
  35       * Define (add) particular settings this activity can have
  36       */
  37      protected function define_my_settings() {
  38          // No particular settings for this activity.
  39      }
  40  
  41      /**
  42       * Define (add) particular steps this activity can have
  43       */
  44      protected function define_my_steps() {
  45          // Chat only has one structure step.
  46          $this->add_step(new restore_chat_activity_structure_step('chat_structure', 'chat.xml'));
  47      }
  48  
  49      /**
  50       * Define the contents in the activity that must be
  51       * processed by the link decoder
  52       */
  53      static public function define_decode_contents() {
  54          $contents = array();
  55  
  56          $contents[] = new restore_decode_content('chat', array('intro'), 'chat');
  57          $contents[] = new restore_decode_content('chat_messages', array('message'), 'chat_message');
  58  
  59          return $contents;
  60      }
  61  
  62      /**
  63       * Define the decoding rules for links belonging
  64       * to the activity to be executed by the link decoder
  65       */
  66      static public function define_decode_rules() {
  67          $rules = array();
  68  
  69          $rules[] = new restore_decode_rule('CHATVIEWBYID', '/mod/chat/view.php?id=$1', 'course_module');
  70          $rules[] = new restore_decode_rule('CHATINDEX', '/mod/chat/index.php?id=$1', 'course');
  71  
  72          return $rules;
  73  
  74      }
  75  
  76      /**
  77       * Define the restore log rules that will be applied
  78       * by the {@link restore_logs_processor} when restoring
  79       * chat logs. It must return one array
  80       * of {@link restore_log_rule} objects
  81       */
  82      static public function define_restore_log_rules() {
  83          $rules = array();
  84  
  85          $rules[] = new restore_log_rule('chat', 'add', 'view.php?id={course_module}', '{chat}');
  86          $rules[] = new restore_log_rule('chat', 'update', 'view.php?id={course_module}', '{chat}');
  87          $rules[] = new restore_log_rule('chat', 'view', 'view.php?id={course_module}', '{chat}');
  88          $rules[] = new restore_log_rule('chat', 'talk', 'view.php?id={course_module}', '{chat}');
  89          $rules[] = new restore_log_rule('chat', 'report', 'report.php?id={course_module}', '{chat}');
  90  
  91          return $rules;
  92      }
  93  
  94      /**
  95       * Define the restore log rules that will be applied
  96       * by the {@link restore_logs_processor} when restoring
  97       * course logs. It must return one array
  98       * of {@link restore_log_rule} objects
  99       *
 100       * Note this rules are applied when restoring course logs
 101       * by the restore final task, but are defined here at
 102       * activity level. All them are rules not linked to any module instance (cmid = 0)
 103       */
 104      static public function define_restore_log_rules_for_course() {
 105          $rules = array();
 106  
 107          $rules[] = new restore_log_rule('chat', 'view all', 'index.php?id={course}', null);
 108  
 109          return $rules;
 110      }
 111  }