MDL-46346 blog: coding style fixes

This commit is contained in:
Andrew Davis 2014-07-13 18:43:09 +08:00
parent e9fb99b15c
commit 2b6e53e8e2
13 changed files with 340 additions and 276 deletions

View file

@ -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
@ -26,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
/**
/*
* Library of functions and constants for blog
*/
require_once($CFG->dirroot .'/blog/rsslib.php');
@ -45,11 +44,11 @@ function blog_user_can_edit_entry($blogentry) {
$sitecontext = context_system::instance();
if (has_capability('moodle/blog:manageentries', $sitecontext)) {
return true; // can edit any blog entry
return true; // Can edit any blog entry.
}
if ($blogentry->userid == $USER->id && has_capability('moodle/blog:create', $sitecontext)) {
return true; // can edit own when having blog:create capability
return true; // Can edit own when having blog:create capability.
}
return false;
@ -168,12 +167,12 @@ function blog_sync_external_entries($externalblog) {
if (empty($rss->data)) {
return null;
}
//used to identify blog posts that have been deleted from the source feed
// Used to identify blog posts that have been deleted from the source feed.
$oldesttimestamp = null;
$uniquehashes = array();
foreach ($rss->get_items() as $entry) {
// If filtertags are defined, use them to filter the entries by RSS category
// If filtertags are defined, use them to filter the entries by RSS category.
if (!empty($externalblog->filtertags)) {
$containsfiltertag = false;
$categories = $entry->get_categories();
@ -201,26 +200,26 @@ function blog_sync_external_entries($externalblog) {
$newentry->uniquehash = $entry->get_permalink();
$newentry->publishstate = 'site';
$newentry->format = FORMAT_HTML;
// Clean subject of html, just in case
// Clean subject of html, just in case.
$newentry->subject = clean_param($entry->get_title(), PARAM_TEXT);
// Observe 128 max chars in DB
// TODO: +1 to raise this to 255
// Observe 128 max chars in DB.
// TODO: +1 to raise this to 255.
if (core_text::strlen($newentry->subject) > 128) {
$newentry->subject = core_text::substr($newentry->subject, 0, 125) . '...';
}
$newentry->summary = $entry->get_description();
//used to decide whether to insert or update
//uses enty permalink plus creation date if available
// Used to decide whether to insert or update.
// Uses enty permalink plus creation date if available.
$existingpostconditions = array('uniquehash' => $entry->get_permalink());
//our DB doesnt allow null creation or modified timestamps so check the external blog supplied one
// Our DB doesnt allow null creation or modified timestamps so check the external blog supplied one.
$entrydate = $entry->get_date('U');
if (!empty($entrydate)) {
$existingpostconditions['created'] = $entrydate;
}
//the post ID or false if post not found in DB
// The post ID or false if post not found in DB.
$postid = $DB->get_field('post', 'id', $existingpostconditions);
$timestamp = null;
@ -230,14 +229,14 @@ function blog_sync_external_entries($externalblog) {
$timestamp = $entrydate;
}
//only set created if its a new post so we retain the original creation timestamp if the post is edited
// Only set created if its a new post so we retain the original creation timestamp if the post is edited.
if ($postid === false) {
$newentry->created = $timestamp;
}
$newentry->lastmodified = $timestamp;
if (empty($oldesttimestamp) || $timestamp < $oldesttimestamp) {
//found an older post
// Found an older post.
$oldesttimestamp = $timestamp;
}
@ -252,7 +251,7 @@ function blog_sync_external_entries($externalblog) {
if ($postid === false) {
$id = $DB->insert_record('post', $newentry);
// Set tags
// Set tags.
if ($tags = tag_get_tags_array('blog_external', $externalblog->id)) {
tag_set('post', $id, $tags, 'core', context_user::instance($externalblog->userid)->id);
}
@ -273,7 +272,7 @@ function blog_sync_external_entries($externalblog) {
$dbposts = $DB->get_records_sql($sql, array('blogid' => $externalblog->id, 'ts' => $oldesttimestamp));
$todelete = array();
foreach($dbposts as $dbpost) {
foreach ($dbposts as $dbpost) {
if ( !in_array($dbpost->uniquehash, $uniquehashes) ) {
$todelete[] = $dbpost->id;
}
@ -324,13 +323,13 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
$options = array();
// If blogs are enabled and the user is logged in and not a guest
// If blogs are enabled and the user is logged in and not a guest.
if (blog_is_enabled_for_user()) {
// If the context is the user then assume we want to load for the users context
// If the context is the user then assume we want to load for the users context.
if (is_null($userid) && $page->context->contextlevel == CONTEXT_USER) {
$userid = $page->context->instanceid;
}
// Check the userid var
// Check the userid var.
if (!is_null($userid) && $userid!==$USER->id) {
// Load the user from the userid... it MUST EXIST throw a wobbly if it doesn't!
$user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
@ -339,33 +338,36 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
}
if ($CFG->useblogassociations && $page->cm !== null) {
// Load for the module associated with the page
// Load for the module associated with the page.
$options[CONTEXT_MODULE] = blog_get_options_for_module($page->cm, $user);
} else if ($CFG->useblogassociations && $page->course->id != SITEID) {
// Load the options for the course associated with the page
// Load the options for the course associated with the page.
$options[CONTEXT_COURSE] = blog_get_options_for_course($page->course, $user);
}
// Get the options for the user
// Get the options for the user.
if ($user !== null and !isguestuser($user)) {
// Load for the requested user
// Load for the requested user.
$options[CONTEXT_USER+1] = blog_get_options_for_user($user);
}
// Load for the current user
// Load for the current user.
if (isloggedin() and !isguestuser()) {
$options[CONTEXT_USER] = blog_get_options_for_user();
}
}
// If blog level is global then display a link to view all site entries
if (!empty($CFG->enableblogs) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', context_system::instance())) {
// If blog level is global then display a link to view all site entries.
if (!empty($CFG->enableblogs)
&& $CFG->bloglevel >= BLOG_GLOBAL_LEVEL
&& has_capability('moodle/blog:view', context_system::instance())) {
$options[CONTEXT_SYSTEM] = array('viewsite' => array(
'string' => get_string('viewsiteentries', 'blog'),
'link' => new moodle_url('/blog/index.php')
));
}
// Return the options
// Return the options.
return $options;
}
@ -380,16 +382,16 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
*/
function blog_get_options_for_user(stdClass $user=null) {
global $CFG, $USER;
// Cache
// Cache.
static $useroptions = array();
$options = array();
// Blogs must be enabled and the user must be logged in
// Blogs must be enabled and the user must be logged in.
if (!blog_is_enabled_for_user()) {
return $options;
}
// Sort out the user var
// Sort out the user var.
if ($user === null || $user->id == $USER->id) {
$user = $USER;
$iscurrentuser = true;
@ -397,7 +399,7 @@ function blog_get_options_for_user(stdClass $user=null) {
$iscurrentuser = false;
}
// If we've already generated serve from the cache
// If we've already generated serve from the cache.
if (array_key_exists($user->id, $useroptions)) {
return $useroptions[$user->id];
}
@ -406,22 +408,22 @@ function blog_get_options_for_user(stdClass $user=null) {
$canview = has_capability('moodle/blog:view', $sitecontext);
if (!$iscurrentuser && $canview && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
// Not the current user, but we can view and its blogs are enabled for SITE or GLOBAL
// Not the current user, but we can view and its blogs are enabled for SITE or GLOBAL.
$options['userentries'] = array(
'string' => get_string('viewuserentries', 'blog', fullname($user)),
'link' => new moodle_url('/blog/index.php', array('userid'=>$user->id))
);
} else {
// It's the current user
// It's the current user.
if ($canview) {
// We can view our own blogs .... BIG surprise
// We can view our own blogs .... BIG surprise.
$options['view'] = array(
'string' => get_string('viewallmyentries', 'blog'),
'link' => new moodle_url('/blog/index.php', array('userid'=>$USER->id))
);
}
if (has_capability('moodle/blog:create', $sitecontext)) {
// We can add to our own blog
// We can add to our own blog.
$options['add'] = array(
'string' => get_string('addnewentry', 'blog'),
'link' => new moodle_url('/blog/edit.php', array('action'=>'add'))
@ -432,12 +434,12 @@ function blog_get_options_for_user(stdClass $user=null) {
$options['rss'] = array(
'string' => get_string('rssfeed', 'blog'),
'link' => new moodle_url(rss_get_url($sitecontext->id, $USER->id, 'blog', 'user/'.$user->id))
);
);
}
// Cache the options
// Cache the options.
$useroptions[$user->id] = $options;
// Return the options
// Return the options.
return $options;
}
@ -451,47 +453,46 @@ function blog_get_options_for_user(stdClass $user=null) {
*/
function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
global $CFG, $USER;
// Cache
// Cache.
static $courseoptions = array();
$options = array();
// User must be logged in and blogs must be enabled
// User must be logged in and blogs must be enabled.
if (!blog_is_enabled_for_user()) {
return $options;
}
// Check that the user can associate with the course
// Check that the user can associate with the course.
$sitecontext = context_system::instance();
// Generate the cache key
// Generate the cache key.
$key = $course->id.':';
if (!empty($user)) {
$key .= $user->id;
} else {
$key .= $USER->id;
}
// Serve from the cache if we've already generated for this course
// Serve from the cache if we've already generated for this course.
if (array_key_exists($key, $courseoptions)) {
return $courseoptions[$key];
}
if (has_capability('moodle/blog:view', $sitecontext)) {
// We can view!
if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
// View entries about this course
// View entries about this course.
$options['courseview'] = array(
'string' => get_string('viewcourseblogs', 'blog'),
'link' => new moodle_url('/blog/index.php', array('courseid' => $course->id))
);
}
// View MY entries about this course
// View MY entries about this course.
$options['courseviewmine'] = array(
'string' => get_string('viewmyentriesaboutcourse', 'blog'),
'link' => new moodle_url('/blog/index.php', array('courseid' => $course->id, 'userid' => $USER->id))
);
if (!empty($user) && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
// View the provided users entries about this course
// View the provided users entries about this course.
$options['courseviewuser'] = array(
'string' => get_string('viewentriesbyuseraboutcourse', 'blog', fullname($user)),
'link' => new moodle_url('/blog/index.php', array('courseid' => $course->id, 'userid' => $user->id))
@ -500,17 +501,16 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
}
if (has_capability('moodle/blog:create', $sitecontext)) {
// We can blog about this course
// We can blog about this course.
$options['courseadd'] = array(
'string' => get_string('blogaboutthiscourse', 'blog'),
'link' => new moodle_url('/blog/edit.php', array('action' => 'add', 'courseid' => $course->id))
);
}
// Cache the options for this course
// Cache the options for this course.
$courseoptions[$key] = $options;
// Return the options
// Return the options.
return $options;
}
@ -524,18 +524,18 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
*/
function blog_get_options_for_module($module, $user=null) {
global $CFG, $USER;
// Cache
// Cache.
static $moduleoptions = array();
$options = array();
// User must be logged in, blogs must be enabled
// User must be logged in, blogs must be enabled.
if (!blog_is_enabled_for_user()) {
return $options;
}
$sitecontext = context_system::instance();
// Generate the cache key
// Generate the cache key.
$key = $module->id.':';
if (!empty($user)) {
$key .= $user->id;
@ -543,18 +543,17 @@ function blog_get_options_for_module($module, $user=null) {
$key .= $USER->id;
}
if (array_key_exists($key, $moduleoptions)) {
// Serve from the cache so we don't have to regenerate
// Serve from the cache so we don't have to regenerate.
return $moduleoptions[$key];
}
if (has_capability('moodle/blog:view', $sitecontext)) {
// Save correct module name for later usage.
$modulename = get_string('modulename', $module->modname);
// We can view!
if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
// View all entries about this module
// View all entries about this module.
$a = new stdClass;
$a->type = $modulename;
$options['moduleview'] = array(
@ -562,13 +561,13 @@ function blog_get_options_for_module($module, $user=null) {
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id))
);
}
// View MY entries about this module
// View MY entries about this module.
$options['moduleviewmine'] = array(
'string' => get_string('viewmyentriesaboutmodule', 'blog', $modulename),
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id, 'userid'=>$USER->id))
);
if (!empty($user) && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
// View the given users entries about this module
// View the given users entries about this module.
$a = new stdClass;
$a->mod = $modulename;
$a->user = fullname($user);
@ -580,15 +579,15 @@ function blog_get_options_for_module($module, $user=null) {
}
if (has_capability('moodle/blog:create', $sitecontext)) {
// The user can blog about this module
// The user can blog about this module.
$options['moduleadd'] = array(
'string' => get_string('blogaboutthismodule', 'blog', $modulename),
'link' => new moodle_url('/blog/edit.php', array('action'=>'add', 'modid'=>$module->id))
);
}
// Cache the options
// Cache the options.
$moduleoptions[$key] = $options;
// Return the options
// Return the options.
return $options;
}
@ -626,7 +625,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$action = optional_param('action', null, PARAM_ALPHA);
$confirm = optional_param('confirm', false, PARAM_BOOL);
// Ignore userid when action == add
// Ignore userid when action == add.
if ($action == 'add' && $userid) {
unset($userid);
$PAGE->url->remove_params(array('userid'));
@ -644,11 +643,11 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$site = $DB->get_record('course', array('id' => SITEID));
$sitecontext = context_system::instance();
// Common Lang strings
// Common Lang strings.
$strparticipants = get_string("participants");
$strblogentries = get_string("blogentries", 'blog');
// Prepare record objects as needed
// Prepare record objects as needed.
if (!empty($courseid)) {
$headers['filters']['course'] = $courseid;
$course = $DB->get_record('course', array('id' => $courseid));
@ -659,7 +658,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$user = $DB->get_record('user', array('id' => $userid));
}
if (!empty($groupid)) { // groupid always overrides courseid
if (!empty($groupid)) { // The groupid always overrides courseid.
$headers['filters']['group'] = $groupid;
$group = $DB->get_record('groups', array('id' => $groupid));
$course = $DB->get_record('course', array('id' => $group->courseid));
@ -667,11 +666,11 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->set_pagelayout('standard');
// modid always overrides courseid, so the $course object may be reset here
// The modid always overrides courseid, so the $course object may be reset here.
if (!empty($modid) && $CFG->useblogassociations) {
$headers['filters']['module'] = $modid;
// A groupid param may conflict with this coursemod's courseid. Ignore groupid in that case
// A groupid param may conflict with this coursemod's courseid. Ignore groupid in that case.
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$modid));
$course = $DB->get_record('course', array('id' => $courseid));
$cm = $DB->get_record('course_modules', array('id' => $modid));
@ -685,17 +684,16 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
}
// Case 1: No entry, mod, course or user params: all site entries to be shown (filtered by search and tag/tagid)
// Note: if action is set to 'add' or 'edit', we do this at the end
// Note: if action is set to 'add' or 'edit', we do this at the end.
if (empty($entryid) && empty($modid) && empty($courseid) && empty($userid) && !in_array($action, array('edit', 'add'))) {
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
// $headers['strview'] = get_string('viewsiteentries', 'blog');
}
// Case 2: only entryid is requested, ignore all other filters. courseid is used to give more contextual information
// Case 2: only entryid is requested, ignore all other filters. courseid is used to give more contextual information.
if (!empty($entryid)) {
$headers['filters']['entry'] = $entryid;
$sql = 'SELECT u.* FROM {user} u, {post} p WHERE p.id = ? AND p.userid = u.id';
@ -720,15 +718,16 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->set_heading("$shortname: " . fullname($user) . ": $entry->subject");
$headers['heading'] = get_string('blogentrybyuser', 'blog', fullname($user));
// We ignore tag and search params
// We ignore tag and search params.
if (empty($action) || !$CFG->useblogassociations) {
$headers['url'] = $blogurl;
return $headers;
}
}
// Case 3: A user's blog entries
if (!empty($userid) && empty($entryid) && ((empty($courseid) && empty($modid)) || !$CFG->useblogassociations)) {
// Case 3: A user's blog entries.
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$blogurl->param('userid', $userid);
$PAGE->set_title("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
@ -736,23 +735,21 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$headers['heading'] = get_string('userblog', 'blog', fullname($user));
$headers['strview'] = get_string('viewuserentries', 'blog', fullname($user));
} else
} else if (!$CFG->useblogassociations && empty($userid) && !in_array($action, array('edit', 'add'))) {
// Case 4: No blog associations, no userid.
// Case 4: No blog associations, no userid
if (!$CFG->useblogassociations && empty($userid) && !in_array($action, array('edit', 'add'))) {
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
} else
} else if (!empty($userid) && !empty($modid) && empty($entryid)) {
// Case 5: Blog entries associated with an activity by a specific user (courseid ignored).
// Case 5: Blog entries associated with an activity by a specific user (courseid ignored)
if (!empty($userid) && !empty($modid) && empty($entryid)) {
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$blogurl->param('userid', $userid);
$blogurl->param('modid', $modid);
// Course module navigation is handled by build_navigation as the second param
// Course module navigation is handled by build_navigation as the second param.
$headers['cm'] = $cm;
$PAGE->navbar->add(fullname($user), "$CFG->wwwroot/user/view.php?id=$user->id");
$PAGE->navbar->add($strblogentries, $blogurl);
@ -767,10 +764,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$headers['heading'] = get_string('blogentriesbyuseraboutmodule', 'blog', $a);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewallmodentries', 'blog', $a);
} else
} else if (!empty($userid) && !empty($courseid) && empty($modid) && empty($entryid)) {
// Case 6: Blog entries associated with a course by a specific user.
// Case 6: Blog entries associated with a course by a specific user
if (!empty($userid) && !empty($courseid) && empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$blogurl->param('userid', $userid);
@ -789,12 +785,11 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewblogentries', 'blog', $a);
// Remove the userid from the URL to inform the blog_menu block correctly
// Remove the userid from the URL to inform the blog_menu block correctly.
$blogurl->remove_params(array('userid'));
} else
} else if (!empty($groupid) && empty($modid) && empty($entryid)) {
// Case 7: Blog entries by members of a group, associated with that group's course.
// Case 7: Blog entries by members of a group, associated with that group's course
if (!empty($groupid) && empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$blogurl->param('courseid', $course->id);
@ -814,10 +809,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$headers['heading'] = get_string('blogentriesbygroupaboutcourse', 'blog', $a);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewblogentries', 'blog', $a);
} else
} else if (!empty($groupid) && !empty($modid) && empty($entryid)) {
// Case 8: Blog entries by members of a group, associated with an activity in that course.
// Case 8: Blog entries by members of a group, associated with an activity in that course
if (!empty($groupid) && !empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$headers['cm'] = $cm;
@ -838,10 +832,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewallmodentries', 'blog', $a);
} else
} else if (!empty($modid) && empty($userid) && empty($groupid) && empty($entryid)) {
// Case 9: All blog entries associated with an activity.
// Case 9: All blog entries associated with an activity
if (!empty($modid) && empty($userid) && empty($groupid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$PAGE->set_cm($cm, $course);
@ -854,10 +847,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$a->type = get_string('modulename', $cm->modname);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewallmodentries', 'blog', $a);
} else
} else if (!empty($courseid) && empty($userid) && empty($groupid) && empty($modid) && empty($entryid)) {
// Case 10: All blog entries associated with a course.
// Case 10: All blog entries associated with a course
if (!empty($courseid) && empty($userid) && empty($groupid) && empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$blogurl->param('courseid', $courseid);
@ -866,20 +858,24 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesabout', 'blog', format_string($course->fullname, true, array('context' => context_course::instance($course->id))));
$headers['heading'] = get_string('blogentriesabout',
'blog',
format_string($course->fullname,
true,
array('context' => context_course::instance($course->id))));
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewblogentries', 'blog', $a);
$blogurl->remove_params(array('userid'));
}
if (!in_array($action, array('edit', 'add'))) {
// Append Tag info
// Append Tag info.
if (!empty($tagid)) {
$headers['filters']['tag'] = $tagid;
$blogurl->param('tagid', $tagid);
$tagrec = $DB->get_record('tag', array('id'=>$tagid));
$PAGE->navbar->add($tagrec->name, $blogurl);
} elseif (!empty($tag)) {
} else if (!empty($tag)) {
if ($tagrec = $DB->get_record('tag', array('name' => $tag))) {
$tagid = $tagrec->id;
$headers['filters']['tag'] = $tagid;
@ -888,7 +884,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
}
}
// Append Search info
// Append Search info.
if (!empty($search)) {
$headers['filters']['search'] = $search;
$blogurl->param('search', $search);
@ -896,7 +892,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
}
}
// Append edit mode info
// Append edit mode info.
if (!empty($action) && $action == 'add') {
} else if (!empty($action) && $action == 'edit') {