Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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.

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

   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 classes used to handle backup settings
  20   *
  21   * @package     core_backup
  22   * @subpackage  moodle2
  23   * @category    backup
  24   * @copyright   2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  25   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  
  28  // TODO: Reduce these to the minimum because ui/dependencies are 100% separated
  29  
  30  // Root backup settings
  31  
  32  /**
  33   * root generic setting to store different things without dependencies
  34   */
  35  class backup_generic_setting extends root_backup_setting {}
  36  
  37  /**
  38   * root setting to handle backup file names (no dependencies nor anything else)
  39   */
  40  class backup_filename_setting extends backup_generic_setting {
  41  
  42      /**
  43       * Instantiates a setting object
  44       *
  45       * @param string $name Name of the setting
  46       * @param string $vtype Type of the setting, eg {@link base_setting::IS_TEXT}
  47       * @param mixed $value Value of the setting
  48       * @param bool $visibility Is the setting visible in the UI, eg {@link base_setting::VISIBLE}
  49       * @param int $status Status of the setting with regards to the locking, eg {@link base_setting::NOT_LOCKED}
  50       */
  51      public function __construct($name, $vtype, $value = null, $visibility = self::VISIBLE, $status = self::NOT_LOCKED) {
  52          parent::__construct($name, $vtype, $value, $visibility, $status);
  53      }
  54  
  55      public function set_ui_filename($label, $value, array $options = null) {
  56          $this->make_ui(self::UI_HTML_TEXTFIELD, $label, null, $options);
  57          $this->set_value($value);
  58      }
  59  }
  60  
  61  /**
  62   * root setting to control if backup will include user information
  63   * A lot of other settings are dependent of this (module's user info,
  64   * grades user info, messages, blogs...
  65   */
  66  class backup_users_setting extends backup_generic_setting {}
  67  
  68  /**
  69   * root setting to control if backup will include group information depends on @backup_users_setting
  70   *
  71   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  72   * @copyright 2014 Matt Sammarco
  73   */
  74  class backup_groups_setting extends backup_generic_setting {
  75  }
  76  
  77  /**
  78   * root setting to control if backup will include custom field information
  79   *
  80   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  81   * @copyright 2018 Daniel Neis Araujo
  82   */
  83  class backup_customfield_setting extends backup_generic_setting {
  84  }
  85  
  86  /**
  87   * root setting to control if backup will include activities or no.
  88   * A lot of other settings (_included at activity levels)
  89   * are dependent of this setting
  90   */
  91  class backup_activities_setting extends backup_generic_setting {}
  92  
  93  /**
  94   * root setting to control if backup will generate anonymized
  95   * user info or no, depends of @backup_users_setting so only is
  96   * available if the former is enabled (apart from security
  97   * that can change it
  98   */
  99  class backup_anonymize_setting extends root_backup_setting {}
 100  
 101  /**
 102   * root setting to control if backup will include
 103   * role assignments or no (any level), depends of @backup_users_setting
 104   * exactly in the same way than @backup_anonymize_setting so we extend from it
 105   */
 106  class backup_role_assignments_setting extends backup_anonymize_setting {}
 107  
 108  /**
 109   * root setting to control if backup will include
 110   * logs or no (any level), depends of @backup_users_setting
 111   * exactly in the same way than @backup_anonymize_setting so we extend from it
 112   */
 113  class backup_logs_setting extends backup_anonymize_setting {}
 114  
 115  /**
 116   * root setting to control if backup will include
 117   * comments or no (any level), depends of @backup_users_setting
 118   * exactly in the same way than @backup_anonymize_setting so we extend from it
 119   */
 120  class backup_comments_setting extends backup_anonymize_setting {}
 121  
 122  /**
 123   * root setting to control if backup will include badges or not,
 124   * depends on @backup_activities_setting
 125   */
 126  class backup_badges_setting extends backup_generic_setting {}
 127  
 128  /**
 129   * root setting to control if backup will include
 130   * calender events or no (any level), depends of @backup_users_setting
 131   * exactly in the same way than @backup_anonymize_setting so we extend from it
 132   */
 133  class backup_calendarevents_setting extends backup_anonymize_setting {}
 134  
 135  /**
 136   * root setting to control if backup will include
 137   * users completion data or no (any level), depends of @backup_users_setting
 138   * exactly in the same way than @backup_anonymize_setting so we extend from it
 139   */
 140  class backup_userscompletion_setting extends backup_anonymize_setting {}
 141  
 142  /**
 143   * root setting to control if backup will include competencies or not.
 144   */
 145  class backup_competencies_setting extends backup_generic_setting {
 146  
 147      /**
 148       * backup_competencies_setting constructor.
 149       */
 150      public function __construct() {
 151          $defaultvalue = false;
 152          $visibility = base_setting::HIDDEN;
 153          $status = base_setting::LOCKED_BY_CONFIG;
 154          if (\core_competency\api::is_enabled()) {
 155              $defaultvalue = true;
 156              $visibility = base_setting::VISIBLE;
 157              $status = base_setting::NOT_LOCKED;
 158          }
 159          parent::__construct('competencies', base_setting::IS_BOOLEAN, $defaultvalue, $visibility, $status);
 160      }
 161  }
 162  
 163  // Section backup settings
 164  
 165  /**
 166   * generic section setting to pass various settings between tasks and steps
 167   */
 168  class backup_section_generic_setting extends section_backup_setting {}
 169  
 170  /**
 171   * Setting to define if one section is included or no. Activities _included
 172   * settings depend of them if available
 173   */
 174  class backup_section_included_setting extends section_backup_setting {}
 175  
 176  /**
 177   * section backup setting to control if section will include
 178   * user information or no, depends of @backup_users_setting
 179   */
 180  class backup_section_userinfo_setting extends section_backup_setting {}
 181  
 182  
 183  // Activity backup settings
 184  
 185  /**
 186   * generic activity setting to pass various settings between tasks and steps
 187   */
 188  class backup_activity_generic_setting extends activity_backup_setting {}
 189  
 190  /**
 191   * activity backup setting to control if activity will
 192   * be included or no, depends of @backup_activities_setting and
 193   * optionally parent section included setting
 194   */
 195  class backup_activity_included_setting extends activity_backup_setting {}
 196  
 197  /**
 198   * activity backup setting to control if activity will include
 199   * user information or no, depends of @backup_users_setting
 200   */
 201  class backup_activity_userinfo_setting extends activity_backup_setting {}
 202  
 203  /**
 204   * Root setting to control if backup will include content bank content or no
 205   */
 206  class backup_contentbankcontent_setting extends backup_generic_setting {
 207  }