PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/roles/classes/permission_prohibit_form.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 64 lines | 26 code | 14 blank | 24 comment | 1 complexity | e439fa40779d3fda2d6194e777295adb MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, AGPL-3.0
  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. * Prohibit something form.
  18. *
  19. * @package core_role
  20. * @copyright 2009 Petr Skoda {@link http://skodak.org}
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once("$CFG->libdir/formslib.php");
  25. class core_role_permission_prohibit_form extends moodleform {
  26. /**
  27. * Define the form.
  28. */
  29. protected function definition() {
  30. global $CFG;
  31. $mform = $this->_form;
  32. list($context, $capability, $overridableroles) = $this->_customdata;
  33. list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
  34. foreach ($forbidden as $id => $unused) {
  35. unset($overridableroles[$id]);
  36. }
  37. $mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'core_role'));
  38. $mform->addElement('select', 'roleid', get_string('roleselect', 'core_role'), $overridableroles);
  39. $mform->addElement('hidden', 'capability');
  40. $mform->setType('capability', PARAM_CAPABILITY);
  41. $mform->setDefault('capability', $capability->name);
  42. $mform->addElement('hidden', 'contextid');
  43. $mform->setType('contextid', PARAM_INT);
  44. $mform->setDefault('contextid', $context->id);
  45. $mform->addElement('hidden', 'prohibit');
  46. $mform->setType('prohibit', PARAM_INT);
  47. $mform->setDefault('prohibit', 1);
  48. $this->add_action_buttons(true, get_string('prohibit', 'core_role'));
  49. }
  50. }