Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Defines backup_feedback_activity_task class
  20   *
  21   * @package     mod_feedback
  22   * @category    backup
  23   * @copyright   2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  24   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  require_once($CFG->dirroot . '/mod/feedback/backup/moodle2/backup_feedback_stepslib.php');
  30  require_once($CFG->dirroot . '/mod/feedback/backup/moodle2/backup_feedback_settingslib.php');
  31  
  32  /**
  33   * Provides the steps to perform one complete backup of the Feedback instance
  34   */
  35  class backup_feedback_activity_task extends backup_activity_task {
  36  
  37      /**
  38       * No specific settings for this activity
  39       */
  40      protected function define_my_settings() {
  41      }
  42  
  43      /**
  44       * Defines a backup step to store the instance data in the feedback.xml file
  45       */
  46      protected function define_my_steps() {
  47          // feedback only has one structure step
  48          $this->add_step(new backup_feedback_activity_structure_step('feedback structure', 'feedback.xml'));
  49      }
  50  
  51      /**
  52       * Encodes URLs to the index.php and view.php scripts
  53       *
  54       * @param string $content some HTML text that eventually contains URLs to the activity instance scripts
  55       * @return string the content with the URLs encoded
  56       */
  57      static public function encode_content_links($content) {
  58          global $CFG;
  59  
  60          $base = preg_quote($CFG->wwwroot, "/");
  61  
  62          // Link to the list of feedbacks
  63          $search="/(".$base."\/mod\/feedback\/index.php\?id\=)([0-9]+)/";
  64          $content= preg_replace($search, '$@FEEDBACKINDEX*$2@$', $content);
  65  
  66          // Link to feedback view by moduleid
  67          $search="/(".$base."\/mod\/feedback\/view.php\?id\=)([0-9]+)/";
  68          $content= preg_replace($search, '$@FEEDBACKVIEWBYID*$2@$', $content);
  69  
  70          // Link to feedback analyis by moduleid
  71          $search="/(".$base."\/mod\/feedback\/analysis.php\?id\=)([0-9]+)/";
  72          $content= preg_replace($search, '$@FEEDBACKANALYSISBYID*$2@$', $content);
  73  
  74          // Link to feedback entries by moduleid
  75          $search="/(".$base."\/mod\/feedback\/show_entries.php\?id\=)([0-9]+)/";
  76          $content= preg_replace($search, '$@FEEDBACKSHOWENTRIESBYID*$2@$', $content);
  77  
  78          return $content;
  79      }
  80  }