mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-34270 blocks: perform My Moodle addinstance capability check first
This commit is contained in:
parent
70c9c1956d
commit
464e00be28
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user