1 |
efrain |
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 |
/**
|
|
|
18 |
* Library code used by the roles administration interfaces.
|
|
|
19 |
*
|
|
|
20 |
* @package core_role
|
|
|
21 |
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
defined('MOODLE_INTERNAL') || die();
|
|
|
26 |
|
|
|
27 |
class core_role_define_role_table_basic extends core_role_define_role_table_advanced {
|
|
|
28 |
protected $stradvmessage;
|
|
|
29 |
protected $strallow;
|
|
|
30 |
|
|
|
31 |
public function __construct($context, $roleid) {
|
|
|
32 |
parent::__construct($context, $roleid);
|
|
|
33 |
$this->displaypermissions = array(CAP_ALLOW => $this->allpermissions[CAP_ALLOW]);
|
|
|
34 |
$this->stradvmessage = get_string('useshowadvancedtochange', 'core_role');
|
|
|
35 |
$this->strallow = $this->strperms[$this->allpermissions[CAP_ALLOW]];
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
protected function print_show_hide_advanced_button() {
|
|
|
39 |
echo '<div class="advancedbutton">';
|
|
|
40 |
echo '<input type="submit" class="btn btn-secondary" name="toggleadvanced"
|
|
|
41 |
value="' . get_string('showadvanced', 'form') . '" />';
|
|
|
42 |
echo '</div>';
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
protected function add_permission_cells($capability) {
|
|
|
46 |
$perm = $this->permissions[$capability->name];
|
|
|
47 |
$permname = $this->allpermissions[$perm];
|
|
|
48 |
$defaultperm = $this->allpermissions[$this->parentpermissions[$capability->name]];
|
|
|
49 |
$content = '<td class="' . $permname . '">';
|
|
|
50 |
if ($perm == CAP_ALLOW || $perm == CAP_INHERIT) {
|
|
|
51 |
$checked = '';
|
|
|
52 |
if ($perm == CAP_ALLOW) {
|
|
|
53 |
$checked = 'checked="checked" ';
|
|
|
54 |
}
|
|
|
55 |
$content .= '<input type="hidden" name="' . $capability->name . '" value="' . CAP_INHERIT . '" />';
|
|
|
56 |
$content .= '<label><input type="checkbox" name="' . $capability->name .
|
|
|
57 |
'" value="' . CAP_ALLOW . '" ' . $checked . '/> ' . $this->strallow . '</label>';
|
|
|
58 |
} else {
|
|
|
59 |
$content .= '<input type="hidden" name="' . $capability->name . '" value="' . $perm . '" />';
|
|
|
60 |
$content .= $this->strperms[$permname] . '<span class="note">' . $this->stradvmessage . '</span>';
|
|
|
61 |
}
|
|
|
62 |
$content .= '</td>';
|
|
|
63 |
return $content;
|
|
|
64 |
}
|
|
|
65 |
}
|