on-demand release 4.0dev+
[moodle.git] / mnet / service / enrol / index.php
CommitLineData
fe73e935
DM
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
1fcf0ca8 27require(__DIR__.'/../../../config.php');
fe73e935
DM
28require_once($CFG->libdir.'/adminlib.php');
29require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');
30
31admin_externalpage_setup('mnetenrol');
32$service = mnetservice_enrol::get_instance();
33
34echo $OUTPUT->header();
35echo $OUTPUT->heading_with_help(get_string('clientname', 'mnetservice_enrol'), 'clientname', 'mnetservice_enrol');
36
37if (!$service->is_available()) {
38 echo $OUTPUT->box(get_string('mnetdisabled','mnet'), 'noticebox');
39 echo $OUTPUT->footer();
40 die();
41}
42
0601e0ee 43$roamingusers = get_users_by_capability(context_system::instance(), 'moodle/site:mnetlogintoremote', 'u.id');
d47b972f
DM
44if (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}
49unset($roamingusers);
50
fe73e935
DM
51// remote hosts that may publish remote enrolment service and we are subscribed to it
52$hosts = $service->get_remote_publishers();
53
54if (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);
68foreach ($hosts as $host) {
69 $hostlink = html_writer::link(new moodle_url($host->hosturl), s($host->hosturl));
de5a205c
DM
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);
fe73e935
DM
73}
74echo html_writer::table($table);
75
76echo $OUTPUT->footer();