Merge branch 'MDL-73169-integration-master' of git://github.com/mihailges/moodle
[moodle.git] / mnet / service / enrol / index.php
blob1938c6c6e7d755e267fd6fe208d69cf9aae2817f
1 <?php
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.
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/>.
18 /**
19 * Displays the list of remote peers we can enrol our users to
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
27 require(__DIR__.'/../../../config.php');
28 require_once($CFG->libdir.'/adminlib.php');
29 require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');
31 admin_externalpage_setup('mnetenrol');
32 $service = mnetservice_enrol::get_instance();
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');
38 if (!$service->is_available()) {
39 echo $OUTPUT->box(get_string('mnetdisabled','mnet'), 'noticebox');
40 echo $OUTPUT->footer();
41 die();
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);
50 unset($roamingusers);
52 // remote hosts that may publish remote enrolment service and we are subscribed to it
53 $hosts = $service->get_remote_publishers();
55 if (empty($hosts)) {
56 echo $OUTPUT->box(get_string('nopublishers', 'mnetservice_enrol'), 'noticebox');
57 echo $OUTPUT->footer();
58 die();
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')
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);
75 echo html_writer::table($table);
77 echo $OUTPUT->footer();