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.
   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   * Plugin administration pages are defined here.
  19   *
  20   * @package     tool_brickfield
  21   * @category    admin
  22   * @copyright   2020 Brickfield Education Labs, https://www.brickfield.ie - Author: Karen Holland
  23   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  use tool_brickfield\accessibility;
  27  use tool_brickfield\manager;
  28  use tool_brickfield\analysis;
  29  use tool_brickfield\output\renderer;
  30  use tool_brickfield\registration;
  31  
  32  defined('MOODLE_INTERNAL') || die();
  33  
  34  $accessibilitydisabled = !accessibility::is_accessibility_enabled();
  35  
  36  if ($hassiteconfig) {
  37      // Add an enable subsystem setting to the "Advanced features" settings page.
  38      $optionalsubsystems = $ADMIN->locate('optionalsubsystems');
  39      $optionalsubsystems->add(new admin_setting_configcheckbox(
  40          'enableaccessibilitytools',
  41          new lang_string('enableaccessibilitytools', manager::PLUGINNAME),
  42          new lang_string('enableaccessibilitytools_desc', manager::PLUGINNAME),
  43          1,
  44          1,
  45          0
  46      ));
  47  }
  48  
  49  $moodleurl = accessibility::get_plugin_url();
  50  if ($hassiteconfig) {
  51      $ADMIN->add(
  52          'tools',
  53          new admin_category('brickfieldfolder', get_string('accessibility', manager::PLUGINNAME), $accessibilitydisabled)
  54      );
  55  
  56      $ADMIN->add(
  57          'brickfieldfolder',
  58          new admin_externalpage(
  59              'tool_brickfield_activation',
  60              get_string('activationform', manager::PLUGINNAME),
  61              manager::registration_url(),
  62              'moodle/site:config'
  63          )
  64      );
  65  
  66      $settings = new admin_settingpage(manager::PLUGINNAME, get_string('settings', manager::PLUGINNAME));
  67  
  68      $settings->add(new admin_setting_configcheckbox(
  69          manager::PLUGINNAME . '/analysistype',
  70          get_string('analysistype', manager::PLUGINNAME),
  71          get_string('analysistype_desc', manager::PLUGINNAME),
  72          analysis::ANALYSISDISABLED,
  73          analysis::ANALYSISBYREQUEST,
  74          analysis::ANALYSISDISABLED
  75      ));
  76  
  77      $settings->add(new admin_setting_configcheckbox(
  78          manager::PLUGINNAME . '/deletehistoricaldata',
  79          get_string('deletehistoricaldata', manager::PLUGINNAME),
  80          '',
  81          1
  82      ));
  83  
  84      $settings->add(new admin_setting_configtext(
  85          manager::PLUGINNAME . '/batch',
  86          get_string('batch', manager::PLUGINNAME),
  87          '',
  88          1000,
  89          PARAM_INT
  90      ));
  91  
  92      $settings->add(new admin_setting_configtext(
  93          manager::PLUGINNAME . '/perpage',
  94          get_string('perpage', manager::PLUGINNAME),
  95          '',
  96          50,
  97          PARAM_INT));
  98  
  99      $ADMIN->add('brickfieldfolder', $settings);
 100  
 101      $ADMIN->add('brickfieldfolder', new admin_externalpage('tool_brickfield_tool',
 102          get_string('tools', manager::PLUGINNAME),
 103          $moodleurl,
 104          accessibility::get_capability_name('viewsystemtools')
 105      ));
 106  }
 107  
 108  // Add the reports link if the toolkit is enabled, and is either registered, or the user has the ability to register it.
 109  $showreports = has_capability('moodle/site:config', \context_system::instance());
 110  $showreports = $showreports || (new registration())->toolkit_is_active();
 111  
 112  // Create a link to the main page in the reports menu.
 113  $ADMIN->add(
 114      'reports',
 115      new admin_externalpage(
 116          'tool_brickfield_reports',
 117          get_string('pluginname', manager::PLUGINNAME),
 118          $moodleurl,
 119          accessibility::get_capability_name('viewsystemtools'),
 120          $accessibilitydisabled || !$showreports
 121      )
 122  );