$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';
} // End foreach
- if ($page->blocks_default_position() == $position && $page->user_is_editing() && has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
+ // 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);
}
}
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
- )
+ ),
+
+ 'moodle/my:manageblocks' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_SYSTEM,
+ 'legacy' => array(
+ 'user' => CAP_ALLOW
+ )
+ )
+
);
?>
}
}
+ if ($result && $oldversion < 2007051801) {
+ // 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;
}
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;
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));
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007051101; // YYYYMMDD = date
+ $version = 2007051801; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 dev'; // Human-friendly version name