MDL-34270 blocks: perform My Moodle addinstance capability check first
authorMark Nelson <markn@moodle.com>
Tue, 6 Nov 2012 06:56:47 +0000 (14:56 +0800)
committerMark Nelson <markn@moodle.com>
Tue, 6 Nov 2012 06:56:47 +0000 (14:56 +0800)
blocks/moodleblock.class.php

index c7ef937..b1a6bf7 100644 (file)
@@ -558,12 +558,6 @@ class block_base {
     function user_can_addto($page) {
         global $USER;
 
-        $capability = 'block/' . $this->name() . ':addinstance';
-        if ($this->has_add_block_capability($page, $capability)
-                && has_capability('moodle/block:edit', $page->context)) {
-            return true;
-        }
-
         // The blocks in My Moodle are a special case and use a different capability.
         if (!empty($USER->id)
             && $page->context->contextlevel == CONTEXT_USER // Page belongs to a user
@@ -573,6 +567,12 @@ class block_base {
                     && has_capability('moodle/my:manageblocks', $page->context);
         }
 
+        $capability = 'block/' . $this->name() . ':addinstance';
+        if ($this->has_add_block_capability($page, $capability)
+                && has_capability('moodle/block:edit', $page->context)) {
+            return true;
+        }
+
         return false;
     }