source: moodle/trunk/fuentes/admin/mnet/delete.php @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 2.2 KB
Line 
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/**
20 * Page to allow the administrator to delete networked hosts, with a confirm message
21 *
22 * @package    core
23 * @subpackage mnet
24 * @copyright  2007 Donal McMullan
25 * @copyright  2007 Martin Langhoff
26 * @copyright  2010 Penny Leach
27 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 */
29
30require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
31require_once($CFG->libdir . '/adminlib.php');
32
33$step   = optional_param('step', 'verify', PARAM_ALPHA);
34$hostid = required_param('hostid', PARAM_INT);
35
36
37require_login();
38
39$context = context_system::instance();
40require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
41
42$mnet = get_mnet_environment();
43
44$PAGE->set_url('/admin/mnet/delete.php');
45admin_externalpage_setup('mnetpeer' . $hostid);
46
47require_sesskey();
48
49$mnet_peer = new mnet_peer();
50$mnet_peer->set_id($hostid);
51
52if ('verify' == $step) {
53    echo $OUTPUT->header();
54    echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
55    if ($live_users = $mnet_peer->count_live_sessions() > 0) {
56        echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
57    }
58    $yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
59    $nourl = new moodle_url('/admin/mnet/peers.php');
60    echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet')  . ': ' .  $mnet_peer->name, $yesurl, $nourl);
61    echo $OUTPUT->footer();
62} elseif ('delete' == $step) {
63    $mnet_peer->delete();
64    redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
65}
Note: See TracBrowser for help on using the repository browser.