Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

   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   * Class for the structure used for restore BigBlueButtonBN.
  19   *
  20   * @package   mod_bigbluebuttonbn
  21   * @copyright 2010 onwards, Blindside Networks Inc
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   * @author    Fred Dixon  (ffdixon [at] blindsidenetworks [dt] com)
  24   * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
  25   */
  26  
  27  /**
  28   * Define all the restore steps that will be used by the restore_url_activity_task.
  29   *
  30   * @package   mod_bigbluebuttonbn
  31   * @copyright 2010 onwards, Blindside Networks Inc
  32   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  class restore_bigbluebuttonbn_activity_structure_step extends restore_activity_structure_step {
  35      /**
  36       * Structure step to restore one bigbluebuttonbn activity.
  37       *
  38       * @return array
  39       */
  40      protected function define_structure() {
  41          $paths = [];
  42          $bbb = new restore_path_element('bigbluebuttonbn', '/activity/bigbluebuttonbn');
  43          $paths[] = $bbb;
  44          $paths[] = new restore_path_element('bigbluebuttonbn_logs', '/activity/bigbluebuttonbn/logs/log');
  45          $paths[] = new restore_path_element('bigbluebuttonbn_recordings', '/activity/bigbluebuttonbn/recordings/recording');
  46          $this->add_subplugin_structure('bbbext', $bbb);
  47          // Return the paths wrapped into standard activity structure.
  48          return $this->prepare_activity_structure($paths);
  49      }
  50  
  51      /**
  52       * Process a bigbluebuttonbn restore.
  53       *
  54       * @param array $data The data in object form
  55       * @return void
  56       */
  57      protected function process_bigbluebuttonbn(array $data) {
  58          global $DB;
  59          $data = (object) $data;
  60          $data->course = $this->get_courseid();
  61          $data->timemodified = $this->apply_date_offset($data->timemodified);
  62          // Check if we are in backup::MODE_IMPORT (we set a new meetingid) or backup::MODE_GENERAL (we keep the same meetingid).
  63          if ($this->get_task()->get_info()->mode == backup::MODE_IMPORT || empty($data->meetingid)) {
  64              // We are in backup::MODE_IMPORT, we need to renew the meetingid.
  65              $data->meetingid = \mod_bigbluebuttonbn\meeting::get_unique_meetingid_seed();
  66          }
  67          // Insert the bigbluebuttonbn record.
  68          $newitemid = $DB->insert_record('bigbluebuttonbn', $data);
  69          // Immediately after inserting "activity" record, call this.
  70          $this->apply_activity_instance($newitemid);
  71      }
  72  
  73      /**
  74       * Process a bigbluebuttonbn_logs restore (additional table).
  75       *
  76       * @param array $data The data in object form
  77       * @return void
  78       */
  79      protected function process_bigbluebuttonbn_logs(array $data) {
  80          global $DB;
  81          $data = (object) $data;
  82          // Apply modifications.
  83          $data->courseid = $this->get_mappingid('course', $data->courseid);
  84          $data->bigbluebuttonbnid = $this->get_new_parentid('bigbluebuttonbn');
  85          $data->userid = $this->get_mappingid('user', $data->userid);
  86          $data->timecreated = $this->apply_date_offset($data->timecreated);
  87          // Insert the bigbluebuttonbn_logs record.
  88          $newitemid = $DB->insert_record('bigbluebuttonbn_logs', $data);
  89          // Immediately after inserting associated record, call this.
  90          $this->set_mapping('bigbluebuttonbn_logs', $data->id, $newitemid);
  91      }
  92  
  93      /**
  94       * Process a bigbluebuttonbn_recordings restore (additional table).
  95       *
  96       * @param array $data The data in object form
  97       * @return void
  98       */
  99      protected function process_bigbluebuttonbn_recordings(array $data) {
 100          global $DB;
 101          $data = (object) $data;
 102          // Apply modifications.
 103          $data->courseid = $this->get_mappingid('course', $data->courseid);
 104          $data->bigbluebuttonbnid = $this->get_new_parentid('bigbluebuttonbn');
 105          $data->timecreated = $this->apply_date_offset($data->timecreated);
 106          // Insert the bigbluebuttonbn_recordings record.
 107          $newitemid = $DB->insert_record('bigbluebuttonbn_recordings', $data);
 108          // Immediately after inserting associated record, call this.
 109          $this->set_mapping('bigbluebuttonbn_recordings', $data->id, $newitemid);
 110      }
 111  
 112      /**
 113       * Actions to be executed after the restore is completed
 114       *
 115       * @return void
 116       */
 117      protected function after_execute() {
 118          // Add bigbluebuttonbn related files, no need to match by itemname (just internally handled context).
 119          $this->add_related_files('mod_bigbluebuttonbn', 'intro', null);
 120      }
 121  }