Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

   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   * Class for exporting partial database data.
  19   *
  20   * @package    mod_data
  21   * @copyright  2017 Juan Leyva <juan@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace mod_data\external;
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  use core\external\exporter;
  28  use renderer_base;
  29  use external_files;
  30  use external_util;
  31  
  32  /**
  33   * Class for exporting partial database data (some fields are only viewable by admins).
  34   *
  35   * @copyright  2017 Juan Leyva <juan@moodle.com>
  36   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class database_summary_exporter extends exporter {
  39  
  40      protected static function define_properties() {
  41  
  42          return array(
  43              'id' => array(
  44                  'type' => PARAM_INT,
  45                  'description' => 'Database id'),
  46              'course' => array(
  47                  'type' => PARAM_INT,
  48                  'description' => 'Course id'),
  49              'name' => array(
  50                  'type' => PARAM_RAW,
  51                  'description' => 'Database name'),
  52              'intro' => array(
  53                  'type' => PARAM_RAW,
  54                  'description' => 'The Database intro',
  55              ),
  56              'introformat' => array(
  57                  'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
  58                  'type' => PARAM_INT,
  59                  'default' => FORMAT_MOODLE
  60              ),
  61              'comments' => array(
  62                  'type' => PARAM_BOOL,
  63                  'description' => 'comments enabled',
  64              ),
  65              'timeavailablefrom' => array(
  66                  'type' => PARAM_INT,
  67                  'description' => 'timeavailablefrom field',
  68              ),
  69              'timeavailableto' => array(
  70                  'type' => PARAM_INT,
  71                  'description' => 'timeavailableto field',
  72              ),
  73              'timeviewfrom' => array(
  74                  'type' => PARAM_INT,
  75                  'description' => 'timeviewfrom field',
  76              ),
  77              'timeviewto' => array(
  78                  'type' => PARAM_INT,
  79                  'description' => 'timeviewto field',
  80              ),
  81              'requiredentries' => array(
  82                  'type' => PARAM_INT,
  83                  'description' => 'requiredentries field',
  84              ),
  85              'requiredentriestoview' => array(
  86                  'type' => PARAM_INT,
  87                  'description' => 'requiredentriestoview field',
  88              ),
  89              'maxentries' => array(
  90                  'type' => PARAM_INT,
  91                  'description' => 'maxentries field',
  92              ),
  93              'rssarticles' => array(
  94                  'type' => PARAM_INT,
  95                  'description' => 'rssarticles field',
  96              ),
  97              'singletemplate' => array(
  98                  'type' => PARAM_RAW,
  99                  'description' => 'singletemplate field',
 100                  'null' => NULL_ALLOWED,
 101              ),
 102              'listtemplate' => array(
 103                  'type' => PARAM_RAW,
 104                  'description' => 'listtemplate field',
 105                  'null' => NULL_ALLOWED,
 106              ),
 107              'listtemplateheader' => array(
 108                  'type' => PARAM_RAW,
 109                  'description' => 'listtemplateheader field',
 110                  'null' => NULL_ALLOWED,
 111              ),
 112              'listtemplatefooter' => array(
 113                  'type' => PARAM_RAW,
 114                  'description' => 'listtemplatefooter field',
 115                  'null' => NULL_ALLOWED,
 116              ),
 117              'addtemplate' => array(
 118                  'type' => PARAM_RAW,
 119                  'description' => 'addtemplate field',
 120                  'null' => NULL_ALLOWED,
 121              ),
 122              'rsstemplate' => array(
 123                  'type' => PARAM_RAW,
 124                  'description' => 'rsstemplate field',
 125                  'null' => NULL_ALLOWED,
 126              ),
 127              'rsstitletemplate' => array(
 128                  'type' => PARAM_RAW,
 129                  'description' => 'rsstitletemplate field',
 130                  'null' => NULL_ALLOWED,
 131              ),
 132              'csstemplate' => array(
 133                  'type' => PARAM_RAW,
 134                  'description' => 'csstemplate field',
 135                  'null' => NULL_ALLOWED,
 136              ),
 137              'jstemplate' => array(
 138                  'type' => PARAM_RAW,
 139                  'description' => 'jstemplate field',
 140                  'null' => NULL_ALLOWED,
 141              ),
 142              'asearchtemplate' => array(
 143                  'type' => PARAM_RAW,
 144                  'description' => 'asearchtemplate field',
 145                  'null' => NULL_ALLOWED,
 146              ),
 147              'approval' => array(
 148                  'type' => PARAM_BOOL,
 149                  'description' => 'approval field',
 150              ),
 151              'manageapproved' => array(
 152                  'type' => PARAM_BOOL,
 153                  'description' => 'manageapproved field',
 154              ),
 155              'scale' => array(
 156                  'type' => PARAM_INT,
 157                  'description' => 'scale field',
 158                  'optional' => true,
 159              ),
 160              'assessed' => array(
 161                  'type' => PARAM_INT,
 162                  'description' => 'assessed field',
 163                  'optional' => true,
 164              ),
 165              'assesstimestart' => array(
 166                  'type' => PARAM_INT,
 167                  'description' => 'assesstimestart field',
 168                  'optional' => true,
 169              ),
 170              'assesstimefinish' => array(
 171                  'type' => PARAM_INT,
 172                  'description' => 'assesstimefinish field',
 173                  'optional' => true,
 174              ),
 175              'defaultsort' => array(
 176                  'type' => PARAM_INT,
 177                  'description' => 'defaultsort field',
 178              ),
 179              'defaultsortdir' => array(
 180                  'type' => PARAM_INT,
 181                  'description' => 'defaultsortdir field',
 182              ),
 183              'editany' => array(
 184                  'type' => PARAM_BOOL,
 185                  'description' => 'editany field (not used any more)',
 186                  'optional' => true,
 187              ),
 188              'notification' => array(
 189                  'type' => PARAM_INT,
 190                  'description' => 'notification field (not used any more)',
 191                  'optional' => true,
 192              ),
 193              'timemodified' => array(
 194                  'type' => PARAM_INT,
 195                  'description' => 'Time modified',
 196                  'optional' => true,
 197              ),
 198          );
 199      }
 200  
 201      protected static function define_related() {
 202          return array(
 203              'context' => 'context'
 204          );
 205      }
 206  
 207      protected static function define_other_properties() {
 208          return array(
 209              'coursemodule' => array(
 210                  'type' => PARAM_INT
 211              ),
 212              'introfiles' => array(
 213                  'type' => external_files::get_properties_for_exporter(),
 214                  'multiple' => true,
 215                  'optional' => true,
 216              ),
 217          );
 218      }
 219  
 220      protected function get_other_values(renderer_base $output) {
 221          $context = $this->related['context'];
 222  
 223          $values = array(
 224              'coursemodule' => $context->instanceid,
 225              'introfiles' => external_util::get_area_files($context->id, 'mod_data', 'intro', false, false),
 226          );
 227  
 228          return $values;
 229      }
 230  
 231      /**
 232       * Get the formatting parameters for the intro.
 233       *
 234       * @return array
 235       */
 236      protected function get_format_parameters_for_intro() {
 237          return [
 238              'component' => 'mod_data',
 239              'filearea' => 'intro',
 240              'options' => array('noclean' => true),
 241          ];
 242      }
 243  }