MDL-34270 blocks: perform My Moodle addinstance capability check first

This commit is contained in:
Mark Nelson 2012-11-06 14:56:47 +08:00
parent 70c9c1956d
commit 464e00be28

View 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;
}