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 310 and 311] [Versions 39 and 311]

   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   * Google Docs repository data generator
  19   *
  20   * @package    repository_googledocs
  21   * @category   test
  22   * @copyright  2013 Frédéric Massart
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  use \core\oauth2\issuer;
  27  use \core\oauth2\endpoint;
  28  
  29  /**
  30   * Google Docs repository data generator class
  31   *
  32   * @package    repository_googledocs
  33   * @category   test
  34   * @copyright  2013 Frédéric Massart
  35   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  36   */
  37  class repository_googledocs_generator extends testing_repository_generator {
  38  
  39      /**
  40       * Fill in type record defaults.
  41       *
  42       * @param array $record
  43       * @return array
  44       */
  45      protected function prepare_type_record(array $record) {
  46          $record = parent::prepare_type_record($record);
  47          $issuerrecord = (object) [
  48              'name' => 'Google',
  49              'image' => 'https://accounts.google.com/favicon.ico',
  50              'baseurl' => 'https://accounts.google.com/',
  51              'loginparamsoffline' => 'access_type=offline&prompt=consent',
  52              'showonloginpage' => issuer::EVERYWHERE
  53          ];
  54  
  55          $issuer = new issuer(0, $issuerrecord);
  56          $issuer->create();
  57  
  58          $endpointrecord = (object) [
  59              'issuerid' => $issuer->get('id'),
  60              'name' => 'discovery_endpoint',
  61              'url' => 'https://accounts.google.com/.well-known/openid-configuration'
  62          ];
  63          $endpoint = new endpoint(0, $endpointrecord);
  64          $endpoint->create();
  65  
  66          if (!isset($record['issuerid'])) {
  67              $record['issuerid'] = $issuer->get('id');
  68          }
  69          if (!isset($record['defaultreturntype'])) {
  70              $record['defaultreturntype'] = FILE_INTERNAL;
  71          }
  72          if (!isset($record['supportedreturntypes'])) {
  73              $record['supportedreturntypes'] = 'both';
  74          }
  75          if (!isset($record['documentformat'])) {
  76              $record['documentformat'] = 'pdf';
  77          }
  78          if (!isset($record['presentationformat'])) {
  79              $record['presentationformat'] = 'pdf';
  80          }
  81          if (!isset($record['drawingformat'])) {
  82              $record['drawingformat'] = 'pdf';
  83          }
  84          if (!isset($record['spreadsheetformat'])) {
  85              $record['spreadsheetformat'] = 'pdf';
  86          }
  87          return $record;
  88      }
  89  
  90  }