mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
community block MDL-24011 fix two context related issues with community block
This commit is contained in:
parent
d7ba102bcf
commit
e6c2edbf7c
1 changed files with 20 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
|||
<?PHP
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
@ -31,7 +32,8 @@ class block_community extends block_list {
|
|||
|
||||
function user_can_addto($page) {
|
||||
// Don't allow people to add the block if they can't even use it
|
||||
if (!has_capability('moodle/community:add', get_context_instance(CONTEXT_SYSTEM))) { // Should be page context?
|
||||
if (!has_capability('moodle/community:add',
|
||||
get_context_instance(CONTEXT_COURSE, $this->page->course->id))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -40,7 +42,8 @@ class block_community extends block_list {
|
|||
|
||||
function user_can_edit() {
|
||||
// Don't allow people to edit the block if they can't even use it
|
||||
if (!has_capability('moodle/community:add', get_context_instance(CONTEXT_SYSTEM))) { // Should be page context?
|
||||
if (!has_capability('moodle/community:add',
|
||||
get_context_instance(CONTEXT_COURSE, $this->page->course->id))) {
|
||||
return false;
|
||||
}
|
||||
return parent::user_can_edit();
|
||||
|
@ -49,7 +52,8 @@ class block_community extends block_list {
|
|||
function get_content() {
|
||||
global $CFG, $OUTPUT, $USER;
|
||||
|
||||
if (!has_capability('moodle/community:add', get_context_instance(CONTEXT_SYSTEM)) // Should be page context?
|
||||
if (!has_capability('moodle/community:add',
|
||||
get_context_instance(CONTEXT_COURSE, $this->page->course->id))
|
||||
or $this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
@ -85,7 +89,9 @@ class block_community extends block_list {
|
|||
array('src' => $OUTPUT->pix_url('i/cross_red_small'),
|
||||
'alt' => get_string('removecommunitycourse', 'block_community')));
|
||||
$deleteurl = new moodle_url('/blocks/community/communitycourse.php',
|
||||
array('remove'=>true, 'communityid'=> $course->id, 'sesskey' => sesskey()));
|
||||
array('remove' => true,
|
||||
'courseid' => $this->page->course->id,
|
||||
'communityid' => $course->id, 'sesskey' => sesskey()));
|
||||
$deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl));
|
||||
|
||||
$courselink = html_writer::tag('a', $course->coursename,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue