Skip to content

Commit

Permalink
MDL-68974 blocks: Check permission before generating content
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored and Jenkins committed Sep 8, 2020
1 parent cb72d84 commit 5c91f31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions calendar/lib.php
Expand Up @@ -1281,6 +1281,9 @@ public function timestamp_tomorrow() {
* @param string|null $view preference view options (eg: day, month, upcoming)
*/
public function add_sidecalendar_blocks(core_calendar_renderer $renderer, $showfilters=false, $view=null) {
if (!has_capability('moodle/block:view', $this->context) ) {
return;
}
if ($showfilters) {
$filters = new block_contents();
$filters->content = $renderer->event_filter();
Expand Down
6 changes: 6 additions & 0 deletions lib/blocklib.php
Expand Up @@ -1225,6 +1225,12 @@ protected function ensure_instances_exist($region) {
*/
public function ensure_content_created($region, $output) {
$this->ensure_instances_exist($region);

if (!has_capability('moodle/block:view', $this->page->context) ) {
$this->visibleblockcontent[$region] = [];
return;
}

if (!array_key_exists($region, $this->visibleblockcontent)) {
$contents = array();
if (array_key_exists($region, $this->extracontent)) {
Expand Down

0 comments on commit 5c91f31

Please sign in to comment.