mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-11814 use system context for pinned blocks; merged from MOODLE_19_STABLE
This commit is contained in:
parent
baae1acfef
commit
5c10879f55
4 changed files with 41 additions and 10 deletions
|
@ -84,6 +84,10 @@ class block_base {
|
|||
|
||||
var $cron = NULL;
|
||||
|
||||
/**
|
||||
* Indicates blocked is pinned - can not be moved, always present, does not have own context
|
||||
*/
|
||||
var $pinned = false;
|
||||
|
||||
/// Class Functions
|
||||
|
||||
|
@ -266,7 +270,11 @@ class block_base {
|
|||
*/
|
||||
function is_empty() {
|
||||
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
|
||||
if ( !has_capability('moodle/block:view', $context) ) {
|
||||
return true;
|
||||
|
@ -366,8 +374,11 @@ class block_base {
|
|||
function _add_edit_controls($options) {
|
||||
global $CFG, $USER, $PAGE;
|
||||
|
||||
// this is the context relevant to this particular block instance
|
||||
$blockcontext = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
|
||||
// context for site or course, i.e. participant list etc
|
||||
// check to see if user can edit site or course blocks.
|
||||
|
@ -375,7 +386,7 @@ class block_base {
|
|||
|
||||
switch ($this->instance->pagetype) {
|
||||
case 'course-view':
|
||||
if (!has_capability('moodle/site:manageblocks', $blockcontext)) {
|
||||
if (!has_capability('moodle/site:manageblocks', $context)) {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
|
@ -427,7 +438,7 @@ class block_base {
|
|||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey));
|
||||
|
||||
if (empty($this->instance->pinned)) {
|
||||
$movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$blockcontext->id.'">' .
|
||||
$movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.'">' .
|
||||
'<img src="'.$CFG->pixpath.'/i/roles.gif" alt="'.$this->str->assignroles.'" /></a>';
|
||||
}
|
||||
|
||||
|
@ -756,7 +767,11 @@ class block_list extends block_base {
|
|||
|
||||
function is_empty() {
|
||||
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
|
||||
if ( !has_capability('moodle/block:view', $context) ) {
|
||||
return true;
|
||||
|
|
|
@ -96,7 +96,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
|
||||
if (has_capability('block/rss_client:createsharedfeeds', $context)
|
||||
|| has_capability('block/rss_client:createprivatefeeds', $context)) {
|
||||
|
|
|
@ -93,7 +93,11 @@ print_box_start();
|
|||
print $checkbox . $feedtitle .'<br />'."\n";
|
||||
}
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
print_string('nofeeds', 'block_rss_client');
|
||||
|
||||
if (has_capability('block/rss_client:createprivatefeeds', $context)
|
||||
|
@ -169,7 +173,11 @@ print_box_start();
|
|||
} else {
|
||||
global $act, $url, $rssid, $preferredtitle, $shared;
|
||||
print '</div></form></div>'; // Closes off page form
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
|
||||
print_box_start();
|
||||
rss_display_feeds($id, $USER->id, '', $context);
|
||||
|
|
|
@ -6,7 +6,11 @@ global $USER;
|
|||
$tabs = $row = array();
|
||||
|
||||
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
if (empty($this->instance->pinned)) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:manageblocks', $context)) {
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id, 'section' => 'rss'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue