MDL-50330 blog: Fixed fatal error accessing blogs.

This commit is contained in:
Adrian Greeve
2015-05-22 15:34:09 +08:00
parent b5dbb126f9
commit 0c7131622d
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -76,7 +76,9 @@ $sitecontext = context_system::instance();
if (isset($userid) && $USER->id == $userid) {
$blognode = $PAGE->navigation->find('siteblog', null);
$blognode->make_inactive();
if ($blognode) {
$blognode->make_inactive();
}
}
// Check basic permissions.
+5
View File
@@ -1023,12 +1023,17 @@ function blog_page_type_list($pagetype, $parentcontext, $currentcontext) {
* @return bool
*/
function core_blog_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
global $CFG;
if (!blog_is_enabled_for_user() || isguestuser($user)) {
// The guest user cannot post, so it is not possible to view any posts.
// Also blogs might be disabled.
// May as well just bail aggressively here.
return true;
}
if ($CFG->bloglevel == BLOG_USER_LEVEL && !$iscurrentuser) {
// Blogs are only viewable by the owner.
return true;
}
$url = new moodle_url("/blog/index.php", array('userid' => $user->id));
if (!empty($course)) {
$url->param('courseid', $course->id);