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   * Registration configuration for the Brickfield too.
  19   *
  20   * @package    tool_brickfield
  21   * @author     2020 JM Tomas <jmtomas@tresipunt.com>
  22   * @copyright  2020 Brickfield Education Labs https://www.brickfield.ie
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
  24   */
  25  
  26  use tool_brickfield\brickfieldconnect;
  27  use tool_brickfield\form\registration_form;
  28  use tool_brickfield\manager;
  29  use tool_brickfield\registration;
  30  
  31  require(__DIR__ . '/../../../config.php');
  32  
  33  global $CFG, $OUTPUT, $PAGE;
  34  require_once($CFG->libdir . '/adminlib.php');
  35  require_once($CFG->libdir . '/moodlelib.php');
  36  
  37  // If this feature has been disabled, do nothing.
  38  \tool_brickfield\accessibility::require_accessibility_enabled();
  39  
  40  admin_externalpage_setup('tool_brickfield_activation');
  41  $thisurl = new moodle_url(\tool_brickfield\accessibility::get_plugin_url().'/registration.php');
  42  $PAGE->set_url($thisurl);
  43  
  44  $context = context_system::instance();
  45  $PAGE->set_context($context);
  46  $PAGE->set_title(get_string('registration', manager::PLUGINNAME));
  47  $PAGE->set_heading(get_string('registration', manager::PLUGINNAME));
  48  
  49  $registrationform = new registration_form();
  50  
  51  echo $OUTPUT->header();
  52  
  53  echo html_writer::img($OUTPUT->image_url('brickfield-logo-small', manager::PLUGINNAME), 'logo',
  54      ['style' => 'display: block; margin: 0 auto; float: right;']);
  55  echo $OUTPUT->heading(get_string('pluginname', manager::PLUGINNAME), 3);
  56  
  57  $registration = new registration();
  58  $reginfo = get_string('registrationinfo', manager::PLUGINNAME, $registration->get_termsurl());
  59  echo format_text($reginfo, FORMAT_HTML, ['noclean' => true]);
  60  
  61  if ($fromform = $registrationform->get_data()) {
  62      if (!$registration->set_keys_for_registration($fromform->key, $fromform->hash)) {
  63          echo $OUTPUT->notification(get_string('hashincorrect', manager::PLUGINNAME), 'notifyproblem');
  64      }
  65  }
  66  
  67  if (!$registration->toolkit_is_active()) {
  68      echo $OUTPUT->notification(get_string('inactive', manager::PLUGINNAME), 'error');
  69  } else if ($registration->validation_pending()) {
  70      if ($registration->validation_error()) {
  71          echo $OUTPUT->notification(get_string('validationerror', manager::PLUGINNAME), 'error');
  72      } else {
  73          echo $OUTPUT->notification(get_string('notvalidated', manager::PLUGINNAME), 'warning');
  74      }
  75  } else {
  76      echo $OUTPUT->notification(get_string('activated', manager::PLUGINNAME), 'success');
  77  }
  78  
  79  $keyinfo = get_string('activationinfo', manager::PLUGINNAME, $registration->get_regurl());
  80  echo format_text($keyinfo, FORMAT_HTML, ['noclean' => true]);
  81  
  82  $registrationform->display();
  83  echo $OUTPUT->footer();