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.
   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   * Privacy Subsystem implementation for datafield_textarea.
  18   *
  19   * @package    datafield_textarea
  20   * @copyright  2018 Carlos Escobedo <carlos@moodle.com>
  21   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  namespace datafield_textarea\privacy;
  24  
  25  use core_privacy\local\request\transform;
  26  use core_privacy\local\request\writer;
  27  use mod_data\privacy\datafield_provider;
  28  
  29  defined('MOODLE_INTERNAL') || die();
  30  /**
  31   * Privacy Subsystem for datafield_textarea implementing null_provider.
  32   *
  33   * @copyright  2018 Carlos Escobedo <carlos@moodle.com>
  34   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class provider implements \core_privacy\local\metadata\null_provider,
  37          datafield_provider {
  38      /**
  39       * Get the language string identifier with the component's language
  40       * file to explain why this plugin stores no data.
  41       *
  42       * @return  string
  43       */
  44      public static function get_reason() : string {
  45          return 'privacy:metadata';
  46      }
  47  
  48      /**
  49       * Exports data about one record in {data_content} table.
  50       *
  51       * @param \context_module $context
  52       * @param \stdClass $recordobj record from DB table {data_records}
  53       * @param \stdClass $fieldobj record from DB table {data_fields}
  54       * @param \stdClass $contentobj record from DB table {data_content}
  55       * @param \stdClass $defaultvalue pre-populated default value that most of plugins will use
  56       */
  57      public static function export_data_content($context, $recordobj, $fieldobj, $contentobj, $defaultvalue) {
  58          $subcontext = [$recordobj->id, $contentobj->id];
  59          $defaultvalue->content = writer::with_context($context)
  60              ->rewrite_pluginfile_urls($subcontext, 'mod_data', 'content', $contentobj->id,
  61              $defaultvalue->content);
  62          $defaultvalue->contentformat = $defaultvalue->content1;
  63          unset($defaultvalue->content1);
  64  
  65          $defaultvalue->field['autolink'] = transform::yesno($fieldobj->param1);
  66          $defaultvalue->field['rows'] = $fieldobj->param3;
  67          $defaultvalue->field['cols'] = $fieldobj->param2;
  68          if ($fieldobj->param5) {
  69              $defaultvalue->field['maxbytes'] = $fieldobj->param5;
  70          }
  71          writer::with_context($context)->export_data($subcontext, $defaultvalue);
  72      }
  73  
  74      /**
  75       * Allows plugins to delete locally stored data.
  76       *
  77       * @param \context_module $context
  78       * @param \stdClass $recordobj record from DB table {data_records}
  79       * @param \stdClass $fieldobj record from DB table {data_fields}
  80       * @param \stdClass $contentobj record from DB table {data_content}
  81       */
  82      public static function delete_data_content($context, $recordobj, $fieldobj, $contentobj) {
  83  
  84      }
  85  }