Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 400]

   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->heading_with_help(get_string('clientname', 'mnetservice_enrol'), 'clientname', 'mnetservice_enrol');
  36  
  37  if (!$service->is_available()) {
  38      echo $OUTPUT->box(get_string('mnetdisabled','mnet'), 'noticebox');
  39      echo $OUTPUT->footer();
  40      die();
  41  }
  42  
  43  $roamingusers = get_users_by_capability(context_system::instance(), 'moodle/site:mnetlogintoremote', 'u.id');
  44  if (empty($roamingusers)) {
  45      $capname = get_string('site:mnetlogintoremote', 'role');
  46      $url = new moodle_url('/admin/roles/manage.php');
  47      echo notice(get_string('noroamingusers', 'mnetservice_enrol', $capname), $url);
  48  }
  49  unset($roamingusers);
  50  
  51  // remote hosts that may publish remote enrolment service and we are subscribed to it
  52  $hosts = $service->get_remote_publishers();
  53  
  54  if (empty($hosts)) {
  55      echo $OUTPUT->box(get_string('nopublishers', 'mnetservice_enrol'), 'noticebox');
  56      echo $OUTPUT->footer();
  57      die();
  58  }
  59  
  60  $table = new html_table();
  61  $table->attributes['class'] = 'generaltable remotehosts';
  62  $table->head = array(
  63      get_string('hostappname', 'mnetservice_enrol'),
  64      get_string('hostname', 'mnetservice_enrol'),
  65      get_string('hosturl', 'mnetservice_enrol'),
  66      get_string('action')
  67  );
  68  foreach ($hosts as $host) {
  69      $hostlink = html_writer::link(new moodle_url($host->hosturl), s($host->hosturl));
  70      $editbtn  = $OUTPUT->single_button(new moodle_url('/mnet/service/enrol/host.php', array('id'=>$host->id)),
  71                                         get_string('editenrolments', 'mnetservice_enrol'), 'get');
  72      $table->data[] = array(s($host->appname), s($host->hostname), $hostlink, $editbtn);
  73  }
  74  echo html_writer::table($table);
  75  
  76  echo $OUTPUT->footer();