MDL-9802 added my:manageblocks capability so admins can define whether users can add/remove blocks from myMoodle page

This commit is contained in:
jmg324
2007-05-18 12:47:19 +00:00
parent 54617ab56b
commit 3ba9c859b6
6 changed files with 33 additions and 4 deletions
+1
View File
@@ -72,6 +72,7 @@ $string['listallroles'] = 'List all roles';
$string['manageroles'] = 'Manage roles';
$string['metaassignerror'] = 'Can not assign this role to user \"$a\" because Manage metacourse capability is needed.';
$string['metaunassignerror'] = 'Role of user \"$a\" was automatically reassigned, please unassign the role in child courses instead.';
$string['my:manageblocks'] = 'Manage myMoodle page blocks';
$string['nocapabilitiesincontext'] = 'No capabilities available in this context';
$string['notset'] = 'Not set';
$string['overrideroles'] = 'Override roles';
+8 -1
View File
@@ -337,7 +337,14 @@ function blocks_print_group(&$page, &$pageblocks, $position) {
} // End foreach
if ($page->blocks_default_position() == $position && $page->user_is_editing()) {
// Check if
// we are on the default position/side AND
// we're editing the page AND
// (
// we have the capability to manage blocks OR
// we are in myMoodle page AND have the capibility to manage myMoodle blocks
// )
if ($page->blocks_default_position() == $position && $page->user_is_editing() && (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_COURSE, $COURSE->id)) || ($page->type == PAGE_MY_MOODLE && has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_COURSE, $COURSE->id)))) ) {
blocks_print_adminblock($page, $pageblocks);
}
}
+9
View File
@@ -890,7 +890,16 @@ $moodle_capabilities = array(
'legacy' => array(
'admin' => CAP_ALLOW
)
),
'moodle/my:manageblocks' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'user' => CAP_ALLOW
)
)
);
?>
+12
View File
@@ -680,6 +680,18 @@ function xmldb_main_upgrade($oldversion=0) {
}
}
if ($result && $oldversion < 2007021505) {
// Get the role id of the "Auth. User" role and check if the default role id is different
$userrole = get_record( 'role', 'shortname', 'user' );
$defaultroleid = $CFG->defaultuserroleid;
if( $defaultroleid != $userrole->id ) {
// Add in the new moodle/my:manageblocks capibility to the default user role
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
assign_capability('moodle/my:manageblocks',CAP_ALLOW,$defaultroleid,$context->id);
}
}
return $result;
}
+2 -2
View File
@@ -12,7 +12,7 @@ class page_my_moodle extends page_base {
page_id_and_class($id,$class);
if ($id == PAGE_MY_MOODLE) {
return true;
} else if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
} else if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
return true;
}
return false;
@@ -20,7 +20,7 @@ class page_my_moodle extends page_base {
function user_is_editing() {
global $USER;
if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
return true;
}
return (!empty($USER->editing));
+1 -1
View File
@@ -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 = 2007021504; // YYYYMMDD = date of the 1.8 branch (don't change)
$version = 2007021505; // YYYYMMDD = date of the 1.8 branch (don't change)
// X = release number 1.8.[0,1,2,3...]
// Y = micro-increments between releases