]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9802 added my:manageblocks capability so admins can define whether users can...
authorjmg324 <jmg324>
Fri, 18 May 2007 11:57:46 +0000 (11:57 +0000)
committerjmg324 <jmg324>
Fri, 18 May 2007 11:57:46 +0000 (11:57 +0000)
lang/en_utf8/role.php
lib/blocklib.php
lib/db/access.php
lib/db/upgrade.php
my/pagelib.php
version.php

index d812005053abd4f0c1d2023fa228b0ad06a347e8..d470f127395449ddc0fcfa654e52b7e61cb77b11 100644 (file)
@@ -79,6 +79,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';
index e4501c1803ee113d767b62007f531ee582fedb91..ca39d05de10274bf74e2e8e5fdca3b2a2170dc16 100644 (file)
@@ -336,7 +336,14 @@ function blocks_print_group(&$page, &$pageblocks, $position) {
     } // 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);
     }
 }
index 77c29cc72afb34fcbe16d10c130ce793e2f9227b..adb71d1c118bd8c66e66d1a0e35243be8c543132 100644 (file)
@@ -1003,7 +1003,16 @@ $moodle_capabilities = array(
             'editingteacher' => CAP_ALLOW,
             'admin' => CAP_ALLOW
         )
-    )    
+    ),
+    
+        'moodle/my:manageblocks' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'user' => CAP_ALLOW
+        )
+    )
+        
 );
 
 ?>
index f25f5b350952aef0946128c876b59e8161a45920..adeeef7a89ac435e4d5c98ffd263f9e4883a583d 100644 (file)
@@ -1280,6 +1280,18 @@ function xmldb_main_upgrade($oldversion=0) {
         }
     }
 
+    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; 
 }
 
index a126458a07e5580d548008c77d069992ec249a60..b003bf62d2eef0f8d2f9fa8915a6af12b4aaac38 100644 (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));
index ec0eff3525908bc0c8da773229d04100f0ac1fe0..3bb8451a5b5ce51d841542549bdfb8ab0838ee15 100644 (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 = 2007051101;  // YYYYMMDD = date
+   $version = 2007051801;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.9 dev';    // Human-friendly version name