From 0e32a56591b85767bbe524895c533a21709be25a Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 28 Aug 2015 16:13:26 +0800 Subject: [PATCH 1/2] MDL-51239 core_blog: coding style fixes --- blog/edit.php | 14 ++++++---- blog/external_blogs.php | 2 +- blog/index.php | 18 ++++++------- blog/lib.php | 52 ++++++++++++++++++------------------- blog/locallib.php | 8 +++--- blog/renderer.php | 8 +++--- blog/rsslib.php | 20 +++++++------- blog/tests/bloglib_test.php | 50 +++++++++++++++++------------------ 8 files changed, 88 insertions(+), 84 deletions(-) diff --git a/blog/edit.php b/blog/edit.php index 7ff8333e0ecff..2731cba74d35e 100644 --- a/blog/edit.php +++ b/blog/edit.php @@ -132,8 +132,12 @@ redirect($returnurl); } } else if (blog_user_can_edit_entry($entry)) { - $optionsyes = array('entryid'=>$id, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'courseid'=>$courseid); - $optionsno = array('userid'=>$entry->userid, 'courseid'=>$courseid); + $optionsyes = array('entryid' => $id, + 'action' => 'delete', + 'confirm' => 1, + 'sesskey' => sesskey(), + 'courseid' => $courseid); + $optionsno = array('userid' => $entry->userid, 'courseid' => $courseid); $PAGE->set_title("$SITE->shortname: $strblogs"); $PAGE->set_heading($SITE->fullname); echo $OUTPUT->header(); @@ -181,9 +185,9 @@ } require_once('edit_form.php'); -$summaryoptions = array('maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>true, 'context'=>$sitecontext, - 'subdirs'=>file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id)); -$attachmentoptions = array('subdirs'=>false, 'maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes); +$summaryoptions = array('maxfiles' => 99, 'maxbytes' => $CFG->maxbytes, 'trusttext' => true, 'context' => $sitecontext, + 'subdirs' => file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id)); +$attachmentoptions = array('subdirs' => false, 'maxfiles' => 99, 'maxbytes' => $CFG->maxbytes); $blogeditform = new blog_edit_form(null, compact('entry', 'summaryoptions', diff --git a/blog/external_blogs.php b/blog/external_blogs.php index 4b0d408cbce15..65958483fa032 100644 --- a/blog/external_blogs.php +++ b/blog/external_blogs.php @@ -94,7 +94,7 @@ $editurl = new moodle_url('/blog/external_blog_edit.php', array('id' => $blog->id)); $editicon = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('editexternalblog', 'blog'))); - $deletelink = new moodle_url('/blog/external_blogs.php', array('delete' => $blog->id, 'sesskey'=>sesskey())); + $deletelink = new moodle_url('/blog/external_blogs.php', array('delete' => $blog->id, 'sesskey' => sesskey())); $deleteicon = $OUTPUT->action_icon($deletelink, new pix_icon('t/delete', get_string('deleteexternalblog', 'blog'))); $table->data[] = new html_table_row(array($blog->name, diff --git a/blog/index.php b/blog/index.php index ddbdf45424532..dfaa836aac00d 100644 --- a/blog/index.php +++ b/blog/index.php @@ -40,13 +40,13 @@ comment::init(); -$url_params = compact('id', 'start', 'tag', 'userid', 'tagid', 'modid', 'entryid', 'groupid', 'courseid', 'search'); -foreach ($url_params as $var => $val) { +$urlparams = compact('id', 'start', 'tag', 'userid', 'tagid', 'modid', 'entryid', 'groupid', 'courseid', 'search'); +foreach ($urlparams as $var => $val) { if (empty($val)) { - unset($url_params[$var]); + unset($urlparams[$var]); } } -$PAGE->set_url('/blog/index.php', $url_params); +$PAGE->set_url('/blog/index.php', $urlparams); // Correct tagid if a text tag is provided as a param. if (!empty($tag)) { @@ -121,7 +121,7 @@ if (!$userid && has_capability('moodle/blog:view', $sitecontext) && $CFG->bloglevel > BLOG_USER_LEVEL) { if ($entryid) { - if (!$entryobject = $DB->get_record('post', array('id'=>$entryid))) { + if (!$entryobject = $DB->get_record('post', array('id' => $entryid))) { print_error('nosuchentry', 'blog'); } $userid = $entryobject->userid; @@ -148,12 +148,12 @@ print_error('cannotviewsiteblog', 'blog'); } - $COURSE = $DB->get_record('course', array('format'=>'site')); + $COURSE = $DB->get_record('course', array('format' => 'site')); $courseid = $COURSE->id; } if (!empty($courseid)) { - if (!$course = $DB->get_record('course', array('id'=>$courseid))) { + if (!$course = $DB->get_record('course', array('id' => $courseid))) { print_error('invalidcourseid'); } @@ -176,7 +176,7 @@ print_error(get_string('invalidgroupid', 'blog')); } - if (!$course = $DB->get_record('course', array('id'=>$group->courseid))) { + if (!$course = $DB->get_record('course', array('id' => $group->courseid))) { print_error('invalidcourseid'); } @@ -200,7 +200,7 @@ print_error('blogdisable', 'blog'); } - if (!$user = $DB->get_record('user', array('id'=>$userid))) { + if (!$user = $DB->get_record('user', array('id' => $userid))) { print_error('invaliduserid'); } diff --git a/blog/lib.php b/blog/lib.php index f99ed31695cd0..00a1ffa6bf5ff 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -332,9 +332,9 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) { $userid = $page->context->instanceid; } // Check the userid var. - if (!is_null($userid) && $userid!==$USER->id) { + 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); + $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); } else { $user = null; } @@ -350,7 +350,7 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) { // Get the options for the user. if ($user !== null and !isguestuser($user)) { // Load for the requested user. - $options[CONTEXT_USER+1] = blog_get_options_for_user($user); + $options[CONTEXT_USER + 1] = blog_get_options_for_user($user); } // Load for the current user. if (isloggedin() and !isguestuser()) { @@ -413,7 +413,7 @@ function blog_get_options_for_user(stdClass $user=null) { // 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)) + 'link' => new moodle_url('/blog/index.php', array('userid' => $user->id)) ); } else { // It's the current user. @@ -421,14 +421,14 @@ function blog_get_options_for_user(stdClass $user=null) { // We can view our own blogs .... BIG surprise. $options['view'] = array( 'string' => get_string('blogentries', 'blog'), - 'link' => new moodle_url('/blog/index.php', array('userid'=>$USER->id)) + '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. $options['add'] = array( 'string' => get_string('addnewentry', 'blog'), - 'link' => new moodle_url('/blog/edit.php', array('action'=>'add')) + 'link' => new moodle_url('/blog/edit.php', array('action' => 'add')) ); } } @@ -560,13 +560,13 @@ function blog_get_options_for_module($module, $user=null) { $a->type = $modulename; $options['moduleview'] = array( 'string' => get_string('viewallmodentries', 'blog', $a), - 'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id)) + 'link' => new moodle_url('/blog/index.php', array('modid' => $module->id)) ); } // 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)) + '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. @@ -575,7 +575,7 @@ function blog_get_options_for_module($module, $user=null) { $a->user = fullname($user); $options['moduleviewuser'] = array( 'string' => get_string('blogentriesbyuseraboutmodule', 'blog', $a), - 'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id, 'userid'=>$user->id)) + 'link' => new moodle_url('/blog/index.php', array('modid' => $module->id, 'userid' => $user->id)) ); } } @@ -584,7 +584,7 @@ function blog_get_options_for_module($module, $user=null) { // 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)) + 'link' => new moodle_url('/blog/edit.php', array('action' => 'add', 'modid' => $module->id)) ); } // Cache the options. @@ -673,7 +673,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu $headers['filters']['module'] = $modid; // 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)); + $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)); $cm->modname = $DB->get_field('modules', 'name', array('id' => $cm->module)); @@ -861,7 +861,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu if (!empty($tagid)) { $headers['filters']['tag'] = $tagid; $blogurl->param('tagid', $tagid); - $tagrec = $DB->get_record('tag', array('id'=>$tagid)); + $tagrec = $DB->get_record('tag', array('id' => $tagid)); $PAGE->navbar->add($tagrec->name, $blogurl); } else if (!empty($tag)) { if ($tagrec = $DB->get_record('tag', array('name' => $tag))) { @@ -921,7 +921,7 @@ function blog_get_associated_count($courseid, $cmid=null) { * @package core_blog * @category comment * - * @param stdClass $comment_param { + * @param stdClass $commentparam { * context => context the context object * courseid => int course id * cm => stdClass course module object @@ -930,11 +930,11 @@ function blog_get_associated_count($courseid, $cmid=null) { * } * @return array */ -function blog_comment_permissions($comment_param) { +function blog_comment_permissions($commentparam) { global $DB; // If blog is public and current user is guest, then don't let him post comments. - $blogentry = $DB->get_record('post', array('id' => $comment_param->itemid), 'publishstate', MUST_EXIST); + $blogentry = $DB->get_record('post', array('id' => $commentparam->itemid), 'publishstate', MUST_EXIST); if ($blogentry->publishstate != 'public') { if (!isloggedin() || isguestuser()) { @@ -959,7 +959,7 @@ function blog_comment_permissions($comment_param) { * } * @return boolean */ -function blog_comment_validate($comment_param) { +function blog_comment_validate($commentparam) { global $CFG, $DB, $USER; // Check if blogs are enabled user can comment. @@ -968,22 +968,22 @@ function blog_comment_validate($comment_param) { } // Validate comment area. - if ($comment_param->commentarea != 'format_blog') { + if ($commentparam->commentarea != 'format_blog') { throw new comment_exception('invalidcommentarea'); } - $blogentry = $DB->get_record('post', array('id' => $comment_param->itemid), '*', MUST_EXIST); + $blogentry = $DB->get_record('post', array('id' => $commentparam->itemid), '*', MUST_EXIST); // Validation for comment deletion. - if (!empty($comment_param->commentid)) { - if ($record = $DB->get_record('comments', array('id'=>$comment_param->commentid))) { + if (!empty($commentparam->commentid)) { + if ($record = $DB->get_record('comments', array('id' => $commentparam->commentid))) { if ($record->commentarea != 'format_blog') { throw new comment_exception('invalidcommentarea'); } - if ($record->contextid != $comment_param->context->id) { + if ($record->contextid != $commentparam->context->id) { throw new comment_exception('invalidcontext'); } - if ($record->itemid != $comment_param->itemid) { + if ($record->itemid != $commentparam->itemid) { throw new comment_exception('invalidcommentitemid'); } } else { @@ -1005,10 +1005,10 @@ function blog_comment_validate($comment_param) { */ function blog_page_type_list($pagetype, $parentcontext, $currentcontext) { return array( - '*'=>get_string('page-x', 'pagetype'), - 'blog-*'=>get_string('page-blog-x', 'blog'), - 'blog-index'=>get_string('page-blog-index', 'blog'), - 'blog-edit'=>get_string('page-blog-edit', 'blog') + '*' => get_string('page-x', 'pagetype'), + 'blog-*' => get_string('page-blog-x', 'blog'), + 'blog-index' => get_string('page-blog-index', 'blog'), + 'blog-edit' => get_string('page-blog-edit', 'blog') ); } diff --git a/blog/locallib.php b/blog/locallib.php index 114e38eb0d02f..7968483fb3613 100644 --- a/blog/locallib.php +++ b/blog/locallib.php @@ -112,7 +112,7 @@ public function prepare_render() { $this->renderable = new StdClass(); - $this->renderable->user = $DB->get_record('user', array('id'=>$this->userid)); + $this->renderable->user = $DB->get_record('user', array('id' => $this->userid)); // Entry comments. if (!empty($CFG->usecomments) and $CFG->blogusecomments) { @@ -163,7 +163,7 @@ public function prepare_render() { $associations[$key]->contextlevel = $context->contextlevel; // Course associations. - if ($context->contextlevel == CONTEXT_COURSE) { + if ($context->contextlevel == CONTEXT_COURSE) { // TODO: performance!!!! $instancename = $DB->get_field('course', 'shortname', array('id' => $context->instanceid)); @@ -174,7 +174,7 @@ public function prepare_render() { } // Mod associations. - if ($context->contextlevel == CONTEXT_MODULE) { + if ($context->contextlevel == CONTEXT_MODULE) { // Getting the activity type and the activity instance id. $sql = 'SELECT cm.instance, m.name FROM {course_modules} cm @@ -653,7 +653,7 @@ public function get_entry_fetch_sql($count=false, $sort='lastmodified DESC', $us $assocexists = $DB->record_exists('blog_association', array()); // Begin permission sql clause. - $permissionsql = '(p.userid = ? '; + $permissionsql = '(p.userid = ? '; $params[] = $userid; if ($CFG->bloglevel >= BLOG_SITE_LEVEL) { // Add permission to view site-level entries. diff --git a/blog/renderer.php b/blog/renderer.php index 832d4b1281266..1045a89868532 100644 --- a/blog/renderer.php +++ b/blog/renderer.php @@ -141,10 +141,10 @@ public function render_blog_entry(blog_entry $entry) { if ($officialtags) { $o .= get_string('tags', 'tag') .': '. $this->output->container($officialtags, 'officialblogtags'); if ($defaulttags) { - $o .= ', '; + $o .= ', '; } } - $o .= $defaulttags; + $o .= $defaulttags; $o .= $this->output->container_end(); } @@ -155,7 +155,7 @@ public function render_blog_entry(blog_entry $entry) { $assocstr = ''; $coursesarray = array(); foreach ($entry->renderable->blogassociations as $assocrec) { - if ($assocrec->contextlevel == CONTEXT_COURSE) { + if ($assocrec->contextlevel == CONTEXT_COURSE) { $coursesarray[] = $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true); } } @@ -166,7 +166,7 @@ public function render_blog_entry(blog_entry $entry) { // Now show mod association. $modulesarray = array(); foreach ($entry->renderable->blogassociations as $assocrec) { - if ($assocrec->contextlevel == CONTEXT_MODULE) { + if ($assocrec->contextlevel == CONTEXT_MODULE) { $str = get_string('associated', 'blog', $assocrec->type) . ': '; $str .= $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true); $modulesarray[] = $str; diff --git a/blog/rsslib.php b/blog/rsslib.php index 3f26eb0f8aac6..247028de0f8be 100644 --- a/blog/rsslib.php +++ b/blog/rsslib.php @@ -35,7 +35,7 @@ * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @return string */ -function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $tagid=0) { +function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $tagid =0) { $componentname = 'blog'; $additionalargs = null; @@ -70,7 +70,7 @@ function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $ta * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @param string $tooltiptext The tooltip to be displayed with the link */ -function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid=0, $tooltiptext='') { +function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid =0, $tooltiptext='') { global $CFG, $USER, $OUTPUT; if (!isloggedin()) { @@ -93,7 +93,7 @@ function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid=0, $ * @param int $filterselect The id of the item defined by $filtertype * @param int $tagid The id of the row in the tag table that identifies the RSS Feed */ -function blog_rss_add_http_header($context, $title, $filtertype, $filterselect=0, $tagid=0) { +function blog_rss_add_http_header($context, $title, $filtertype, $filterselect=0, $tagid =0) { global $PAGE, $USER, $CFG; if (!isloggedin()) { @@ -168,7 +168,7 @@ function blog_rss_get_feed($context, $args) { $type = clean_param($args[3], PARAM_ALPHA); $id = clean_param($args[4], PARAM_INT); // Could be groupid / courseid / userid depending on $type. - $tagid=0; + $tagid = 0; if ($args[5] != 'rss.xml') { $tagid = clean_param($args[5], PARAM_INT); } else { @@ -234,10 +234,10 @@ function blog_rss_get_feed($context, $args) { switch ($type) { case 'user': - $info = fullname($DB->get_record('user', array('id'=>$id), 'firstname,lastname')); + $info = fullname($DB->get_record('user', array('id' => $id), 'firstname,lastname')); break; case 'course': - $info = $DB->get_field('course', 'fullname', array('id'=>$id)); + $info = $DB->get_field('course', 'fullname', array('id' => $id)); $info = format_string($info, true, array('context' => context_course::instance($id))); break; case 'site': @@ -245,7 +245,7 @@ function blog_rss_get_feed($context, $args) { break; case 'group': $group = groups_get_group($id); - $info = $group->name; // TODO: $DB->get_field('groups', 'name', array('id'=>$id)). + $info = $group->name; // TODO: $DB->get_field('groups', 'name', array('id' => $id)). break; default: $info = ''; @@ -253,7 +253,7 @@ function blog_rss_get_feed($context, $args) { } if ($tagid) { - $info .= ': '.$DB->get_field('tags', 'text', array('id'=>$tagid)); + $info .= ': '.$DB->get_field('tags', 'text', array('id' => $tagid)); } $header = rss_standard_header(get_string($type.'blog', 'blog', $info), @@ -279,7 +279,7 @@ function blog_rss_get_feed($context, $args) { * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @return string */ -function blog_rss_file_name($type, $id, $tagid=0) { +function blog_rss_file_name($type, $id, $tagid =0) { global $CFG; if ($tagid) { @@ -298,7 +298,7 @@ function blog_rss_file_name($type, $id, $tagid=0) { * @param string $contents The contents of the RSS Feed file * @return bool whether the save was successful or not */ -function blog_rss_save_file($type, $id, $tagid=0, $contents='') { +function blog_rss_save_file($type, $id, $tagid =0, $contents='') { global $CFG; $status = true; diff --git a/blog/tests/bloglib_test.php b/blog/tests/bloglib_test.php index a0589c26194c8..fb959059b48eb 100644 --- a/blog/tests/bloglib_test.php +++ b/blog/tests/bloglib_test.php @@ -46,9 +46,9 @@ protected function setUp() { $this->resetAfterTest(); // Create default course. - $course = $this->getDataGenerator()->create_course(array('category'=>1, 'shortname'=>'ANON')); + $course = $this->getDataGenerator()->create_course(array('category' => 1, 'shortname' => 'ANON')); $this->assertNotEmpty($course); - $page = $this->getDataGenerator()->create_module('page', array('course'=>$course->id)); + $page = $this->getDataGenerator()->create_module('page', array('course' => $course->id)); $this->assertNotEmpty($page); // Create default group. @@ -58,7 +58,7 @@ protected function setUp() { $group->id = $DB->insert_record('groups', $group); // Create default user. - $user = $this->getDataGenerator()->create_user(array('username'=>'testuser', 'firstname'=>'Jimmy', 'lastname'=>'Kinnon')); + $user = $this->getDataGenerator()->create_user(array('username' => 'testuser', 'firstname' => 'Jimmy', 'lastname' => 'Kinnon')); // Create default tag. $tag = new stdClass(); @@ -91,35 +91,35 @@ public function test_overrides() { // Try all the filters at once: Only the entry filter is active. $filters = array('site' => $SITE->id, 'course' => $this->courseid, 'module' => $this->cmid, 'group' => $this->groupid, 'user' => $this->userid, 'tag' => $this->tagid, 'entry' => $this->postid); - $blog_listing = new blog_listing($filters); - $this->assertFalse(array_key_exists('site', $blog_listing->filters)); - $this->assertFalse(array_key_exists('course', $blog_listing->filters)); - $this->assertFalse(array_key_exists('module', $blog_listing->filters)); - $this->assertFalse(array_key_exists('group', $blog_listing->filters)); - $this->assertFalse(array_key_exists('user', $blog_listing->filters)); - $this->assertFalse(array_key_exists('tag', $blog_listing->filters)); - $this->assertTrue(array_key_exists('entry', $blog_listing->filters)); + $bloglisting = new blog_listing($filters); + $this->assertFalse(array_key_exists('site', $bloglisting->filters)); + $this->assertFalse(array_key_exists('course', $bloglisting->filters)); + $this->assertFalse(array_key_exists('module', $bloglisting->filters)); + $this->assertFalse(array_key_exists('group', $bloglisting->filters)); + $this->assertFalse(array_key_exists('user', $bloglisting->filters)); + $this->assertFalse(array_key_exists('tag', $bloglisting->filters)); + $this->assertTrue(array_key_exists('entry', $bloglisting->filters)); // Again, but without the entry filter: This time, the tag, user and module filters are active. $filters = array('site' => $SITE->id, 'course' => $this->courseid, 'module' => $this->cmid, 'group' => $this->groupid, 'user' => $this->userid, 'tag' => $this->postid); - $blog_listing = new blog_listing($filters); - $this->assertFalse(array_key_exists('site', $blog_listing->filters)); - $this->assertFalse(array_key_exists('course', $blog_listing->filters)); - $this->assertFalse(array_key_exists('group', $blog_listing->filters)); - $this->assertTrue(array_key_exists('module', $blog_listing->filters)); - $this->assertTrue(array_key_exists('user', $blog_listing->filters)); - $this->assertTrue(array_key_exists('tag', $blog_listing->filters)); + $bloglisting = new blog_listing($filters); + $this->assertFalse(array_key_exists('site', $bloglisting->filters)); + $this->assertFalse(array_key_exists('course', $bloglisting->filters)); + $this->assertFalse(array_key_exists('group', $bloglisting->filters)); + $this->assertTrue(array_key_exists('module', $bloglisting->filters)); + $this->assertTrue(array_key_exists('user', $bloglisting->filters)); + $this->assertTrue(array_key_exists('tag', $bloglisting->filters)); // We should get the same result by removing the 3 inactive filters: site, course and group. $filters = array('module' => $this->cmid, 'user' => $this->userid, 'tag' => $this->tagid); - $blog_listing = new blog_listing($filters); - $this->assertFalse(array_key_exists('site', $blog_listing->filters)); - $this->assertFalse(array_key_exists('course', $blog_listing->filters)); - $this->assertFalse(array_key_exists('group', $blog_listing->filters)); - $this->assertTrue(array_key_exists('module', $blog_listing->filters)); - $this->assertTrue(array_key_exists('user', $blog_listing->filters)); - $this->assertTrue(array_key_exists('tag', $blog_listing->filters)); + $bloglisting = new blog_listing($filters); + $this->assertFalse(array_key_exists('site', $bloglisting->filters)); + $this->assertFalse(array_key_exists('course', $bloglisting->filters)); + $this->assertFalse(array_key_exists('group', $bloglisting->filters)); + $this->assertTrue(array_key_exists('module', $bloglisting->filters)); + $this->assertTrue(array_key_exists('user', $bloglisting->filters)); + $this->assertTrue(array_key_exists('tag', $bloglisting->filters)); } From f0899a256099392aac5bed5c2cfdf7d5b1920855 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 8 Dec 2015 13:28:17 +0800 Subject: [PATCH 2/2] MDL-51239 blog: Coding style fixes. --- blog/rsslib.php | 10 +++++----- blog/tests/bloglib_test.php | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/blog/rsslib.php b/blog/rsslib.php index 247028de0f8be..cad38d88d50a5 100644 --- a/blog/rsslib.php +++ b/blog/rsslib.php @@ -35,7 +35,7 @@ * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @return string */ -function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $tagid =0) { +function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect = 0, $tagid = 0) { $componentname = 'blog'; $additionalargs = null; @@ -70,7 +70,7 @@ function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $ta * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @param string $tooltiptext The tooltip to be displayed with the link */ -function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid =0, $tooltiptext='') { +function blog_rss_print_link($context, $filtertype, $filterselect = 0, $tagid = 0, $tooltiptext = '') { global $CFG, $USER, $OUTPUT; if (!isloggedin()) { @@ -93,7 +93,7 @@ function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid =0, * @param int $filterselect The id of the item defined by $filtertype * @param int $tagid The id of the row in the tag table that identifies the RSS Feed */ -function blog_rss_add_http_header($context, $title, $filtertype, $filterselect=0, $tagid =0) { +function blog_rss_add_http_header($context, $title, $filtertype, $filterselect = 0, $tagid = 0) { global $PAGE, $USER, $CFG; if (!isloggedin()) { @@ -279,7 +279,7 @@ function blog_rss_get_feed($context, $args) { * @param int $tagid The id of the row in the tag table that identifies the RSS Feed * @return string */ -function blog_rss_file_name($type, $id, $tagid =0) { +function blog_rss_file_name($type, $id, $tagid = 0) { global $CFG; if ($tagid) { @@ -298,7 +298,7 @@ function blog_rss_file_name($type, $id, $tagid =0) { * @param string $contents The contents of the RSS Feed file * @return bool whether the save was successful or not */ -function blog_rss_save_file($type, $id, $tagid =0, $contents='') { +function blog_rss_save_file($type, $id, $tagid = 0, $contents = '') { global $CFG; $status = true; diff --git a/blog/tests/bloglib_test.php b/blog/tests/bloglib_test.php index fb959059b48eb..73c81f25f214f 100644 --- a/blog/tests/bloglib_test.php +++ b/blog/tests/bloglib_test.php @@ -58,7 +58,11 @@ protected function setUp() { $group->id = $DB->insert_record('groups', $group); // Create default user. - $user = $this->getDataGenerator()->create_user(array('username' => 'testuser', 'firstname' => 'Jimmy', 'lastname' => 'Kinnon')); + $user = $this->getDataGenerator()->create_user(array( + 'username' => 'testuser', + 'firstname' => 'Jimmy', + 'lastname' => 'Kinnon' + )); // Create default tag. $tag = new stdClass();