Search moodle.org's
Developer Documentation

See Release Notes

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