Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/roles/permissions_forms.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00028 require_once("$CFG->libdir/formslib.php");
00029 
00030 
00031 class role_allow_form extends moodleform {
00032 
00033     // Define the form
00034     function definition() {
00035         global $CFG;
00036 
00037         $mform = $this->_form;
00038         list($context, $capability, $overridableroles) = $this->_customdata;
00039 
00040         list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
00041         foreach($needed as $id=>$unused) {
00042             unset($overridableroles[$id]);
00043         }
00044         foreach($forbidden as $id=>$unused) {
00045             unset($overridableroles[$id]);
00046         }
00047 
00048         $mform->addElement('header', 'allowheader', get_string('roleallowheader', 'role'));
00049 
00050         $mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
00051 
00052         $mform->addElement('hidden','capability');
00053         $mform->setType('capability', PARAM_CAPABILITY);
00054         $mform->setDefault('capability', $capability->name);
00055 
00056         $mform->addElement('hidden','contextid');
00057         $mform->setType('contextid', PARAM_INT);
00058         $mform->setDefault('contextid', $context->id);
00059 
00060         $mform->addElement('hidden','allow');
00061         $mform->setType('allow', PARAM_INT);
00062         $mform->setDefault('allow', 1);
00063 
00064         $this->add_action_buttons(true, get_string('allow', 'role'));
00065     }
00066 }
00067 
00068 
00069 class role_prohibit_form extends moodleform {
00070 
00071     // Define the form
00072     function definition() {
00073         global $CFG;
00074 
00075         $mform = $this->_form;
00076         list($context, $capability, $overridableroles) = $this->_customdata;
00077 
00078         list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
00079         foreach($forbidden as $id=>$unused) {
00080             unset($overridableroles[$id]);
00081         }
00082 
00083         $mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'role'));
00084 
00085         $mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
00086 
00087         $mform->addElement('hidden','capability');
00088         $mform->setType('capability', PARAM_CAPABILITY);
00089         $mform->setDefault('capability', $capability->name);
00090 
00091         $mform->addElement('hidden','contextid');
00092         $mform->setType('contextid', PARAM_INT);
00093         $mform->setDefault('contextid', $context->id);
00094 
00095         $mform->addElement('hidden','prohibit');
00096         $mform->setType('prohibit', PARAM_INT);
00097         $mform->setDefault('prohibit', 1);
00098 
00099         $this->add_action_buttons(true, get_string('prohibit', 'role'));
00100     }
00101 }
 All Data Structures Namespaces Files Functions Variables Enumerations