delete.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Page to allow the administrator to delete networked hosts, with a confirm message
  18. *
  19. * @package core
  20. * @subpackage mnet
  21. * @copyright 2007 Donal McMullan
  22. * @copyright 2007 Martin Langhoff
  23. * @copyright 2010 Penny Leach
  24. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25. */
  26. require(__DIR__.'/../../config.php');
  27. require_once($CFG->libdir . '/adminlib.php');
  28. $step = optional_param('step', 'verify', PARAM_ALPHA);
  29. $hostid = required_param('hostid', PARAM_INT);
  30. require_login();
  31. $context = context_system::instance();
  32. require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
  33. $mnet = get_mnet_environment();
  34. $PAGE->set_url('/admin/mnet/delete.php');
  35. admin_externalpage_setup('mnetpeer' . $hostid);
  36. require_sesskey();
  37. $mnet_peer = new mnet_peer();
  38. $mnet_peer->set_id($hostid);
  39. if ('verify' == $step) {
  40. echo $OUTPUT->header();
  41. echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
  42. if ($live_users = $mnet_peer->count_live_sessions() > 0) {
  43. echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
  44. }
  45. $yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
  46. $nourl = new moodle_url('/admin/mnet/peers.php');
  47. echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet') . ': ' . $mnet_peer->name, $yesurl, $nourl);
  48. echo $OUTPUT->footer();
  49. } elseif ('delete' == $step) {
  50. $mnet_peer->delete();
  51. redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
  52. }