Skip to content

Commit

Permalink
MDL-50663 blocks: Fix /my/ page when in non-user context
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-unikent committed Jun 29, 2015
1 parent 38cb73a commit 56af0fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public function load_blocks($includeinvisible = null) {
}

$context = $this->page->context;
$contexttest = 'bi.parentcontextid = :contextid2';
$contexttest = 'bi.parentcontextid IN (:contextid2, :contextid3)';
$parentcontextparams = array();
$parentcontextids = $context->get_parent_context_ids();
if ($parentcontextids) {
Expand All @@ -594,12 +594,14 @@ public function load_blocks($includeinvisible = null) {
$ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
$ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = bi.id AND ctx.contextlevel = :contextlevel)";

$systemcontext = \context_system::instance();
$params = array(
'contextlevel' => CONTEXT_BLOCK,
'subpage1' => $this->page->subpage,
'subpage2' => $this->page->subpage,
'contextid1' => $context->id,
'contextid2' => $context->id,
'contextid3' => $systemcontext->id,
'pagetype' => $this->page->pagetype,
);
if ($this->page->subpage === '') {
Expand Down
5 changes: 2 additions & 3 deletions my/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -104,11 +103,11 @@
}

// Toggle the editing state and switches
if ($PAGE->user_allowed_editing()) {
if (!$CFG->forcedefaultmymoodle && $PAGE->user_allowed_editing()) {
if ($reset !== null) {
if (!is_null($userid)) {
require_sesskey();
if(!$currentpage = my_reset_page($userid, MY_PAGE_PRIVATE)){
if (!$currentpage = my_reset_page($userid, MY_PAGE_PRIVATE)) {
print_error('reseterror', 'my');
}
redirect(new moodle_url('/my'));
Expand Down
2 changes: 1 addition & 1 deletion my/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function my_get_page($userid, $private=MY_PAGE_PRIVATE) {
function my_copy_page($userid, $private=MY_PAGE_PRIVATE, $pagetype='my-index') {
global $DB;

if ($customised = $DB->record_exists('my_pages', array('userid' => $userid, 'private' => $private))) {
if ($customised = $DB->get_record('my_pages', array('userid' => $userid, 'private' => $private))) {
return $customised; // We're done!
}

Expand Down

0 comments on commit 56af0fb

Please sign in to comment.