Permalink
Browse files

MDL-9802 added my:manageblocks capability so admins can define whethe…

…r users can add/remove blocks from myMoodle page
  • Loading branch information...
1 parent 54617ab commit 3ba9c859b6bca51e1811df0c54ffe2e48984f814 jmg324 committed May 18, 2007
Showing with 33 additions and 4 deletions.
  1. +1 −0 lang/en_utf8/role.php
  2. +8 −1 lib/blocklib.php
  3. +9 −0 lib/db/access.php
  4. +12 −0 lib/db/upgrade.php
  5. +2 −2 my/pagelib.php
  6. +1 −1 version.php
View
@@ -72,6 +72,7 @@
$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';
View
@@ -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);
}
}
View
@@ -890,7 +890,16 @@
'legacy' => array(
'admin' => CAP_ALLOW
)
+ ),
+
+ 'moodle/my:manageblocks' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_SYSTEM,
+ 'legacy' => array(
+ 'user' => CAP_ALLOW
+ )
)
+
);
?>
View
@@ -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;
}
View
@@ -12,15 +12,15 @@ function user_allowed_editing() {
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));
View
@@ -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

0 comments on commit 3ba9c85

Please sign in to comment.