Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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   * This file defines a link to another Moodle subsystem.
  19   *
  20   * @package core_privacy
  21   * @copyright 2018 Zig Tan <zig@moodle.com>
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace core_privacy\local\metadata\types;
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  /**
  29   * The subsystem link type.
  30   *
  31   * @copyright 2018 Zig Tan <zig@moodle.com>
  32   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  class subsystem_link implements type {
  35  
  36      /**
  37       * @var The name of the core subsystem to link.
  38       */
  39      protected $name;
  40  
  41      /**
  42       * @var array The list of data names and descriptions.
  43       */
  44      protected $privacyfields;
  45  
  46      /**
  47       * @var string A description of what this subsystem is used to store.
  48       */
  49      protected $summary;
  50  
  51      /**
  52       * Constructor for the subsystem_link.
  53       *
  54       * @param   string  $name The name of the subsystem to link.
  55       * @param   array   $privacyfields An optional array of fields and their descriptions.
  56       * @param   string  $summary A description of what is stored within this subsystem.
  57       */
  58      public function __construct($name, array $privacyfields = [], $summary = '') {
  59          if (debugging('', DEBUG_DEVELOPER)) {
  60              $teststring = clean_param($summary, PARAM_STRINGID);
  61              if ($teststring !== $summary) {
  62                  debugging("Summary information for use of the '{$name}' subsystem " .
  63                      "has an invalid langstring identifier: '{$summary}'",
  64                      DEBUG_DEVELOPER);
  65              }
  66          }
  67  
  68          $this->name = $name;
  69          $this->privacyfields = $privacyfields;
  70          $this->summary = $summary;
  71      }
  72  
  73      /**
  74       * Function to return the name of this subsystem_link type.
  75       *
  76       * @return string $name
  77       */
  78      public function get_name() {
  79          return $this->name;
  80      }
  81  
  82      /**
  83       * A subsystem link does not define any fields itself.
  84       *
  85       * @return  array
  86       */
  87      public function get_privacy_fields() : array {
  88          return $this->privacyfields;
  89      }
  90  
  91      /**
  92       * A summary of what this subsystem is used for.
  93       *
  94       * @return string $summary
  95       */
  96      public function get_summary() {
  97          return $this->summary;
  98      }
  99  }