MDL-21710, MDL-21711 new permissions evaluation and overriding UI
This commit is contained in:
+56
-65
@@ -1,83 +1,74 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* this page defines what roles can do things with other roles. For example
|
||||
* which roles can assign which other roles, or which roles can switch to
|
||||
* which other roles.
|
||||
* Allow overriding of roles by other roles
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$mode = required_param('mode', PARAM_ACTION);
|
||||
$classformode = array(
|
||||
'assign' => 'role_allow_assign_page',
|
||||
'override' => 'role_allow_override_page',
|
||||
'switch' => 'role_allow_switch_page'
|
||||
);
|
||||
if (!isset($classformode[$mode])) {
|
||||
print_error('invalidmode', '', '', $mode);
|
||||
}
|
||||
$mode = required_param('mode', PARAM_ACTION);
|
||||
$classformode = array(
|
||||
'assign' => 'role_allow_assign_page',
|
||||
'override' => 'role_allow_override_page',
|
||||
'switch' => 'role_allow_switch_page'
|
||||
);
|
||||
if (!isset($classformode[$mode])) {
|
||||
print_error('invalidmode', '', '', $mode);
|
||||
}
|
||||
|
||||
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/allow.php?mode=' . $mode;
|
||||
admin_externalpage_setup('defineroles', '', array(), $baseurl);
|
||||
require_login();
|
||||
$baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
|
||||
admin_externalpage_setup('defineroles', '', array(), $baseurl);
|
||||
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $syscontext);
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $syscontext);
|
||||
|
||||
$controller = new $classformode[$mode]();
|
||||
$controller = new $classformode[$mode]();
|
||||
|
||||
if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
|
||||
$controller->process_submission();
|
||||
mark_context_dirty($syscontext->path);
|
||||
add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
|
||||
$controller->process_submission();
|
||||
mark_context_dirty($syscontext->path);
|
||||
add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
$controller->load_current_settings();
|
||||
$controller->load_current_settings();
|
||||
|
||||
/// Display the editing form.
|
||||
admin_externalpage_print_header();
|
||||
// Display the editing form.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = $mode;
|
||||
require_once('managetabs.php');
|
||||
$currenttab = $mode;
|
||||
require('managetabs.php');
|
||||
|
||||
$table = $controller->get_table();
|
||||
$table = $controller->get_table();
|
||||
|
||||
echo $OUTPUT->box($controller->get_intro_text());
|
||||
echo $OUTPUT->box($controller->get_intro_text());
|
||||
|
||||
echo '<form action="' . $baseurl . '" method="post">';
|
||||
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
echo $OUTPUT->table($table);
|
||||
echo '<div class="buttons"><input type="submit" name="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '</div></form>';
|
||||
echo '<form action="' . $baseurl . '" method="post">';
|
||||
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
echo $OUTPUT->table($table);
|
||||
echo '<div class="buttons"><input type="submit" name="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '</div></form>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+37
-48
@@ -1,34 +1,28 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Lets you assign roles to users in a particular context.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
@@ -42,7 +36,6 @@
|
||||
$hidden = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
|
||||
$extendperiod = optional_param('extendperiod', 0, PARAM_INT);
|
||||
$extendbase = optional_param('extendbase', 3, PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
|
||||
$urlparams = array('contextid' => $contextid);
|
||||
if (!empty($userid)) {
|
||||
@@ -51,9 +44,6 @@
|
||||
if ($courseid && $courseid != SITEID) {
|
||||
$urlparams['courseid'] = $courseid;
|
||||
}
|
||||
if ($returnurl) {
|
||||
$urlparams['returnurl'] = $returnurl;
|
||||
}
|
||||
$PAGE->set_url('/admin/roles/assign.php', $urlparams);
|
||||
$baseurl = $PAGE->url->out();
|
||||
|
||||
@@ -65,26 +55,27 @@
|
||||
$contextname = print_context_name($context);
|
||||
|
||||
$inmeta = 0;
|
||||
$cm = null;
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseid = $context->instanceid;
|
||||
if ($course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
$inmeta = $course->metacourse;
|
||||
} else {
|
||||
print_error('invalidcourse', 'error');
|
||||
}
|
||||
|
||||
} else if (!empty($courseid)){ // we need this for user tabs in user context
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('invalidcourse', 'error');
|
||||
}
|
||||
} else if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
$cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST);
|
||||
$courseid = $cm->course;
|
||||
|
||||
} else if (!empty($courseid)) { // we need this for user tabs in user context
|
||||
// pass it
|
||||
|
||||
} else {
|
||||
$courseid = SITEID;
|
||||
$course = clone($SITE);
|
||||
}
|
||||
|
||||
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
||||
$inmeta = $course->metacourse;
|
||||
|
||||
/// Check login and permissions.
|
||||
require_login($course);
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/role:assign', $context);
|
||||
|
||||
/// These are needed early because of tabs.php
|
||||
@@ -276,19 +267,21 @@
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'assign';
|
||||
echo $OUTPUT->header();
|
||||
include($CFG->dirroot.'/user/tabs.php');
|
||||
|
||||
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
admin_externalpage_print_header();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
} else if ($isfrontpage) {
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
admin_externalpage_print_header();
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'assign';
|
||||
include('tabs.php');
|
||||
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'assign';
|
||||
include('tabs.php');
|
||||
}
|
||||
@@ -364,7 +357,7 @@
|
||||
|
||||
/// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
|
||||
|
||||
$select = new single_select(new moodle_url($baseurl), 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('assignanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
@@ -440,12 +433,8 @@
|
||||
|
||||
echo $OUTPUT->table($table);
|
||||
|
||||
if (!$isfrontpage && ($url = get_context_url($context))) {
|
||||
echo '<div class="backlink"><a href="' . $url . '">' .
|
||||
get_string('backto', '', $contextname) . '</a></div>';
|
||||
} else if ($returnurl) {
|
||||
echo '<div class="backlink"><a href="' . $CFG->wwwroot . '/' . $returnurl . '">' .
|
||||
get_string('backtopageyouwereon') . '</a></div>';
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
echo '<div class="backlink"><a href="' . get_context_url($context) . '">' . get_string('backto', '', $contextname) . '</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+28
-41
@@ -1,34 +1,28 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Shows the result of has_capability for every capability for a user in a context.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
@@ -36,7 +30,6 @@
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
|
||||
$urlparams = array('contextid' => $contextid);
|
||||
if (!empty($userid)) {
|
||||
@@ -45,9 +38,6 @@
|
||||
if ($courseid && $courseid != SITEID) {
|
||||
$urlparams['courseid'] = $courseid;
|
||||
}
|
||||
if ($returnurl) {
|
||||
$urlparams['returnurl'] = $returnurl;
|
||||
}
|
||||
$PAGE->set_url('/admin/roles/check.php', $urlparams);
|
||||
|
||||
if (! $context = get_context_instance_by_id($contextid)) {
|
||||
@@ -120,21 +110,22 @@
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'check';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
include($CFG->dirroot.'/user/tabs.php');
|
||||
|
||||
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
admin_externalpage_setup('checkpermissions', '', array('contextid' => $contextid));
|
||||
admin_externalpage_print_header();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
} else if ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid), $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php');
|
||||
admin_externalpage_print_header();
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'check';
|
||||
include_once('tabs.php');
|
||||
include('tabs.php');
|
||||
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'check';
|
||||
include_once('tabs.php');
|
||||
include('tabs.php');
|
||||
}
|
||||
|
||||
/// Print heading.
|
||||
@@ -146,7 +137,7 @@
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo $OUTPUT->heading(get_string('permissionsforuser', 'role', fullname($reportuser)), 3);
|
||||
|
||||
$table = new explain_capability_table($context, $reportuser, $contextname);
|
||||
$table = new check_capability_table($context, $reportuser, $contextname);
|
||||
$table->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
@@ -178,12 +169,8 @@
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Appropriate back link.
|
||||
if (!$isfrontpage && ($url = get_context_url($context))) {
|
||||
echo '<div class="backlink"><a href="' . $url . '">' .
|
||||
get_string('backto', '', $contextname) . '</a></div>';
|
||||
} else if ($returnurl) {
|
||||
echo '<div class="backlink"><a href="' . $CFG->wwwroot . '/' . $returnurl . '">' .
|
||||
get_string('backtopageyouwereon') . '</a></div>';
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
echo '<div class="backlink"><a href="' . get_context_url($context) . '">' . get_string('backto', '', $contextname) . '</a></div>';
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+19
-25
@@ -1,27 +1,19 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Lets the user edit role definitions.
|
||||
@@ -32,9 +24,11 @@
|
||||
* edit - edit the definition of a role
|
||||
* view - view the definition of a role
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
@@ -1,280 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Elucidates what has_capability does for a particular capability/user/context.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
|
||||
require(dirname(__FILE__) . '/../../config.php');
|
||||
|
||||
// Get parameters.
|
||||
$userid = required_param('user', PARAM_INTEGER); // We use 0 here to mean not-logged-in.
|
||||
$contextid = required_param('contextid', PARAM_INTEGER);
|
||||
$capability = required_param('capability', PARAM_CAPABILITY);
|
||||
|
||||
$PAGE->set_url('/admin/roles/explain.php', array('user'=>$userid, 'contextid'=>$contextid, 'capability'=>$capability));
|
||||
|
||||
// Get the context and its parents.
|
||||
$context = get_context_instance_by_id($contextid);
|
||||
if (!$context) {
|
||||
print_error('unknowncontext');
|
||||
}
|
||||
$contextids = get_parent_contexts($context);
|
||||
array_unshift($contextids, $context->id);
|
||||
$contexts = array();
|
||||
$number = count($contextids);
|
||||
foreach ($contextids as $contextid) {
|
||||
$contexts[$contextid] = get_context_instance_by_id($contextid);
|
||||
$contexts[$contextid]->name = print_context_name($contexts[$contextid], true, true);
|
||||
$contexts[$contextid]->number = $number--;
|
||||
}
|
||||
|
||||
// Validate the user id.
|
||||
if ($userid) {
|
||||
$user = $DB->get_record('user', array('id' => $userid));
|
||||
if (!$user) {
|
||||
print_error('nosuchuser');
|
||||
}
|
||||
} else {
|
||||
$frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
|
||||
if (!empty($CFG->forcelogin) ||
|
||||
($context->contextlevel >= CONTEXT_COURSE && !in_array($frontpagecontext->id, $contextids))) {
|
||||
print_error('cannotgetherewithoutloggingin', 'role');
|
||||
}
|
||||
}
|
||||
|
||||
// Check access permissions.
|
||||
require_login();
|
||||
if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
|
||||
'moodle/role:override', 'moodle/role:assign'), $context)) {
|
||||
print_error('nopermissions', '', get_string('explainpermissions'));
|
||||
}
|
||||
|
||||
// This duplicates code in load_all_capabilities and has_capability.
|
||||
$systempath = '/' . SYSCONTEXTID;
|
||||
if ($userid == 0) {
|
||||
if (!empty($CFG->notloggedinroleid)) {
|
||||
$accessdata = get_role_access($CFG->notloggedinroleid);
|
||||
$accessdata['ra'][$systempath] = array($CFG->notloggedinroleid);
|
||||
} else {
|
||||
$accessdata = array();
|
||||
$accessdata['ra'] = array();
|
||||
$accessdata['rdef'] = array();
|
||||
$accessdata['loaded'] = array();
|
||||
}
|
||||
} else if (isguestuser($user)) {
|
||||
$guestrole = get_guest_role();
|
||||
$accessdata = get_role_access($guestrole->id);
|
||||
$accessdata['ra'][$systempath] = array($guestrole->id);
|
||||
} else {
|
||||
$accessdata = load_user_accessdata($userid);
|
||||
}
|
||||
if ($context->contextlevel > CONTEXT_COURSE && !path_inaccessdata($context->path, $accessdata)) {
|
||||
load_subcontext($userid, $context, $accessdata);
|
||||
}
|
||||
|
||||
// Load the roles we need.
|
||||
$roleids = array();
|
||||
foreach ($accessdata['ra'] as $roleassignments) {
|
||||
$roleids = array_merge($roleassignments, $roleids);
|
||||
}
|
||||
$roles = $DB->get_records_list('role', 'id', $roleids);
|
||||
$rolenames = array();
|
||||
foreach ($roles as $role) {
|
||||
$rolenames[$role->id] = $role->name;
|
||||
}
|
||||
$rolenames = role_fix_names($rolenames, $context);
|
||||
|
||||
// Pass over the data once, to find the cell that determines the result.
|
||||
$userhascapability = has_capability($capability, $context, $userid, false);
|
||||
$areprohibits = false;
|
||||
$decisiveassigncon = 0;
|
||||
$decisiveoverridecon = 0;
|
||||
foreach ($contexts as $con) {
|
||||
if (!empty($accessdata['ra'][$con->path])) {
|
||||
// The array_unique here is to work around bug MDL-14817. Once that bug is
|
||||
// fixed, it can be removed
|
||||
$ras = array_unique($accessdata['ra'][$con->path]);
|
||||
} else {
|
||||
$ras = array();
|
||||
}
|
||||
$con->firstoverride = 0;
|
||||
foreach ($contexts as $ocon) {
|
||||
$summedpermission = 0;
|
||||
$gotsomething = false;
|
||||
foreach ($ras as $roleid) {
|
||||
if (isset($accessdata['rdef'][$ocon->path . ':' . $roleid][$capability])) {
|
||||
$perm = $accessdata['rdef'][$ocon->path . ':' . $roleid][$capability];
|
||||
} else {
|
||||
$perm = CAP_INHERIT;
|
||||
}
|
||||
if ($perm && !$gotsomething) {
|
||||
$gotsomething = true;
|
||||
$con->firstoverride = $ocon->id;
|
||||
}
|
||||
if ($perm == CAP_PROHIBIT) {
|
||||
$areprohibits = true;
|
||||
$decisiveassigncon = 0;
|
||||
$decisiveoverridecon = 0;
|
||||
break;
|
||||
}
|
||||
$summedpermission += $perm;
|
||||
}
|
||||
if (!$areprohibits && !$decisiveassigncon && $summedpermission) {
|
||||
$decisiveassigncon = $con->id;
|
||||
$decisiveoverridecon = $ocon->id;
|
||||
break;
|
||||
} else if ($gotsomething) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$areprohibits && !$decisiveassigncon) {
|
||||
$decisiveassigncon = SYSCONTEXTID;
|
||||
$decisiveoverridecon = SYSCONTEXTID;
|
||||
}
|
||||
|
||||
// Make a fake role to simplify rendering the table below.
|
||||
$rolenames[0] = get_string('none');
|
||||
|
||||
// Prepare some arrays of strings.
|
||||
$cssclasses = array(
|
||||
CAP_INHERIT => 'inherit',
|
||||
CAP_ALLOW => 'allow',
|
||||
CAP_PREVENT => 'prevent',
|
||||
CAP_PROHIBIT => 'prohibit',
|
||||
'' => ''
|
||||
);
|
||||
$strperm = array(
|
||||
CAP_INHERIT => get_string('inherit', 'role'),
|
||||
CAP_ALLOW => get_string('allow', 'role'),
|
||||
CAP_PREVENT => get_string('prevent', 'role'),
|
||||
CAP_PROHIBIT => get_string('prohibit', 'role'),
|
||||
'' => ''
|
||||
);
|
||||
|
||||
// Start the output.
|
||||
$PAGE->set_title(get_string('explainpermission', 'role'));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('explainpermission', 'role'));
|
||||
|
||||
// Print a summary of what we are doing.
|
||||
$a = new stdClass;
|
||||
if ($userid) {
|
||||
$a->fullname = fullname($user);
|
||||
} else {
|
||||
$a->fullname = get_string('nobody');
|
||||
}
|
||||
$a->capability = $capability;
|
||||
$a->context = reset($contexts)->name;
|
||||
if ($userhascapability) {
|
||||
echo '<p>' . get_string('whydoesuserhavecap', 'role', $a) . '</p>';
|
||||
} else {
|
||||
echo '<p>' . get_string('whydoesusernothavecap', 'role', $a) . '</p>';
|
||||
}
|
||||
|
||||
// Print the table header rows.
|
||||
echo '<table class="generaltable explainpermissions"><thead>';
|
||||
echo '<tr><th scope="col" colspan="2" class="header assignment">' . get_string('roleassignments', 'role') . '</th>';
|
||||
if (count($contexts) > 1) {
|
||||
echo '<th scope="col" colspan="' . (count($contexts) - 1) . '" class="header">' . get_string('overridesbycontext', 'role') . '</th>';
|
||||
}
|
||||
echo '<th scope="col" rowspan="2" class="header">' . get_string('roledefinitions', 'role') . '</th>';
|
||||
echo '</tr>';
|
||||
echo '<tr class="row2"><th scope="col" class="header assignment">' . get_string('context', 'role') .
|
||||
'</th><th scope="col" class="header assignment">' . get_string('role') . '</th>';
|
||||
foreach (array_slice($contexts, 0, count($contexts) - 1) as $con) {
|
||||
echo '<th scope="col" class="header overridecontext" title="' . $con->name . '">' . $con->number . '</th>';
|
||||
}
|
||||
echo '</tr></thead><tbody>';
|
||||
|
||||
// Now print the bulk of the table.
|
||||
foreach ($contexts as $con) {
|
||||
if (!empty($accessdata['ra'][$con->path])) {
|
||||
// The array_unique here is to work around bug MDL-14817. Once that bug is
|
||||
// fixed, it can be removed
|
||||
$ras = array_unique($accessdata['ra'][$con->path]);
|
||||
} else {
|
||||
$ras = array(0);
|
||||
}
|
||||
$firstcell = '<th class="cell assignment" rowspan="' . count($ras) . '">' . $con->number . '. ' . $con->name . '</th>';
|
||||
$rowclass = ' class="newcontext"';
|
||||
foreach ($ras as $roleid) {
|
||||
$extraclass = '';
|
||||
if (!$roleid) {
|
||||
$extraclass = ' noroles';
|
||||
}
|
||||
echo '<tr' . $rowclass . '>' . $firstcell . '<th class="cell assignment' . $extraclass . '" scope="row">' . $rolenames[$roleid] . '</th>';
|
||||
$overridden = false;
|
||||
foreach ($contexts as $ocon) {
|
||||
if ($roleid == 0) {
|
||||
$perm = '';
|
||||
} else {
|
||||
if (isset($accessdata['rdef'][$ocon->path . ':' . $roleid][$capability])) {
|
||||
$perm = $accessdata['rdef'][$ocon->path . ':' . $roleid][$capability];
|
||||
} else {
|
||||
$perm = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
if ($perm === CAP_INHERIT && $ocon->id == SYSCONTEXTID) {
|
||||
$permission = get_string('notset', 'role');
|
||||
} else {
|
||||
$permission = $strperm[$perm];
|
||||
}
|
||||
$classes = $cssclasses[$perm];
|
||||
if (!$areprohibits && $decisiveassigncon == $con->id && $decisiveoverridecon == $ocon->id) {
|
||||
$classes .= ' decisive';
|
||||
if ($userhascapability) {
|
||||
$classes .= ' has';
|
||||
} else {
|
||||
$classes .= ' hasnot';
|
||||
}
|
||||
}
|
||||
if ($overridden) {
|
||||
$classes .= ' overridden';
|
||||
}
|
||||
echo '<td class="cell ' . $classes . '">' . $permission . '</td>';
|
||||
if ($con->firstoverride == $ocon->id) {
|
||||
$overridden = true;
|
||||
}
|
||||
}
|
||||
echo '</tr>';
|
||||
$firstcell = '';
|
||||
$rowclass = '';
|
||||
}
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
|
||||
// Finish the page.
|
||||
echo get_string('explainpermissionsinfo', 'role');
|
||||
if ($userid && $capability != 'moodle/site:doanything' && !$userhascapability &&
|
||||
has_capability('moodle/site:doanything', $context, $userid)) {
|
||||
echo '<p>' . get_string('explainpermissionsdoanything', 'role', $capability) . '</p>';
|
||||
}
|
||||
echo $OUTPUT->close_window_button();
|
||||
echo $OUTPUT->footer();
|
||||
+166
-77
@@ -1,34 +1,34 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* Responds to actions:
|
||||
* add - add a new role
|
||||
* duplicate - like add, only initialise the new role by using an existing one.
|
||||
* edit - edit the definition of a role
|
||||
* view - view the definition of a role
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
@@ -83,6 +83,10 @@ abstract class capability_table_base {
|
||||
* Display the table.
|
||||
*/
|
||||
public function display() {
|
||||
if (count($this->capabilities) > capability_table_base::NUM_CAPS_FOR_SEARCH) {
|
||||
global $PAGE;
|
||||
$PAGE->requires->js_init_call('M.core_role.init_cap_table_filter', array($this->id, get_string('filter'), get_string('clear')));
|
||||
}
|
||||
echo '<table class="' . implode(' ', $this->classes) . '" id="' . $this->id . '">' . "\n<thead>\n";
|
||||
echo '<tr><th class="name" align="left" scope="col">' . get_string('capability','role') . '</th>';
|
||||
$this->add_header_cells();
|
||||
@@ -119,11 +123,7 @@ abstract class capability_table_base {
|
||||
}
|
||||
|
||||
/// End of the table.
|
||||
echo "</tbody>\n</table>\n";
|
||||
if (count($this->capabilities) > capability_table_base::NUM_CAPS_FOR_SEARCH) {
|
||||
global $PAGE;
|
||||
$PAGE->requires->js_init_call('M.core_role.init_cap_table_filter', array($this->id, get_string('filter'), get_string('clear')));
|
||||
}
|
||||
echo "</tbody>\n</table>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,17 +179,14 @@ abstract class capability_table_base {
|
||||
/**
|
||||
* Subclass of capability_table_base for use on the Check permissions page.
|
||||
*
|
||||
* We have two additional columns, Allowed, which contains yes/no, and Explanation,
|
||||
* which contains a pop-up link to explainhascapability.php.
|
||||
* We have one additional column, Allowed, which contains yes/no.
|
||||
*/
|
||||
class explain_capability_table extends capability_table_base {
|
||||
class check_capability_table extends capability_table_base {
|
||||
protected $user;
|
||||
protected $fullname;
|
||||
protected $baseurl;
|
||||
protected $contextname;
|
||||
protected $stryes;
|
||||
protected $strno;
|
||||
protected $strexplanation;
|
||||
private $hascap;
|
||||
|
||||
/**
|
||||
@@ -204,21 +201,16 @@ class explain_capability_table extends capability_table_base {
|
||||
$this->user = $user;
|
||||
$this->fullname = fullname($user);
|
||||
$this->contextname = $contextname;
|
||||
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin .
|
||||
'/roles/explain.php?user=' . $user->id .
|
||||
'&contextid=' . $context->id . '&capability=';
|
||||
$this->stryes = get_string('yes');
|
||||
$this->strno = get_string('no');
|
||||
$this->strexplanation = get_string('explanation');
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
echo '<th>' . get_string('allowed', 'role') . '</th>';
|
||||
echo '<th>' . $this->strexplanation . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function skip_row($capability) {
|
||||
@@ -238,27 +230,150 @@ class explain_capability_table extends capability_table_base {
|
||||
global $OUTPUT;
|
||||
if ($this->hascap) {
|
||||
$result = $this->stryes;
|
||||
$tooltip = 'whydoesuserhavecap';
|
||||
} else {
|
||||
$result = $this->strno;
|
||||
$tooltip = 'whydoesusernothavecap';
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->fullname = $this->fullname;
|
||||
$a->capability = $capability->name;
|
||||
$a->context = $this->contextname;
|
||||
echo '<td>' . $result . '</td>';
|
||||
echo '<td>';
|
||||
|
||||
$url = $this->baseurl . $capability->name;
|
||||
echo $OUTPUT->action_link($url, $this->strexplanation,
|
||||
new popup_action('click', $url, 'hascapabilityexplanation', array('height' => 600, 'width' => 600)),
|
||||
array('title'=>get_string($tooltip, 'role', $a)));
|
||||
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subclass of capability_table_base for use on the Permissions page.
|
||||
*/
|
||||
class permissions_table extends capability_table_base {
|
||||
protected $contextname;
|
||||
protected $allowoverrides;
|
||||
protected $allowsafeoverrides;
|
||||
protected $overridableroles;
|
||||
protected $roles;
|
||||
protected $icons = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param object $context the context this table relates to.
|
||||
* @param string $contextname print_context_name($context) - to save recomputing.
|
||||
*/
|
||||
public function __construct($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles) {
|
||||
global $DB;
|
||||
|
||||
parent::__construct($context, 'permissions');
|
||||
$this->contextname = $contextname;
|
||||
$this->allowoverrides = $allowoverrides;
|
||||
$this->allowsafeoverrides = $allowsafeoverrides;
|
||||
$this->overridableroles = $overridableroles;
|
||||
|
||||
$roles = $DB->get_records('role', null, 'sortorder DESC');
|
||||
foreach ($roles as $roleid=>$role) {
|
||||
$roles[$roleid] = $role->name;
|
||||
}
|
||||
$this->roles = role_fix_names($roles, $context);
|
||||
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
echo '<th>' . get_string('risks', 'role') . '</th>';
|
||||
echo '<th>' . get_string('neededroles', 'role') . '</th>';
|
||||
echo '<th>' . get_string('prohibitedroles', 'role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
protected function skip_row($capability) {
|
||||
return $capability->name != 'moodle/site:doanything' && is_legacy($capability->name);
|
||||
}
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
global $OUTPUT, $PAGE;
|
||||
|
||||
$context = $this->context;
|
||||
$contextid = $this->context->id;
|
||||
$allowoverrides = $this->allowoverrides;
|
||||
$allowsafeoverrides = $this->allowsafeoverrides;
|
||||
$overridableroles = $this->overridableroles;
|
||||
$roles = $this->roles;
|
||||
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
$neededroles = array();
|
||||
$forbiddenroles = array();
|
||||
$allowable = $overridableroles;
|
||||
$forbitable = $overridableroles;
|
||||
foreach ($neededroles as $id=>$unused) {
|
||||
unset($allowable[$id]);
|
||||
}
|
||||
foreach ($forbidden as $id=>$unused) {
|
||||
unset($allowable[$id]);
|
||||
unset($forbitable[$id]);
|
||||
}
|
||||
|
||||
foreach ($roles as $id=>$name) {
|
||||
if (isset($needed[$id])) {
|
||||
$neededroles[$id] = $roles[$id];
|
||||
if (isset($overridableroles[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$preventurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'prevent'=>1));
|
||||
$neededroles[$id] .= $OUTPUT->action_icon($preventurl, new pix_icon('t/delete', get_string('prevent', 'role')));
|
||||
}
|
||||
}
|
||||
}
|
||||
$neededroles = implode(', ', $neededroles);
|
||||
foreach ($roles as $id=>$name) {
|
||||
if (isset($forbidden[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$forbiddenroles[$id] = $roles[$id];
|
||||
if (isset($overridableroles[$id]) and prohibit_is_removable($id, $context, $capability->name)) {
|
||||
$unprohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'unprohibit'=>1));
|
||||
$forbiddenroles[$id] .= $OUTPUT->action_icon($unprohibiturl, new pix_icon('t/delete', get_string('delete')));
|
||||
}
|
||||
}
|
||||
}
|
||||
$forbiddenroles = implode(', ', $forbiddenroles);
|
||||
|
||||
if ($allowable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$allowurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'allow'=>1));
|
||||
$neededroles .= '<div class="allowmore">'.$OUTPUT->action_icon($allowurl, new pix_icon('t/add', get_string('allow', 'role'))).'</div>';
|
||||
}
|
||||
|
||||
if ($forbitable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$prohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'prohibit'=>1));
|
||||
$forbiddenroles .= '<div class="prohibitmore">'.$OUTPUT->action_icon($prohibiturl, new pix_icon('t/add', get_string('prohibit', 'role'))).'</div>';
|
||||
}
|
||||
|
||||
$risks = $this->get_risks($capability);
|
||||
|
||||
echo '<td>' . $risks . '</td>';
|
||||
echo '<td>' . $neededroles . '</td>';
|
||||
echo '<td>' . $forbiddenroles . '</td>';
|
||||
}
|
||||
|
||||
protected function get_risks($capability) {
|
||||
global $OUTPUT;
|
||||
|
||||
$allrisks = get_all_risks();
|
||||
$risksurl = new moodle_url(get_docs_url(s(get_string('risks', 'role'))));
|
||||
|
||||
$return = '';
|
||||
|
||||
foreach ($allrisks as $type=>$risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
if (!isset($this->icons[$type])) {
|
||||
$pixicon = new pix_icon('/i/' . str_replace('risk', 'risk_', $type), get_string($type . 'short', 'admin'));
|
||||
$this->icons[$type] = $OUTPUT->action_icon($risksurl, $pixicon, new popup_action('click', $risksurl));
|
||||
}
|
||||
$return .= $this->icons[$type];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This subclass is the bases for both the define roles and override roles
|
||||
* pages. As well as adding the risks columns, this also provides generic
|
||||
@@ -900,32 +1015,6 @@ class override_permissions_table_advanced extends capability_table_with_risks {
|
||||
}
|
||||
}
|
||||
|
||||
class override_permissions_table_basic extends override_permissions_table_advanced {
|
||||
protected $stradvmessage;
|
||||
|
||||
public function __construct($context, $roleid, $safeoverridesonly) {
|
||||
parent::__construct($context, $roleid, $safeoverridesonly);
|
||||
unset($this->displaypermissions[CAP_PROHIBIT]);
|
||||
$this->stradvmessage = get_string('useshowadvancedtochange', 'role');
|
||||
}
|
||||
|
||||
protected function skip_row($capability) {
|
||||
return is_legacy($capability->name) || $capability->locked;
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
if ($this->permissions[$capability->name] == CAP_PROHIBIT) {
|
||||
$permname = $this->allpermissions[CAP_PROHIBIT];
|
||||
echo '<td class="' . $permname . '" colspan="' . count($this->displaypermissions) . '">';
|
||||
echo '<input type="hidden" name="' . $capability->name . '" value="' . CAP_PROHIBIT . '" />';
|
||||
echo $this->strperms[$permname] . '<span class="note">' . $this->stradvmessage . '</span>';
|
||||
echo '</td>';
|
||||
} else {
|
||||
parent::add_permission_cells($capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// User selectors for managing role assignments ================================
|
||||
|
||||
/**
|
||||
|
||||
+20
-26
@@ -1,27 +1,19 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Lets the user define and edit roles.
|
||||
@@ -36,9 +28,11 @@
|
||||
* For all but the first two of those, you also need a roleid parameter, and
|
||||
* possibly some other data.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
@@ -194,7 +188,7 @@
|
||||
}
|
||||
|
||||
/// Print the page header and tabs.
|
||||
admin_externalpage_print_header();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
include_once('managetabs.php');
|
||||
|
||||
+29
-35
@@ -1,45 +1,39 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Defines the tab bar used on the manage/allow assign/allow overrides pages.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
}
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$toprow = array();
|
||||
$toprow[] = new tabobject('manage', $CFG->wwwroot.'/'.$CFG->admin.'/roles/manage.php', get_string('manageroles', 'role'));
|
||||
$toprow[] = new tabobject('assign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allow.php?mode=assign', get_string('allowassign', 'role'));
|
||||
$toprow[] = new tabobject('override', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allow.php?mode=override', get_string('allowoverride', 'role'));
|
||||
$toprow[] = new tabobject('switch', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allow.php?mode=switch', get_string('allowswitch', 'role'));
|
||||
$tabs = array($toprow);
|
||||
$toprow = array();
|
||||
$toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), get_string('manageroles', 'role'));
|
||||
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'role'));
|
||||
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'role'));
|
||||
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'role'));
|
||||
$tabs = array($toprow);
|
||||
|
||||
print_tabs($tabs, $currenttab);
|
||||
print_tabs($tabs, $currenttab);
|
||||
|
||||
|
||||
+104
-106
@@ -5,113 +5,111 @@ capability name does not contain that text. */
|
||||
|
||||
M.core_role = {};
|
||||
|
||||
M.core_role.CapTableFilter = function(Y, tableid, strsearch, strclear) {
|
||||
this.delayhandle = -1,
|
||||
this.searchdelay = 100, // milliseconds
|
||||
|
||||
this.Y = Y
|
||||
// Find the form controls.
|
||||
this.table = document.getElementById(tableid);
|
||||
|
||||
// Create a div to hold the search UI.
|
||||
this.div = document.createElement('div');
|
||||
this.div.className = 'capabilitysearchui';
|
||||
this.div.style.width = this.table.offsetWidth + 'px';
|
||||
|
||||
// Create the capability search input.
|
||||
this.input = document.createElement('input');
|
||||
this.input.type = 'text';
|
||||
this.input.id = tableid + 'capabilitysearch';
|
||||
|
||||
// Create a label for the search input.
|
||||
this.label = document.createElement('label');
|
||||
this.label.htmlFor = this.input.id;
|
||||
this.label.appendChild(document.createTextNode(strsearch + ' '));
|
||||
|
||||
// Create a clear button to clear the input.
|
||||
this.button = document.createElement('input');
|
||||
this.button.value = strclear;
|
||||
this.button.type = 'button';
|
||||
this.button.disabled = true;
|
||||
|
||||
// Tie it all together
|
||||
this.div.appendChild(this.label);
|
||||
this.div.appendChild(this.input);
|
||||
this.div.appendChild(this.button);
|
||||
this.table.parentNode.insertBefore(this.div, this.table);
|
||||
Y.on('keyup', this.change, this.input, this);
|
||||
Y.on('click', this.clear, this.button, this);
|
||||
|
||||
// Horrible hack!
|
||||
var hidden = document.createElement('input');
|
||||
hidden.type = 'hidden';
|
||||
hidden.disabled = true;
|
||||
this.div.appendChild(hidden);
|
||||
hidden = document.createElement('input');
|
||||
hidden.type = 'hidden';
|
||||
hidden.disabled = true;
|
||||
this.div.appendChild(hidden);
|
||||
};
|
||||
|
||||
M.core_role.CapTableFilter.prototype.clear = function () {
|
||||
this.input.value = '';
|
||||
if (this.delayhandle != -1) {
|
||||
clearTimeout(this.delayhandle);
|
||||
this.delayhandle = -1;
|
||||
}
|
||||
this.filter();
|
||||
};
|
||||
|
||||
M.core_role.CapTableFilter.prototype.change = function() {
|
||||
var self = this;
|
||||
var handle = setTimeout(function(){self.filter();}, this.searchdelay);
|
||||
if (this.delayhandle != -1) {
|
||||
clearTimeout(this.delayhandle);
|
||||
}
|
||||
this.delayhandle = handle;
|
||||
};
|
||||
|
||||
M.core_role.CapTableFilter.prototype.set_visible = function(row, visible) {
|
||||
if (visible) {
|
||||
this.Y.one(row).removeClass('hiddenrow');
|
||||
} else {
|
||||
this.Y.one(row).addClass('hiddenrow');
|
||||
}
|
||||
};
|
||||
|
||||
M.core_role.CapTableFilter.prototype.filter = function() {
|
||||
var filtertext = this.input.value.toLowerCase();
|
||||
this.button.disabled = (filtertext == '');
|
||||
var lastheading = null;
|
||||
var capssincelastheading = 0;
|
||||
|
||||
Y.all('#'+this.table.id+' tr').each(function(row, index, list) {
|
||||
if (row.hasClass('rolecapheading')) {
|
||||
if (lastheading) {
|
||||
this.set_visible(lastheading, capssincelastheading > 0);
|
||||
}
|
||||
lastheading = row;
|
||||
capssincelastheading = 0;
|
||||
}
|
||||
if (row.hasClass('rolecap')) {
|
||||
var capname = row.one('.cap-name').get('text') + '|' + row.one('.cap-desc a').get('text').toLowerCase();
|
||||
if (capname.indexOf(filtertext) >= 0) {
|
||||
this.set_visible(row, true);
|
||||
capssincelastheading += 1;
|
||||
} else {
|
||||
this.set_visible(row, false);
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (lastheading) {
|
||||
this.set_visible(lastheading, capssincelastheading > 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
M.core_role.init_cap_table_filter = function(Y, tableid, strsearch, strclear) {
|
||||
new M.core_role.CapTableFilter(Y, tableid, strsearch, strclear);
|
||||
var CapTableFilter = function(tableid, strsearch, strclear) {
|
||||
this.delayhandle = -1,
|
||||
this.searchdelay = 100, // milliseconds
|
||||
|
||||
// Find the form controls.
|
||||
this.table = document.getElementById(tableid);
|
||||
|
||||
// Create a div to hold the search UI.
|
||||
this.div = document.createElement('div');
|
||||
this.div.className = 'capabilitysearchui';
|
||||
this.div.style.width = this.table.offsetWidth + 'px';
|
||||
|
||||
// Create the capability search input.
|
||||
this.input = document.createElement('input');
|
||||
this.input.type = 'text';
|
||||
this.input.id = tableid + 'capabilitysearch';
|
||||
|
||||
// Create a label for the search input.
|
||||
this.label = document.createElement('label');
|
||||
this.label.htmlFor = this.input.id;
|
||||
this.label.appendChild(document.createTextNode(strsearch + ' '));
|
||||
|
||||
// Create a clear button to clear the input.
|
||||
this.button = document.createElement('input');
|
||||
this.button.value = strclear;
|
||||
this.button.type = 'button';
|
||||
this.button.disabled = true;
|
||||
|
||||
// Tie it all together
|
||||
this.div.appendChild(this.label);
|
||||
this.div.appendChild(this.input);
|
||||
this.div.appendChild(this.button);
|
||||
this.table.parentNode.insertBefore(this.div, this.table);
|
||||
Y.on('keyup', this.change, this.input, this);
|
||||
Y.on('click', this.clear, this.button, this);
|
||||
|
||||
// Horrible hack!
|
||||
var hidden = document.createElement('input');
|
||||
hidden.type = 'hidden';
|
||||
hidden.disabled = true;
|
||||
this.div.appendChild(hidden);
|
||||
hidden = document.createElement('input');
|
||||
hidden.type = 'hidden';
|
||||
hidden.disabled = true;
|
||||
this.div.appendChild(hidden);
|
||||
};
|
||||
|
||||
CapTableFilter.prototype.clear = function () {
|
||||
this.input.value = '';
|
||||
if (this.delayhandle != -1) {
|
||||
clearTimeout(this.delayhandle);
|
||||
this.delayhandle = -1;
|
||||
}
|
||||
this.filter();
|
||||
};
|
||||
|
||||
CapTableFilter.prototype.change = function() {
|
||||
var self = this;
|
||||
var handle = setTimeout(function(){self.filter();}, this.searchdelay);
|
||||
if (this.delayhandle != -1) {
|
||||
clearTimeout(this.delayhandle);
|
||||
}
|
||||
this.delayhandle = handle;
|
||||
};
|
||||
|
||||
CapTableFilter.prototype.set_visible = function(row, visible) {
|
||||
if (visible) {
|
||||
Y.one(row).removeClass('hiddenrow');
|
||||
} else {
|
||||
Y.one(row).addClass('hiddenrow');
|
||||
}
|
||||
};
|
||||
|
||||
CapTableFilter.prototype.filter = function() {
|
||||
var filtertext = this.input.value.toLowerCase();
|
||||
this.button.disabled = (filtertext == '');
|
||||
var lastheading = null;
|
||||
var capssincelastheading = 0;
|
||||
|
||||
Y.all('#'+this.table.id+' tr').each(function(row, index, list) {
|
||||
if (row.hasClass('rolecapheading')) {
|
||||
if (lastheading) {
|
||||
this.set_visible(lastheading, capssincelastheading > 0);
|
||||
}
|
||||
lastheading = row;
|
||||
capssincelastheading = 0;
|
||||
}
|
||||
if (row.hasClass('rolecap')) {
|
||||
var capname = row.one('.cap-name').get('text') + '|' + row.one('.cap-desc a').get('text').toLowerCase();
|
||||
if (capname.indexOf(filtertext) >= 0) {
|
||||
this.set_visible(row, true);
|
||||
capssincelastheading += 1;
|
||||
} else {
|
||||
this.set_visible(row, false);
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (lastheading) {
|
||||
this.set_visible(lastheading, capssincelastheading > 0);
|
||||
}
|
||||
};
|
||||
|
||||
new CapTableFilter(tableid, strsearch, strclear);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+147
-227
@@ -1,208 +1,161 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Lets you override role definitions in contexts.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
require('../../config.php');
|
||||
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // requested role id
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = required_param('roleid', PARAM_INT); // requested role id
|
||||
|
||||
/// Get the base URL for this and related pages into a convenient variable.
|
||||
$urlparams = array('contextid' => $contextid);
|
||||
if (!empty($userid)) {
|
||||
$urlparams['userid'] = $userid;
|
||||
}
|
||||
if ($courseid && $courseid != SITEID) {
|
||||
$urlparams['courseid'] = $courseid;
|
||||
}
|
||||
if ($returnurl) {
|
||||
$urlparams['returnurl'] = $returnurl;
|
||||
}
|
||||
$PAGE->set_url('/admin/roles/override.php', $urlparams);
|
||||
$baseurl = $PAGE->url->out();
|
||||
// security first
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
require_login($course, false, $cm);
|
||||
$safeoverridesonly = !has_capability('moodle/role:override', $context);
|
||||
if ($safeoverridesonly) {
|
||||
require_capability('moodle/role:safeoverride', $context);
|
||||
}
|
||||
|
||||
/// Validate the contextid parameter.
|
||||
if (!$context = $DB->get_record('context', array('id'=>$contextid))) {
|
||||
print_error('wrongcontextid', 'error');
|
||||
}
|
||||
$isfrontpage = $context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID;
|
||||
$contextname = print_context_name($context);
|
||||
$PAGE->set_url('/admin/roles/override.php', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
$PAGE->set_context($context);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
print_error('cannotoverridebaserole', 'error');
|
||||
}
|
||||
$userid = 0;
|
||||
$tabfile = null;
|
||||
|
||||
/// Validate the courseid parameter.
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseid = $context->instanceid;
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
} if ($courseid) { // we need this for user tabs in user context
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
} else {
|
||||
$course = clone($SITE);
|
||||
$courseid = SITEID;
|
||||
}
|
||||
if ($course) {
|
||||
$isfrontpage = ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID);
|
||||
|
||||
/// Check access permissions.
|
||||
require_login($course);
|
||||
$safeoverridesonly = !has_capability('moodle/role:override', $context);
|
||||
if ($safeoverridesonly) {
|
||||
require_capability('moodle/role:safeoverride', $context);
|
||||
}
|
||||
|
||||
/// Handle the cancel button.
|
||||
if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
/// Handle the toggle advanced mode button.
|
||||
$showadvanced = get_user_preferences('overridepermissions_showadvanced', false);
|
||||
if (optional_param('toggleadvanced', false, PARAM_BOOL)) {
|
||||
$showadvanced = !$showadvanced;
|
||||
set_user_preference('overridepermissions_showadvanced', $showadvanced);
|
||||
}
|
||||
|
||||
/// These are needed early because of tabs.php
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
|
||||
|
||||
/// Make sure this user can override that role
|
||||
if ($roleid && !isset($overridableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotoverriderolehere', '', get_context_url($context), $a);
|
||||
}
|
||||
|
||||
|
||||
/// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
if ($roleid) {
|
||||
if ($showadvanced) {
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
} else {
|
||||
$overridestable = new override_permissions_table_basic($context, $roleid, $safeoverridesonly);
|
||||
}
|
||||
$overridestable->read_submitted_permissions();
|
||||
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$overridestable->save_changes();
|
||||
$rolename = $overridableroles[$roleid];
|
||||
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
}
|
||||
|
||||
/// Work out an appropriate page title.
|
||||
if ($roleid) {
|
||||
$a = new stdClass;
|
||||
$a->role = $overridableroles[$roleid];
|
||||
$a->context = $contextname;
|
||||
$title = get_string('overridepermissionsforrole', 'role', $a);
|
||||
} else {
|
||||
if ($isfrontpage) {
|
||||
$title = get_string('frontpageoverrides', 'admin');
|
||||
} else {
|
||||
$title = get_string('overridepermissionsin', 'role', $contextname);
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the header and tabs
|
||||
$straction = get_string('overrideroles', 'role'); // Used by tabs.php
|
||||
} else {
|
||||
$isfrontpage = false;
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
$user = $DB->get_record('user', array('id'=>$userid));
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
|
||||
$PAGE->set_title($title);
|
||||
if ($courseid != SITEID) {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$PAGE->navbar->add(get_string('participants'), new moodle_url('/user/index.php', array('id'=>$course->id)));
|
||||
}
|
||||
$PAGE->set_heading($fullname);
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
$PAGE->navbar->add($fullname, new moodle_url("$CFG->wwwroot/user/view.php", array('id'=>$userid,'course'=>$courseid)));
|
||||
$PAGE->navbar->add($straction);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'override';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid), $CFG->wwwroot . '/' . $CFG->admin . '/roles/override.php');
|
||||
admin_externalpage_print_header();
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
$courseid = optional_param('courseid', SITEID, PARAM_INT); // needed for user/tabs.php
|
||||
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
||||
$PAGE->url->param('courseid', $courseid);
|
||||
$userid = $context->instanceid;
|
||||
} else {
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
$course = $SITE;
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading_with_help($title, 'overrides');
|
||||
$courseid = $course->id;
|
||||
|
||||
if ($roleid) {
|
||||
/// Show UI for overriding roles.
|
||||
$baseurl = $PAGE->url->out();
|
||||
$returnurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $context->id));
|
||||
|
||||
if (!empty($capabilities)) {
|
||||
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'role'), 'generalbox boxaligncenter');
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
} else {
|
||||
// Print the capabilities overrideable in this context
|
||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
||||
// These are needed early because of tabs.php
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
|
||||
|
||||
if ($showadvanced) {
|
||||
$showadvancedlabel = get_string('hideadvanced', 'form');
|
||||
} else {
|
||||
$showadvancedlabel = get_string('showadvanced', 'form');
|
||||
}
|
||||
?>
|
||||
<form id="overrideform" action="<?php echo $baseurl . '&roleid=' . $roleid; ?>" method="post"><div>
|
||||
// Work out an appropriate page title.
|
||||
$contextname = print_context_name($context);
|
||||
$straction = get_string('overrideroles', 'role'); // Used by tabs.php
|
||||
$a = (object)array('context' => $contextname, 'role' => $overridableroles[$roleid]);
|
||||
$title = get_string('overridepermissionsforrole', 'role', $a);
|
||||
|
||||
// Print the header and tabs
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
print_error('cannotoverridebaserole', 'error');
|
||||
|
||||
} else if ($context->contextlevel == CONTEXT_USER) {
|
||||
// NOTE: this is not linked from UI for now
|
||||
$userid = $context->instanceid;
|
||||
$user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST);
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
|
||||
// course header
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
} else {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
$PAGE->navbar->add(get_string('participants'), new moodle_url('/user/index.php', array('id'=>$courseid)));
|
||||
}
|
||||
$PAGE->set_heading($fullname);
|
||||
}
|
||||
$PAGE->navbar->add($fullname, new moodle_url("$CFG->wwwroot/user/view.php", array('id'=>$userid,'course'=>$courseid)));
|
||||
$PAGE->navbar->add($straction);
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'permissions';
|
||||
$tabfile = $CFG->dirroot.'/user/tabs.php';
|
||||
|
||||
} else if ($isfrontpage) {
|
||||
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
|
||||
$currenttab = 'permissions';
|
||||
$tabfile = 'tabs.php';
|
||||
|
||||
} else {
|
||||
$currenttab = 'permissions';
|
||||
$tabfile = 'tabs.php';
|
||||
}
|
||||
|
||||
|
||||
// Handle the cancel button.
|
||||
if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Make sure this user can override that role
|
||||
if (empty($overridableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotoverriderolehere', '', get_context_url($context), $a);
|
||||
}
|
||||
|
||||
// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable->read_submitted_permissions();
|
||||
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$overridestable->save_changes();
|
||||
$rolename = $overridableroles[$roleid];
|
||||
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Finally start page output
|
||||
echo $OUTPUT->header();
|
||||
if ($tabfile) {
|
||||
include($tabfile);
|
||||
}
|
||||
echo $OUTPUT->heading_with_help($title, 'overrides');
|
||||
|
||||
// Show UI for overriding roles.
|
||||
if (!empty($capabilities)) {
|
||||
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'role'), 'generalbox boxaligncenter');
|
||||
|
||||
} else {
|
||||
// Print the capabilities overrideable in this context
|
||||
echo $OUTPUT->box_start('generalbox capbox');
|
||||
|
||||
?>
|
||||
<form id="overrideform" action="<?php echo $baseurl ?>" method="post"><div>
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()); ?>" />
|
||||
|
||||
<div class="advancedbutton">
|
||||
<input type="submit" name="toggleadvanced" value="<?php echo $showadvancedlabel ?>" />
|
||||
</div>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" name="savechanges" value="<?php print_string('savechanges') ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid); ?>" />
|
||||
<?php
|
||||
|
||||
echo '<p class="overridenotice">' . get_string('highlightedcellsshowinherit', 'role') . ' </p>';
|
||||
@@ -218,50 +171,17 @@
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
</div></form>
|
||||
<?php
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
<?php
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
}
|
||||
// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
$select = new single_select(new moodle_url($baseurl), 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('overrideanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
echo '<p><a href="' . $returnurl . '">' . get_string('backtoallroles', 'role') . '</a></p>';
|
||||
echo '</div>';
|
||||
|
||||
/// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
$select = new single_select(new moodle_url($baseurl), 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('overrideanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
echo '<p><a href="' . $baseurl . '">' . get_string('backtoallroles', 'role') . '</a></p>';
|
||||
echo '</div>';
|
||||
|
||||
} else if (empty($overridableroles)) {
|
||||
/// Print a message that there are no roles that can me assigned here.
|
||||
echo $OUTPUT->heading(get_string('notabletooverrideroleshere', 'role'), 3, 'mdl-align');
|
||||
|
||||
} else {
|
||||
/// Show UI for choosing a role to assign.
|
||||
|
||||
$table = new html_table();
|
||||
$table->tablealign = 'center';
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('role'), get_string('description'), get_string('overrides', 'role'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center');
|
||||
|
||||
foreach ($overridableroles as $roleid => $rolename) {
|
||||
$countusers = 0;
|
||||
$description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
|
||||
$table->data[] = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>',
|
||||
$description, $overridecounts[$roleid]);
|
||||
}
|
||||
|
||||
echo $OUTPUT->table($table);
|
||||
|
||||
if (!$isfrontpage && ($url = get_context_url($context))) {
|
||||
echo '<div class="backlink"><a href="' . $url . '">' .
|
||||
get_string('backto', '', $contextname) . '</a></div>';
|
||||
} else if ($returnurl) {
|
||||
echo '<div class="backlink"><a href="' . $CFG->wwwroot . '/' . $returnurl . '">' .
|
||||
get_string('backtopageyouwereon') . '</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script serves draft files of current user
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 2009 Petr Skoda (skodak) [email protected]
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
|
||||
require_once("permissions_forms.php");
|
||||
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT);
|
||||
$capability = optional_param('capability', false, PARAM_CAPABILITY);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$prevent = optional_param('prevent', 0, PARAM_BOOL);
|
||||
$allow = optional_param('allow', 0, PARAM_BOOL);
|
||||
$unprohibit = optional_param('unprohibit', 0, PARAM_BOOL);
|
||||
$prohibit = optional_param('prohibit', 0, PARAM_BOOL);
|
||||
|
||||
// security first
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/role:review', $context);
|
||||
|
||||
$PAGE->set_url('/admin/roles/permissions.php', array('contextid' => $contextid));
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$userid = 0;
|
||||
$tabfile = null;
|
||||
|
||||
if ($course) {
|
||||
$isfrontpage = ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID);
|
||||
|
||||
} else {
|
||||
$isfrontpage = false;
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
$courseid = optional_param('courseid', SITEID, PARAM_INT); // needed for user/tabs.php
|
||||
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
||||
$PAGE->url->param('courseid', $courseid);
|
||||
$userid = $context->instanceid;
|
||||
} else {
|
||||
$course = $SITE;
|
||||
}
|
||||
}
|
||||
|
||||
$courseid = $course->id;
|
||||
|
||||
|
||||
// These are needed early because of tabs.php
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
|
||||
|
||||
if ($capability) {
|
||||
$capability = $DB->get_record('capabilities', array('name'=>$capability), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
$allowoverrides = has_capability('moodle/role:override', $context);
|
||||
$allowsafeoverrides = has_capability('moodle/role:safeoverride', $context);
|
||||
|
||||
$contextname = print_context_name($context);
|
||||
$title = get_string('permissionsincontext', 'role', $contextname);
|
||||
$straction = get_string('permissions', 'role'); // Used by tabs.php
|
||||
$PAGE->set_title($title);
|
||||
|
||||
// Print the header and tabs
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
print_error('cannotoverridebaserole', 'error');
|
||||
|
||||
} else if ($context->contextlevel == CONTEXT_USER) {
|
||||
// NOTE: this is not linked from UI for now
|
||||
$userid = $context->instanceid;
|
||||
$user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST);
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
|
||||
// course header
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
} else {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
$PAGE->navbar->add(get_string('participants'), new moodle_url('/user/index.php', array('id'=>$courseid)));
|
||||
}
|
||||
$PAGE->set_heading($fullname);
|
||||
}
|
||||
$PAGE->navbar->add($fullname, new moodle_url("$CFG->wwwroot/user/view.php", array('id'=>$userid,'course'=>$courseid)));
|
||||
$PAGE->navbar->add($straction);
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'permissions';
|
||||
$tabfile = $CFG->dirroot.'/user/tabs.php';
|
||||
|
||||
} else if ($isfrontpage) {
|
||||
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
|
||||
$currenttab = 'permissions';
|
||||
$tabfile = 'tabs.php';
|
||||
|
||||
} else {
|
||||
$currenttab = 'permissions';
|
||||
$tabfile = 'tabs.php';
|
||||
}
|
||||
|
||||
// handle confirmations and actions
|
||||
if ($prevent and isset($overridableroles[$roleid]) and $capability) {
|
||||
if ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability))) {
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
role_change_permission($roleid, $context, $capability->name, CAP_PREVENT);
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'role'=>$overridableroles[$roleid], 'context'=>$contextname);
|
||||
$message = get_string('confirmroleprevent', 'role', $a);
|
||||
$continueurl = new moodle_url($PAGE->url, array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'prevent'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($tabfile) {
|
||||
include($tabfile);
|
||||
}
|
||||
echo $OUTPUT->heading($title);
|
||||
echo $OUTPUT->confirm($message, $continueurl, $PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($unprohibit and isset($overridableroles[$roleid]) and $capability) {
|
||||
if ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability))) {
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
role_change_permission($roleid, $context, $capability->name, CAP_INHERIT);
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'role'=>$overridableroles[$roleid], 'context'=>$contextname);
|
||||
$message = get_string('confirmroleunprohibit', 'role', $a);
|
||||
$continueurl = new moodle_url($PAGE->url, array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'unprohibit'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($tabfile) {
|
||||
include($tabfile);
|
||||
}
|
||||
echo $OUTPUT->heading($title);
|
||||
echo $OUTPUT->confirm($message, $continueurl, $PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($allow and $capability) {
|
||||
if ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability))) {
|
||||
$mform = new role_allow_form(null, array($context, $capability, $overridableroles));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else if ($data = $mform->get_data() and !empty($data->roleid)) {
|
||||
$roleid = $data->roleid;
|
||||
if (isset($overridableroles[$roleid])) {
|
||||
role_change_permission($roleid, $context, $capability->name, CAP_ALLOW);
|
||||
}
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'context'=>$contextname);
|
||||
$message = get_string('roleallowinfo', 'role', $a);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($tabfile) {
|
||||
include($tabfile);
|
||||
}
|
||||
echo $OUTPUT->heading($title);
|
||||
echo $OUTPUT->box($message);
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($prohibit and $capability) {
|
||||
if ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability))) {
|
||||
$mform = new role_prohibit_form(null, array($context, $capability, $overridableroles));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else if ($data = $mform->get_data() and !empty($data->roleid)) {
|
||||
$roleid = $data->roleid;
|
||||
if (isset($overridableroles[$roleid])) {
|
||||
role_change_permission($roleid, $context, $capability->name, CAP_PROHIBIT);
|
||||
}
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'context'=>$contextname);
|
||||
$message = get_string('roleprohibitinfo', 'role', $a);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($tabfile) {
|
||||
include($tabfile);
|
||||
}
|
||||
echo $OUTPUT->box($message);
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($tabfile) {
|
||||
include($tabfile);
|
||||
}
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$table = new permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
|
||||
echo $OUTPUT->box_start('generalbox capbox');
|
||||
// print link to advanced override page
|
||||
if ($overridableroles) {
|
||||
$overrideurl = new moodle_url('/admin/roles/override.php', array('contextid' => $context->id));
|
||||
$select = new single_select($overrideurl, 'roleid', $nameswithcounts);
|
||||
$select->label = get_string('advancedoverride', 'role');
|
||||
echo '<div class="advancedoverride">'.$OUTPUT->render($select).'</div>';
|
||||
}
|
||||
$table->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
echo '<div class="backlink"><a href="' . get_context_url($context) . '">' . get_string('backto', '', $contextname) . '</a></div>';
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer($course);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script serves draft files of current user
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 2009 Petr Skoda (skodak) [email protected]
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
|
||||
class role_allow_form extends moodleform {
|
||||
|
||||
// Define the form
|
||||
function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach($needed as $id=>$unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
foreach($forbidden as $id=>$unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'allowheader', get_string('roleallowheader', 'role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden','capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden','contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden','allow');
|
||||
$mform->setType('allow', PARAM_INT);
|
||||
$mform->setDefault('allow', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('allow', 'role'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class role_prohibit_form extends moodleform {
|
||||
|
||||
// Define the form
|
||||
function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach($forbidden as $id=>$unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden','capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden','contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden','prohibit');
|
||||
$mform->setType('prohibit', PARAM_INT);
|
||||
$mform->setDefault('prohibit', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('prohibit', 'role'));
|
||||
}
|
||||
}
|
||||
+54
-89
@@ -1,35 +1,29 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Handles headers and tabs for the roles control at any level apart from SYSTEM level
|
||||
* We assume that $currenttab, $assignableroles and $overridableroles are defined
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
@@ -56,11 +50,9 @@ if ($currenttab != 'update') {
|
||||
$PAGE->navbar->add($straction);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
break;
|
||||
|
||||
case CONTEXT_USER:
|
||||
echo $OUTPUT->header();
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSECAT:
|
||||
@@ -78,14 +70,12 @@ if ($currenttab != 'update') {
|
||||
$PAGE->navbar->add(get_string("roles"));
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading("$SITE->fullname: $strcourses");
|
||||
echo $OUTPUT->header();
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSE:
|
||||
if ($context->instanceid != SITEID) {
|
||||
$course = $DB->get_record('course', array('id'=>$context->instanceid));
|
||||
|
||||
require_login($course);
|
||||
if (empty($title)) {
|
||||
$title = get_string("editcoursesettings");
|
||||
}
|
||||
@@ -93,7 +83,6 @@ if ($currenttab != 'update') {
|
||||
$PAGE->navbar->add(get_string('roles'), $roleslink, navigation_node::TYPE_SETTING);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -105,8 +94,6 @@ if ($currenttab != 'update') {
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$PAGE->navigation->add(get_string('roles'));
|
||||
|
||||
if (empty($title)) {
|
||||
@@ -114,45 +101,16 @@ if ($currenttab != 'update') {
|
||||
}
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
break;
|
||||
|
||||
case CONTEXT_BLOCK:
|
||||
if ($blockinstance = $DB->get_record('block_instances', array('id' => $context->instanceid))) {
|
||||
$blockname = print_context_name($context);
|
||||
|
||||
$parentcontext = get_context_instance_by_id($blockinstance->parentcontextid);
|
||||
switch ($parentcontext->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_category_by_id($parentcontext->instanceid);
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSE:
|
||||
require_login($parentcontext->instanceid);
|
||||
break;
|
||||
|
||||
case CONTEXT_MODULE:
|
||||
$cm = get_coursemodule_from_id('', $parentcontext->instanceid);
|
||||
require_login($parentcontext->instanceid, false, $cm);
|
||||
break;
|
||||
|
||||
case CONTEXT_USER:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new invalid_state_exception('Block context ' . $blockname .
|
||||
' has parent context with an improper contextlevel ' . $parentcontext->contextlevel);
|
||||
|
||||
|
||||
}
|
||||
$PAGE->navbar->add($blockname);
|
||||
$PAGE->navbar->add($straction);
|
||||
$PAGE->set_title("$straction: $blockname");
|
||||
$PAGE->set_heading($PAGE->course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -167,16 +125,12 @@ if ($currenttab != 'update') {
|
||||
$toprow = array();
|
||||
$inactive = array();
|
||||
$activetwo = array();
|
||||
$secondrow = array();
|
||||
|
||||
$permissionsrow = array();
|
||||
|
||||
if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything except SYSTEM context
|
||||
|
||||
if (!empty($returnurl)) {
|
||||
$returnurlparam = '&returnurl=' . $returnurl;
|
||||
} else {
|
||||
$returnurlparam = '';
|
||||
}
|
||||
|
||||
if ($context->contextlevel == CONTEXT_MODULE) { // Only show update button if module
|
||||
$toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.
|
||||
$context->instanceid.'&return=true&sesskey='.sesskey(), get_string('settings'));
|
||||
@@ -184,29 +138,40 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex
|
||||
|
||||
if (!empty($assignableroles) || $currenttab=='assign') {
|
||||
$toprow[] = new tabobject('assign',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.$returnurlparam,
|
||||
new moodle_url('/admin/roles/assign.php', array('contextid'=>$context->id)),
|
||||
get_string('localroles', 'role'), '', true);
|
||||
}
|
||||
|
||||
if (!empty($overridableroles)) {
|
||||
$toprow[] = new tabobject('override',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id.$returnurlparam,
|
||||
get_string('overridepermissions', 'role'), '', true);
|
||||
if (has_capability('moodle/role:review', $context) or !empty($overridableroles)) {
|
||||
$permissionsrow['permissions'] = new tabobject('permissions',
|
||||
new moodle_url('/admin/roles/permissions.php', array('contextid'=>$context->id)),
|
||||
get_string('permissions', 'role'), '', true);
|
||||
}
|
||||
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
|
||||
'moodle/role:override', 'moodle/role:assign'), $context)) {
|
||||
$toprow[] = new tabobject('check',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/check.php?contextid='.$context->id.$returnurlparam,
|
||||
$permissionsrow['check'] = new tabobject('check',
|
||||
new moodle_url('/admin/roles/check.php', array('contextid'=>$context->id)),
|
||||
get_string('checkpermissions', 'role'));
|
||||
}
|
||||
|
||||
if ($permissionsrow) {
|
||||
$firstpermissionrow = reset($permissionsrow);
|
||||
$toprow[] = new tabobject('toppermissions', $firstpermissionrow->link, get_string('permissions', 'role'), '', true);
|
||||
if (!empty($permissionsrow[$currenttab])) {
|
||||
$secondrow = array_values($permissionsrow);
|
||||
$inactive = array('toppermissions');
|
||||
$activetwo = array('toppermissions');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($availablefilters)) {
|
||||
$toprow[] = new tabobject('filters',
|
||||
$CFG->wwwroot.'/filter/manage.php?contextid=' . $context->id,
|
||||
new moodle_url('/filter/manage.php', array('contextid'=>$context->id)),
|
||||
get_string('filters', 'admin'));
|
||||
}
|
||||
}
|
||||
unset($permissionsrow);
|
||||
|
||||
/// Here other core tabs should go (always calling tabs.php files)
|
||||
/// All the logic to decide what to show must be self-contained in the tabs file
|
||||
@@ -215,26 +180,26 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex
|
||||
|
||||
/// Finally, we support adding some 'on-the-fly' tabs here
|
||||
/// All the logic to decide what to show must be self-cointained in the tabs file
|
||||
if (!empty($CFG->extratabs)) {
|
||||
if ($extratabs = explode(',', $CFG->extratabs)) {
|
||||
asort($extratabs);
|
||||
foreach($extratabs as $extratab) {
|
||||
/// Each extra tab must be one $CFG->dirroot relative file
|
||||
if (file_exists($CFG->dirroot . '/' . $extratab)) {
|
||||
include_once($CFG->dirroot . '/' . $extratab);
|
||||
}
|
||||
if (!empty($CFG->extratabs)) {
|
||||
if ($extratabs = explode(',', $CFG->extratabs)) {
|
||||
asort($extratabs);
|
||||
foreach($extratabs as $extratab) {
|
||||
/// Each extra tab must be one $CFG->dirroot relative file
|
||||
if (file_exists($CFG->dirroot . '/' . $extratab)) {
|
||||
include($CFG->dirroot . '/' . $extratab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$inactive[] = $currenttab;
|
||||
$inactive[] = $currenttab;
|
||||
|
||||
$tabs = array($toprow);
|
||||
$tabs = array($toprow);
|
||||
|
||||
/// If there are any secondrow defined, let's introduce it
|
||||
if (isset($secondrow) && is_array($secondrow) && !empty($secondrow)) {
|
||||
$tabs[] = $secondrow;
|
||||
}
|
||||
if (!empty($secondrow)) {
|
||||
$tabs[] = $secondrow;
|
||||
}
|
||||
|
||||
print_tabs($tabs, $currenttab, $inactive, $activetwo);
|
||||
print_tabs($tabs, $currenttab, $inactive, $activetwo);
|
||||
|
||||
|
||||
+22
-28
@@ -1,37 +1,30 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User roles report list all the users who have been assigned a particular
|
||||
* role in all contexts.
|
||||
*
|
||||
* @copyright © 2007 The Open University and others
|
||||
* @author [email protected] and others
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*//** */
|
||||
* @package moodlecore
|
||||
* @subpackage role
|
||||
* @copyright © 2007 The Open University and others
|
||||
* @author [email protected] and others
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
|
||||
@@ -138,7 +131,8 @@ echo $OUTPUT->header();
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'usersroles';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
include($CFG->dirroot.'/user/tabs.php');
|
||||
|
||||
echo $OUTPUT->heading($title, 3);
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
|
||||
|
||||
@@ -237,12 +237,6 @@ $CFG->admin = 'admin';
|
||||
// logs in. The site front page will always show the same (logged-out) view.
|
||||
// $CFG->disablemycourses = true;
|
||||
//
|
||||
// Enable this option if you need fully working default frontpage role,
|
||||
// please note it might cause serious memory and performance issues,
|
||||
// also there should not be any negative capabilities in default
|
||||
// frontpage role (MDL-19039).
|
||||
// $CFG->fullusersbycapabilityonfrontpage = true;
|
||||
//
|
||||
// If this setting is set to true, then Moodle will track the IP of the
|
||||
// current user to make sure it hasn't changed during a session. This
|
||||
// will prevent the possibility of sessions being hijacked via XSS, but it
|
||||
|
||||
@@ -282,6 +282,19 @@ $string['whydoesusernothavecap'] = 'Why does $a->fullname not have capability $a
|
||||
$string['xroleassignments'] = '$a\'s role assignments';
|
||||
$string['xuserswiththerole'] = 'Users with the role \"$a->role\"';
|
||||
|
||||
// pending new strings for new permission UI
|
||||
$string['advancedoverride'] = 'Advanced role override';
|
||||
$string['confirmroleunprohibit'] = 'Do you really want to remove <strong>$a->role</strong> from the list of prohibited roles for capability $a->cap in context $a->context?';
|
||||
$string['confirmroleprevent'] = 'Do you really want to remove <strong>$a->role</strong> from the list of allowed roles for capability $a->cap in context $a->context?';
|
||||
$string['neededroles'] = 'Roles with permission';
|
||||
$string['permissionsincontext'] = 'Permissions in $a';
|
||||
$string['prohibitedroles'] = 'Prohibited';
|
||||
$string['roleallowheader'] = 'Allow role:';
|
||||
$string['roleallowinfo'] = 'Select a role to be added to the list of allowed roles in context $a->context, capability $a->cap:';
|
||||
$string['roleprohibitheader'] = 'Prohibit role';
|
||||
$string['roleprohibitinfo'] = 'Select a role to be added to the list of prohibited roles in context $a->context, capability $a->cap:';
|
||||
$string['roleselect'] = 'Select role';
|
||||
|
||||
//OBSOLETED in 1.9!
|
||||
$string['course:viewcoursegrades'] = 'View course grades';
|
||||
$string['user:viewusergrades'] = 'View user grades';
|
||||
|
||||
+504
-692
File diff suppressed because it is too large
Load Diff
+4
-40
@@ -61,22 +61,14 @@
|
||||
* require_once($CFG->libdir.'/adminlib.php');
|
||||
* admin_externalpage_setup('foo');
|
||||
* // functionality like processing form submissions goes here
|
||||
* admin_externalpage_print_header();
|
||||
* $OUTPUT->header();
|
||||
* // your HTML goes here
|
||||
* print_footer();
|
||||
* $OUTPUT->footer();
|
||||
* </code>
|
||||
*
|
||||
* The admin_externalpage_setup() function call ensures the user is logged in,
|
||||
* and makes sure that they have the proper role permission to access the page.
|
||||
*
|
||||
* The admin_externalpage_print_header() function prints the header (it figures
|
||||
* out what category and subcategories the page is classified under) and ensures
|
||||
* that you're using the admin pagelib (which provides the admin tree block and
|
||||
* the admin bookmarks block).
|
||||
*
|
||||
* The admin_externalpage_print_footer() function properly closes the tables
|
||||
* opened up by the admin_externalpage_print_header() function and prints the
|
||||
* standard Moodle footer.
|
||||
* It also configures all $PAGE properties needed for navigation.
|
||||
*
|
||||
* ADMIN_CATEGORY OBJECTS
|
||||
*
|
||||
@@ -5264,6 +5256,7 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
|
||||
if (strpos($PAGE->pagetype, 'admin-') !== 0) {
|
||||
$PAGE->set_pagetype('admin-' . $PAGE->pagetype);
|
||||
}
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
if (empty($SITE->fullname) || empty($SITE->shortname)) {
|
||||
// During initial install.
|
||||
@@ -5302,35 +5295,6 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
|
||||
$PAGE->navigation->clear_cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print header for admin page
|
||||
* @deprecated since Moodle 20. Please use normal $OUTPUT->header() instead
|
||||
* @param string $focus focus element
|
||||
*/
|
||||
function admin_externalpage_print_header($focus='') {
|
||||
global $CFG, $PAGE, $SITE, $OUTPUT;
|
||||
|
||||
//debugging('admin_externalpage_print_header is deprecated. Please $OUTPUT->header() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
if (!is_string($focus)) {
|
||||
$focus = ''; // BC compatibility, there used to be adminroot parameter
|
||||
}
|
||||
|
||||
$PAGE->set_focuscontrol($focus);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 1.9. Please use normal $OUTPUT->footer() instead
|
||||
*/
|
||||
function admin_externalpage_print_footer() {
|
||||
// TODO Still 103 referernces in core code. Don't do debugging output yet.
|
||||
debugging('admin_externalpage_print_footer is deprecated. Please $OUTPUT->footer() instead.', DEBUG_DEVELOPER);
|
||||
global $OUTPUT;
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reference to admin tree root
|
||||
*
|
||||
|
||||
@@ -440,6 +440,19 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'moodle/role:review' => array(
|
||||
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'moodle/role:override' => array(
|
||||
|
||||
'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
|
||||
|
||||
+32
-2
@@ -3010,8 +3010,8 @@ function notice_yesno($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno=
|
||||
|
||||
global $OUTPUT;
|
||||
|
||||
$buttoncontinue = new simple_button(new moodle_url($linkyes, $optionsyes), get_string('yes'), $methodyes);
|
||||
$buttoncancel = new simple_button(new moodle_url($linkno, $optionsno), get_string('no'), $methodno);
|
||||
$buttoncontinue = new single_button(new moodle_url($linkyes, $optionsyes), get_string('yes'), $methodyes);
|
||||
$buttoncancel = new single_button(new moodle_url($linkno, $optionsno), get_string('no'), $methodno);
|
||||
|
||||
echo $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel);
|
||||
}
|
||||
@@ -3666,6 +3666,36 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print header for admin page
|
||||
* @deprecated since Moodle 20. Please use normal $OUTPUT->header() instead
|
||||
* @param string $focus focus element
|
||||
*/
|
||||
function admin_externalpage_print_header($focus='') {
|
||||
global $CFG, $PAGE, $SITE, $OUTPUT;
|
||||
|
||||
//debugging('admin_externalpage_print_header is deprecated. Please $OUTPUT->header() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
if (!is_string($focus)) {
|
||||
$focus = ''; // BC compatibility, there used to be adminroot parameter
|
||||
}
|
||||
|
||||
$PAGE->set_focuscontrol($focus);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 1.9. Please use normal $OUTPUT->footer() instead
|
||||
*/
|
||||
function admin_externalpage_print_footer() {
|
||||
// TODO Still 103 referernces in core code. Don't do debugging output yet.
|
||||
debugging('admin_externalpage_print_footer is deprecated. Please $OUTPUT->footer() instead.', DEBUG_DEVELOPER);
|
||||
global $OUTPUT;
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
/// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 61 B |
@@ -947,43 +947,6 @@ table.message_search_results td {
|
||||
color:#ff0000;
|
||||
}
|
||||
|
||||
#admin-roles-override .capcurrent {
|
||||
background-color:#FFFFFF;
|
||||
border: 1px solid #cecece;
|
||||
}
|
||||
table.explainpermissions .decisive.has,
|
||||
#explaincaps .rolecap.yes {
|
||||
background-color: #ddffdd;
|
||||
}
|
||||
table.explainpermissions .decisive.hasnot,
|
||||
table.explainpermissions .prohibit,
|
||||
#explaincaps .rolecap.no {
|
||||
background-color: #ffdddd;
|
||||
}
|
||||
table.explainpermissions .prohibit,
|
||||
table.explainpermissions .decisive {
|
||||
font-weight: bold;
|
||||
}
|
||||
table.explainpermissions .overridden {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
#admin-roles-define .capdefault {
|
||||
background-color:#dddddd;
|
||||
border: 1px solid #cecece;
|
||||
}
|
||||
|
||||
#admin-roles-manage .rolecap,
|
||||
#admin-roles-override .rolecap {
|
||||
border:none;
|
||||
border-bottom:1px solid;
|
||||
border-bottom-color: #cecece;
|
||||
}
|
||||
|
||||
.rolecap .cap-name,
|
||||
.rolecap .note {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
form.mform .required label {
|
||||
color:#a00;
|
||||
}
|
||||
@@ -994,4 +957,163 @@ form.mform .required .fgroup span label {
|
||||
color:#000;
|
||||
}
|
||||
|
||||
/**** role related CSS ****/
|
||||
|
||||
.capbox {
|
||||
width: 80%;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
|
||||
table.rolecap {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.rolecap th {
|
||||
border: none;
|
||||
}
|
||||
|
||||
table.rolecap th {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
table.rolecap thead th {
|
||||
background-color: #dddddd;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
table.rolecap tr {
|
||||
border-bottom: 1px solid #cecece;
|
||||
}
|
||||
|
||||
.rolecap .cap-name,
|
||||
.rolecap .note {
|
||||
font-size: 0.75em;
|
||||
display: block;
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
.rolecap .cap-name {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
table.rolecap .hiddenrow {
|
||||
display: none;
|
||||
}
|
||||
|
||||
table.rolecap .inherit,
|
||||
table.rolecap .allow,
|
||||
table.rolecap .prevent,
|
||||
table.rolecap .prohibit {
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
table.rolecap label {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 2.5em;
|
||||
}
|
||||
|
||||
table#explaincaps {
|
||||
width: 60%;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
table#explaincaps .rolecap.no {
|
||||
background-color: #ffdddd;
|
||||
}
|
||||
|
||||
table#explaincaps .rolecap.yes {
|
||||
background-color: #ddffdd;
|
||||
}
|
||||
|
||||
#admin-roles-define .backlink,
|
||||
#admin-roles-permissions .backlink,
|
||||
#admin-roles-assign .backlink,
|
||||
#admin-roles-check .backlink,
|
||||
#admin-roles-override .backlink {
|
||||
text-align: right;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
#admin-roles-override .capcurrent {
|
||||
background-color:#FFFFFF;
|
||||
border: 1px solid #cecece;
|
||||
}
|
||||
|
||||
#admin-roles-permissions .advancedoverride {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#admin-roles-define .capdefault {
|
||||
background-color:#dddddd;
|
||||
border: 1px solid #cecece;
|
||||
}
|
||||
|
||||
#admin-roles-define .topfields {
|
||||
margin: 1em 0 2em;
|
||||
}
|
||||
|
||||
.roleassigntable {
|
||||
width: 80%;
|
||||
}
|
||||
.roleassigntable td {
|
||||
vertical-align: top;
|
||||
padding: 0.2em 0.3em
|
||||
}
|
||||
.roleassigntable p {
|
||||
text-align: left;
|
||||
margin: 0.2em 0;
|
||||
}
|
||||
.roleassigntable #existingcell,
|
||||
.roleassigntable #potentialcell {
|
||||
width: 42%;
|
||||
}
|
||||
.roleassigntable #existingcell label,
|
||||
.roleassigntable #potentialcell label {
|
||||
font-weight: bold;
|
||||
}
|
||||
.roleassigntable #buttonscell {
|
||||
width: 16%;
|
||||
}
|
||||
.roleassigntable #buttonscell #add,
|
||||
.roleassigntable #buttonscell #remove {
|
||||
width: 100%;
|
||||
margin: 0.3em 0;
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
.roleassigntable #buttonscell p {
|
||||
margin: 0.3em 0;
|
||||
}
|
||||
.roleassigntable #buttonscell #assignoptions {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
.roleassigntable #buttonscell #assignoptions .collapsibleregioncaption {
|
||||
font-weight: bold;
|
||||
}
|
||||
.roleassigntable #buttonscell #addcontrols {
|
||||
margin-top: 3em;
|
||||
height: 13em;
|
||||
}
|
||||
.roleassigntable #removeselect_wrapper,
|
||||
.roleassigntable #addselect_wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
.roleassigntable #removeselect_wrapper label,
|
||||
.roleassigntable #addselect_wrapper label {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#admin-roles-override .overridenotice,
|
||||
#admin-roles-define .definenotice {
|
||||
margin: 1em 10% 2em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.capabilitysearchui {
|
||||
text-align: left;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,11 +261,6 @@ body#admin-index .copyright {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.rolecap .cap-name,
|
||||
.rolecap .note {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
#adminsettings .form-shortname {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
@@ -274,12 +269,6 @@ body#admin-index .copyright {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
#admin-roles-override .cell.c1,
|
||||
#admin-roles-assign .cell.c3,
|
||||
#admin-roles-assign .cell.c1 {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
#admin-lang .translator .strkey {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,22 @@ body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
text-align:center
|
||||
}
|
||||
|
||||
.buttons div,
|
||||
.buttons form {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
.singlebutton {
|
||||
text-align:center;
|
||||
padding: 5px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
|
||||
form {
|
||||
margin-bottom:0;
|
||||
}
|
||||
@@ -249,21 +265,6 @@ div.collapsibleregion div.collapsibleregioncaption a {
|
||||
margin-right:auto;
|
||||
}
|
||||
|
||||
#notice .buttons {
|
||||
text-align:center
|
||||
}
|
||||
|
||||
#notice .buttons div,
|
||||
#notice .buttons form {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
#notice .singlebutton {
|
||||
text-align:center;
|
||||
padding: 5px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.errorbox {
|
||||
border-width:1px;
|
||||
border-style:solid;
|
||||
@@ -505,16 +506,6 @@ form.popupform label {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#group-groupings .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#group-groupings .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#group-usersummary {
|
||||
width: 14em;
|
||||
}
|
||||
@@ -1065,10 +1056,6 @@ body#admin-modules table.generaltable td.c0
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#admin-maintenance .buttons {
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#admin-report-unittest-index .exception pre {
|
||||
padding: 8px;
|
||||
}
|
||||
@@ -1136,177 +1123,6 @@ body#admin-modules table.generaltable td.c0
|
||||
#admin-qtypes #qtypes img.spacer {
|
||||
width: 16px;
|
||||
}
|
||||
#filter-manage .buttons,
|
||||
#admin-roles-allow .buttons,
|
||||
#admin-roles-manage .buttons,
|
||||
#admin-roles-define .buttons,
|
||||
#admin-roles-override .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
#admin-roles-manage .buttons .singlebutton,
|
||||
#admin-roles-define .buttons .singlebutton,
|
||||
#admin-roles-override .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
#admin-roles-define .topfields {
|
||||
margin: 1em 0 2em;
|
||||
}
|
||||
.roleassigntable {
|
||||
width: 100%;
|
||||
}
|
||||
.roleassigntable td {
|
||||
vertical-align: top;
|
||||
padding: 0.2em 0.3em
|
||||
}
|
||||
.roleassigntable p {
|
||||
text-align: left;
|
||||
margin: 0.2em 0;
|
||||
}
|
||||
.roleassigntable #existingcell,
|
||||
.roleassigntable #potentialcell {
|
||||
width: 42%;
|
||||
}
|
||||
.roleassigntable #existingcell label,
|
||||
.roleassigntable #potentialcell label {
|
||||
font-weight: bold;
|
||||
}
|
||||
.roleassigntable #buttonscell {
|
||||
width: 16%;
|
||||
}
|
||||
.roleassigntable #buttonscell #add,
|
||||
.roleassigntable #buttonscell #remove {
|
||||
width: 100%;
|
||||
margin: 0.3em 0;
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
.roleassigntable #buttonscell p {
|
||||
margin: 0.3em 0;
|
||||
}
|
||||
.roleassigntable #buttonscell #assignoptions {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
.roleassigntable #buttonscell #assignoptions .collapsibleregioncaption {
|
||||
font-weight: bold;
|
||||
}
|
||||
.roleassigntable #buttonscell #addcontrols {
|
||||
margin-top: 3em;
|
||||
height: 13em;
|
||||
}
|
||||
.roleassigntable #removeselect_wrapper,
|
||||
.roleassigntable #addselect_wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
.roleassigntable #removeselect_wrapper label,
|
||||
.roleassigntable #addselect_wrapper label {
|
||||
font-weight: normal;
|
||||
}
|
||||
#admin-roles-define .mform {
|
||||
width: 100%;
|
||||
}
|
||||
#filter-manage .backlink,
|
||||
#admin-roles-manage .backlink,
|
||||
#admin-roles-define .backlink,
|
||||
#admin-roles-explain .backlink,
|
||||
#admin-roles-assign .backlink,
|
||||
#admin-roles-override .backlink {
|
||||
text-align: right;
|
||||
width: 90%;
|
||||
margin: 2em auto 1em;
|
||||
}
|
||||
|
||||
#admin-roles-explain #chooseuser h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
#admin-roles-explain #chooseusersubmit {
|
||||
margin: 1em 0 0;
|
||||
text-align: center;
|
||||
}
|
||||
#admin-roles-usersroles .contextname {
|
||||
margin: 0.5em 0 0;
|
||||
}
|
||||
#admin-roles-usersroles p {
|
||||
margin: 0;
|
||||
}
|
||||
table.rolecap {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.capabilitysearchui {
|
||||
text-align: left;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
table.rolecap .hiddenrow {
|
||||
display: none;
|
||||
}
|
||||
|
||||
tr.rolecap th {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
}
|
||||
table.rolecap .inherit,
|
||||
table.rolecap .allow,
|
||||
table.rolecap .prevent,
|
||||
table.rolecap .prohibit {
|
||||
text-align:center;
|
||||
}
|
||||
table.rolecap label {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 2.5em;
|
||||
}
|
||||
.rolecap .cap-name,
|
||||
.rolecap .note {
|
||||
display: block;
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
#admin-roles-override .cell.c1,
|
||||
#admin-roles-assign .cell.c3,
|
||||
#admin-roles-assign .cell.c1 {
|
||||
padding-top: 0.75em;
|
||||
}
|
||||
|
||||
#admin-roles-override .overridenotice,
|
||||
#admin-roles-define .definenotice {
|
||||
margin: 1em 10% 2em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
table.explainpermissions {
|
||||
border: 1px solid black;
|
||||
}
|
||||
table.explainpermissions .cell {
|
||||
border-bottom: none;
|
||||
}
|
||||
table.explainpermissions th.header,
|
||||
table.explainpermissions th.cell,
|
||||
table.explainpermissions td.cell {
|
||||
border-left: 1px solid black;
|
||||
border-right: 1px solid black;
|
||||
vertical-align: middle;
|
||||
}
|
||||
table.explainpermissions .newcontext .cell,
|
||||
table.explainpermissions .row2 th.header {
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
table.explainpermissions .cell.inherit,
|
||||
table.explainpermissions .cell.noroles {
|
||||
color: gray;
|
||||
}
|
||||
table.explainpermissions th.assignment {
|
||||
text-align: left;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
table.explainpermissions .cell.prohibit {
|
||||
font-weight: bold;
|
||||
}
|
||||
table.explainpermissions .cell {
|
||||
padding: 0.2em 0.5em;
|
||||
text-align: center;
|
||||
}
|
||||
#admin-lang .generalbox {
|
||||
text-align:center;
|
||||
margin:auto;
|
||||
@@ -2555,17 +2371,6 @@ body#admin-course-category .addcategory {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
body#admin-course-index .buttons .singlebutton,
|
||||
body#admin-course-category .buttons .singlebutton {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
body#admin-course-index .buttons,
|
||||
body#admin-course-category .buttons {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
body#admin-course-index .editcourse {
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
@@ -2793,28 +2598,8 @@ body#doc-contents ul {
|
||||
|
||||
/* scales edit */
|
||||
|
||||
.grade-edit-scale .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.grade-edit-scale .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
/* outcomes edit */
|
||||
|
||||
.grade-edit-outcome .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.grade-edit-outcome .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
div.allcoursegrades {
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
@@ -2835,20 +2620,10 @@ div.allcoursegrades {
|
||||
padding-bottom:15px;
|
||||
}
|
||||
|
||||
.grade-edit-tree .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.grade-edit-tree .idnumber {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.grade-edit-tree .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.grade-edit-tree .movetarget {
|
||||
position: relative;
|
||||
width: 80px;
|
||||
@@ -3928,16 +3703,6 @@ body#user-index h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#user-view .buttons,
|
||||
#user-index .buttons {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#user-view .buttons form,
|
||||
#user-view .buttons form div {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
body#user-index #longtimenosee,
|
||||
body#user-index #showall {
|
||||
text-align: center;
|
||||
|
||||
+6
-6
@@ -218,11 +218,11 @@
|
||||
if (!empty($showroles) and !empty($user)) { // this variable controls whether this roles is showed, or not, so only user/view page should set this flag
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
|
||||
'moodle/role:override', 'moodle/role:manage'), $usercontext)) {
|
||||
'moodle/role:override', 'moodle/role:manage', 'moodle/role:review'), $usercontext)) {
|
||||
$toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/usersroles.php?userid='.$user->id.'&courseid='.$course->id
|
||||
,get_string('roles'));
|
||||
|
||||
if (in_array($currenttab, array('usersroles', 'assign', 'override', 'check'))) {
|
||||
if (in_array($currenttab, array('usersroles', 'assign', 'permissions', 'check'))) {
|
||||
$inactive = array('roles');
|
||||
$activetwo = array('roles');
|
||||
|
||||
@@ -233,12 +233,12 @@
|
||||
$secondrow[] = new tabobject('assign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id
|
||||
,get_string('assignrolesrelativetothisuser', 'role'), '', true);
|
||||
}
|
||||
if (!empty($overridableroles) || $currenttab=='override') {
|
||||
$secondrow[] = new tabobject('override', $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id
|
||||
,get_string('overridepermissions', 'role'), '', true);
|
||||
if (!empty($overridableroles) || $currenttab=='permissions' || has_capability('moodle/role:review', $usercontext)) {
|
||||
$secondrow[] = new tabobject('permissions', $CFG->wwwroot.'/'.$CFG->admin.'/roles/permissions.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id
|
||||
,get_string('permissions', 'role'), '', true);
|
||||
}
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
|
||||
'moodle/role:override', 'moodle/role:assign'), $usercontext)) {
|
||||
'moodle/role:override', 'moodle/role:assign', 'moodle/role:review'), $usercontext)) {
|
||||
$secondrow[] = new tabobject('check',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/check.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id,
|
||||
get_string('checkpermissions', 'role'));
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2010021900; // YYYYMMDD = date of the last version bump
|
||||
$version = 2010021901; // YYYYMMDD = date of the last version bump
|
||||
// XX = daily increments
|
||||
|
||||
$release = '2.0 dev (Build: 20100307)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user