diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php index 851f1210c5f..b5466b9fb19 100644 --- a/lang/en_utf8/role.php +++ b/lang/en_utf8/role.php @@ -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'; diff --git a/lib/blocklib.php b/lib/blocklib.php index 5398c57dd67..6f83d6656b0 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -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); } } diff --git a/lib/db/access.php b/lib/db/access.php index fb2284bae9c..8ac54e44546 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -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 + ) ) + ); ?> diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 6aa522c6868..c4aa7d95cf1 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/my/pagelib.php b/my/pagelib.php index a126458a07e..b003bf62d2e 100644 --- a/my/pagelib.php +++ b/my/pagelib.php @@ -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)); diff --git a/version.php b/version.php index a6adaf75c95..4e7849fed77 100644 --- a/version.php +++ b/version.php @@ -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