From 1af9063e47485f4e78f8ae88ed9eebfe5cb78ff5 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 21 Nov 2013 13:36:48 +0800 Subject: [PATCH] MDL-43005 blogs: Fix issues with blog tags --- blog/index.php | 2 +- blog/lib.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/blog/index.php b/blog/index.php index 61ef61d801274..6b3d5db9d3183 100644 --- a/blog/index.php +++ b/blog/index.php @@ -40,7 +40,7 @@ //correct tagid if a text tag is provided as a param if (!empty($tag)) { - if ($tagrec = $DB->get_record_sql("SELECT * FROM {tag} WHERE ". $DB->sql_like('name', '?', false), array("%$tag%"))) { + if ($tagrec = $DB->get_record('tag', array('name' => $tag))) { $tagid = $tagrec->id; } else { unset($tagid); diff --git a/blog/lib.php b/blog/lib.php index c7ee5bd9a2ed5..10317c7624c37 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -880,8 +880,12 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu $tagrec = $DB->get_record('tag', array('id'=>$tagid)); $PAGE->navbar->add($tagrec->name, $blogurl); } elseif (!empty($tag)) { - $blogurl->param('tag', $tag); - $PAGE->navbar->add(get_string('tagparam', 'blog', $tag), $blogurl); + if ($tagrec = $DB->get_record('tag', array('name' => $tag))) { + $tagid = $tagrec->id; + $headers['filters']['tag'] = $tagid; + $blogurl->param('tag', $tag); + $PAGE->navbar->add(get_string('tagparam', 'blog', $tag), $blogurl); + } } // Append Search info