Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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   * Displays the list of remote peers we can enrol our users to
  20   *
  21   * @package    mnetservice
  22   * @subpackage enrol
  23   * @copyright  2010 David Mudrak <david@moodle.com>
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  require(__DIR__.'/../../../config.php');
  28  require_once($CFG->libdir.'/adminlib.php');
  29  require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');
  30  
  31  admin_externalpage_setup('mnetenrol');
  32  $service = mnetservice_enrol::get_instance();
  33  
  34  echo $OUTPUT->header();
  35  echo $OUTPUT->render(mnet_get_deprecation_notice());
  36  echo $OUTPUT->heading_with_help(get_string('clientname', 'mnetservice_enrol'), 'clientname', 'mnetservice_enrol');
  37  
  38  if (!$service->is_available()) {
  39      echo $OUTPUT->box(get_string('mnetdisabled','mnet'), 'noticebox');
  40      echo $OUTPUT->footer();
  41      die();
  42  }
  43  
  44  $roamingusers = get_users_by_capability(context_system::instance(), 'moodle/site:mnetlogintoremote', 'u.id');
  45  if (empty($roamingusers)) {
  46      $capname = get_string('site:mnetlogintoremote', 'role');
  47      $url = new moodle_url('/admin/roles/manage.php');
  48      echo notice(get_string('noroamingusers', 'mnetservice_enrol', $capname), $url);
  49  }
  50  unset($roamingusers);
  51  
  52  // remote hosts that may publish remote enrolment service and we are subscribed to it
  53  $hosts = $service->get_remote_publishers();
  54  
  55  if (empty($hosts)) {
  56      echo $OUTPUT->box(get_string('nopublishers', 'mnetservice_enrol'), 'noticebox');
  57      echo $OUTPUT->footer();
  58      die();
  59  }
  60  
  61  $table = new html_table();
  62  $table->attributes['class'] = 'generaltable remotehosts';
  63  $table->head = array(
  64      get_string('hostappname', 'mnetservice_enrol'),
  65      get_string('hostname', 'mnetservice_enrol'),
  66      get_string('hosturl', 'mnetservice_enrol'),
  67      get_string('action')
  68  );
  69  foreach ($hosts as $host) {
  70      $hostlink = html_writer::link(new moodle_url($host->hosturl), s($host->hosturl));
  71      $editbtn  = $OUTPUT->single_button(new moodle_url('/mnet/service/enrol/host.php', array('id'=>$host->id)),
  72                                         get_string('editenrolments', 'mnetservice_enrol'), 'get');
  73      $table->data[] = array(s($host->appname), s($host->hostname), $hostlink, $editbtn);
  74  }
  75  echo html_writer::table($table);
  76  
  77  echo $OUTPUT->footer();