From 55bb2b3d785e1cfdd71212b7005996bebb955b18 Mon Sep 17 00:00:00 2001 From: JuanPablo-Openlms Date: Thu, 28 Sep 2023 11:02:10 -0500 Subject: [PATCH 1/4] add new section flag and task. --- README.md | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e037d482..3f1a88fd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Open Forum Activity -Open forums enhance Moodle Forums by providing teachers and students with quick, -simple views into the forums and their discussions. Allowing users to sort and search -discussions easily and in multiple layouts is key to Advanced Forums increased usability. -Read tracking is a feature in Advanced forums that highlights unread posts, -making it even easier to manage a forum. This saves the student time in viewing and -responding to posts, and saves the teacher time in finding the posts that are most -relevant to the class. Teachers are empowered to create anonymous interactions with + +Open forums enhance Moodle Forums by providing teachers and students with quick, +simple views into the forums and their discussions. Allowing users to sort and search +discussions easily and in multiple layouts is key to Advanced Forums increased usability. +Read tracking is a feature in Advanced forums that highlights unread posts, +making it even easier to manage a forum. This saves the student time in viewing and +responding to posts, and saves the teacher time in finding the posts that are most +relevant to the class. Teachers are empowered to create anonymous interactions with students while still being able to provide accurate grading with advanced grading methods. ![local_hsuforum](https://moodle.org/pluginfile.php/50/local_plugins/plugin_description/399/recent%20posts.png) @@ -16,11 +17,33 @@ schools and organizations by supporting the software that educators use to manag learners in virtual classrooms. ## Installation + Extract the contents of the plugin into _/wwwroot/mod_ then visit `admin/upgrade.php` or use the CLI script to upgrade your site. For more information about the configuration and usage, please see http://docs.moodle.org/dev/Advanced_Forum +## Flag + +### The `hsuforum_digestmailtime` flag. + +### The `hsuforum_allowforcedreadtracking` flag. + +### The `hsuforum_enabletimedposts` flag. + +### The `hsuforum_digestmailtimelast` flag. + +### The `mod_hsuforum_grading_interface` flag. + +### The `hsuforum_replytouser` flag. + +### The `hsuforum_subscription` flag. + +## Task + +### `cron_task` scheduled task . + ## License + Copyright (c) 2021 Open LMS (https://www.openlms.net) This program is free software: you can redistribute it and/or modify it under @@ -33,4 +56,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program. If not, see . \ No newline at end of file +this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). \ No newline at end of file From 8c0761f02e210d42135ae4de42d1369f087762b0 Mon Sep 17 00:00:00 2001 From: JuanPablo-Openlms Date: Wed, 3 Jan 2024 10:34:48 -0500 Subject: [PATCH 2/4] Fixed array syntax issues. --- .../backup_hsuforum_activity_task.class.php | 2 +- backup/moodle2/restore_hsuforum_stepslib.php | 2 +- classes/controller/edit_controller.php | 8 +- classes/message/inbound/reply_handler.php | 2 +- classes/output/big_search_form.php | 4 +- classes/post_form.php | 4 +- classes/privacy/provider.php | 4 +- classes/renderables/advanced_editor.php | 2 +- classes/search/post.php | 4 +- classes/service/discussion_service.php | 2 +- classes/service/form_service.php | 2 +- classes/service/post_service.php | 4 +- db/access.php | 130 +++++++++--------- db/events.php | 2 +- db/services.php | 16 +-- db/tasks.php | 4 +- db/upgrade.php | 4 +- discuss.php | 4 +- externallib.php | 58 ++++---- index.php | 2 +- lib.php | 34 ++--- lib/userselector/discussion/existing.php | 2 +- lib/userselector/discussion/potential.php | 2 +- locallib.php | 8 +- mod_form.php | 2 +- post.php | 16 +-- renderer.php | 12 +- search.php | 4 +- settings.php | 6 +- tests/custom_completion_test.php | 38 ++--- tests/events_test.php | 48 +++---- tests/externallib_test.php | 8 +- tests/form_service_test.php | 4 +- tests/generator/lib.php | 2 +- tests/lib_test.php | 34 ++--- tests/mail_test.php | 6 +- tests/portfolio_caller_test.php | 16 +-- tests/search_test.php | 4 +- user.php | 4 +- 39 files changed, 255 insertions(+), 255 deletions(-) diff --git a/backup/moodle2/backup_hsuforum_activity_task.class.php b/backup/moodle2/backup_hsuforum_activity_task.class.php index 5fd4dfee..e6621247 100644 --- a/backup/moodle2/backup_hsuforum_activity_task.class.php +++ b/backup/moodle2/backup_hsuforum_activity_task.class.php @@ -70,7 +70,7 @@ public function get_comment_file_annotation_info() { static public function encode_content_links($content) { global $CFG; - $base = preg_quote($CFG->wwwroot,"/"); + $base = preg_quote($CFG->wwwroot,"/",); // Link to the list of forums $search="/(".$base."\/mod\/hsuforum\/index.php\?id\=)([0-9]+)/"; diff --git a/backup/moodle2/restore_hsuforum_stepslib.php b/backup/moodle2/restore_hsuforum_stepslib.php index eda0ba2f..939594e6 100644 --- a/backup/moodle2/restore_hsuforum_stepslib.php +++ b/backup/moodle2/restore_hsuforum_stepslib.php @@ -275,7 +275,7 @@ protected function after_restore() { $sd->reveal = 0; $sdid = hsuforum_add_discussion($sd, null, null, $this->task->get_userid()); // Mark the post as mailed - $DB->set_field ('hsuforum_posts','mailed', '1', array('discussion' => $sdid)); + $DB->set_field ('hsuforum_posts','mailed', '1', array('discussion' => $sdid,)); // Copy all the files from mod_foum/intro to mod_hsuforum/post $fs = get_file_storage(); $files = $fs->get_area_files($this->task->get_contextid(), 'mod_hsuforum', 'intro'); diff --git a/classes/controller/edit_controller.php b/classes/controller/edit_controller.php index 153b8e22..232792cb 100644 --- a/classes/controller/edit_controller.php +++ b/classes/controller/edit_controller.php @@ -119,7 +119,7 @@ public function reply_action() { 'message' => $message, 'messageformat' => $messageformat, 'reveal' => $reveal, - 'mailnow' => $mailnow + 'mailnow' => $mailnow, ); if (!empty($subject)) { $data['subject'] = $subject; @@ -175,7 +175,7 @@ public function add_discussion_action() { 'reveal' => $reveal, 'timestart' => $timestart, 'timeend' => $timeend, - 'mailnow' => $mailnow + 'mailnow' => $mailnow, ); return $this->discussionservice->handle_add_discussion($course, $cm, $forum, $context, $options, $posttomygroups); } catch (\Exception $e) { @@ -238,7 +238,7 @@ public function update_post_action() { 'reveal' => $reveal, 'privatereply' => $privatereply, 'timestart' => $timestart, - 'timeend' => $timeend + 'timeend' => $timeend, )); } catch (\Exception $e) { return new json_response($e); @@ -281,7 +281,7 @@ public function edit_post_form_action() { 'isdiscussion' => true, 'timestart' => $discussion->timestart, 'timeend' => $discussion->timeend, - 'offset' => $offset + 'offset' => $offset, ]); } } diff --git a/classes/message/inbound/reply_handler.php b/classes/message/inbound/reply_handler.php index 0fea5118..3df02036 100644 --- a/classes/message/inbound/reply_handler.php +++ b/classes/message/inbound/reply_handler.php @@ -253,7 +253,7 @@ public function process_message(\stdClass $record, \stdClass $messagedata) { 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); $event = \mod_hsuforum\event\post_created::create($params); $event->add_record_snapshot('hsuforum_posts', $addpost); diff --git a/classes/output/big_search_form.php b/classes/output/big_search_form.php index 33f559f9..c230b5f4 100644 --- a/classes/output/big_search_form.php +++ b/classes/output/big_search_form.php @@ -73,7 +73,7 @@ public function __construct($course) { $this->forumoptions = array_map(function($option) use ($forumoptions) { return [ 'value' => $option, - 'name' => $forumoptions[$option] + 'name' => $forumoptions[$option], ]; }, array_keys($forumoptions)); } @@ -200,7 +200,7 @@ public function export_for_template(renderer_base $output) { foreach ($tags as $tag) { $data->tagoptions[] = ['value' => $tag->rawname, 'text' => $tag->fieldname, - 'selected' => in_array($tag->rawname, $this->tags) + 'selected' => in_array($tag->rawname, $this->tags), ]; } diff --git a/classes/post_form.php b/classes/post_form.php index 68d5885d..30806ba4 100644 --- a/classes/post_form.php +++ b/classes/post_form.php @@ -52,7 +52,7 @@ public static function attachment_options($forum) { 'maxbytes' => $maxbytes, 'maxfiles' => $forum->maxattachments, 'accepted_types' => '*', - 'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK + 'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK, ); } @@ -72,7 +72,7 @@ public static function editor_options(context_module $context, $postid) { 'maxbytes' => $maxbytes, 'trusttext'=> true, 'return_types'=> FILE_INTERNAL | FILE_EXTERNAL, - 'subdirs' => file_area_contains_subdirs($context, 'mod_hsuforum', 'post', $postid) + 'subdirs' => file_area_contains_subdirs($context, 'mod_hsuforum', 'post', $postid), ); } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index cafd3c7c..62332ee6 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -98,7 +98,7 @@ public static function get_metadata(collection $items) : collection { 'userid' => 'privacy:metadata:hsuforum_queue:userid', 'discussionid' => 'privacy:metadata:hsuforum_queue:discussionid', 'postid' => 'privacy:metadata:hsuforum_queue:postid', - 'timemodified' => 'privacy:metadata:hsuforum_queue:timemodified' + 'timemodified' => 'privacy:metadata:hsuforum_queue:timemodified', ], 'privacy:metadata:hsuforum_queue'); // The 'hsuforum_read' table stores data about which forum posts have been read by each user. @@ -561,7 +561,7 @@ protected static function export_discussion_data(int $userid, array $mappings) { 'pinned' => transform::yesno((bool)$discussion->pinned), 'timemodified' => transform::datetime($discussion->timemodified), 'usermodified' => transform::datetime($discussion->usermodified), - 'creator_was_you' => transform::yesno($discussion->userid == $userid) + 'creator_was_you' => transform::yesno($discussion->userid == $userid), ]; $discussionarea = static::get_discussion_area($discussion); diff --git a/classes/renderables/advanced_editor.php b/classes/renderables/advanced_editor.php index 0f6dda0e..c8463afb 100644 --- a/classes/renderables/advanced_editor.php +++ b/classes/renderables/advanced_editor.php @@ -110,7 +110,7 @@ public function get_data($draftid = 0){ 'editor' => $editor, 'options' => $options, 'fpoptions' => $fpoptions, - 'draftitemid' => $draftitemid + 'draftitemid' => $draftitemid, ]; } } diff --git a/classes/search/post.php b/classes/search/post.php index e8558d1f..3179b540 100644 --- a/classes/search/post.php +++ b/classes/search/post.php @@ -144,7 +144,7 @@ public function uses_file_indexing() { public function get_search_fileareas() { $fileareas = array( 'attachment', - 'post' + 'post', ); return $fileareas; @@ -315,7 +315,7 @@ protected function get_discussion($discussionid) { protected function get_contexts_to_reindex_extra_sql() { return [ 'JOIN {hsuforum_discussions} fd ON fd.course = cm.course AND fd.forum = cm.instance', - 'MAX(fd.timemodified) DESC' + 'MAX(fd.timemodified) DESC', ]; } diff --git a/classes/service/discussion_service.php b/classes/service/discussion_service.php index f864111d..51822a6e 100644 --- a/classes/service/discussion_service.php +++ b/classes/service/discussion_service.php @@ -242,7 +242,7 @@ public function trigger_discussion_created($course, \context_module $context, $c 'objectid' => $discussion->id, 'other' => array( 'forumid' => $forum->id, - ) + ), ); $event = discussion_created::create($params); $event->add_record_snapshot('hsuforum_discussions', $discussion); diff --git a/classes/service/form_service.php b/classes/service/form_service.php index 6a8de072..f1f927b7 100644 --- a/classes/service/form_service.php +++ b/classes/service/form_service.php @@ -215,7 +215,7 @@ public function edit_discussion_form($cm, $discussion, $post, $draftid) { 'groupid' => ($discussion->groupid == -1) ? 0 : $discussion->groupid, 'itemid' => $itemid, 'timestart' => $discussion->timestart, - 'timeend' => $discussion->timeend + 'timeend' => $discussion->timeend, )); } } diff --git a/classes/service/post_service.php b/classes/service/post_service.php index a1fb0715..b362809f 100644 --- a/classes/service/post_service.php +++ b/classes/service/post_service.php @@ -374,7 +374,7 @@ public function trigger_post_created($course, \context_module $context, $cm, $fo 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); $event = post_created::create($params); $event->add_record_snapshot('hsuforum_posts', $post); @@ -400,7 +400,7 @@ public function trigger_post_updated(\context_module $context, $forum, $discussi 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); if ($post->userid !== $USER->id) { diff --git a/db/access.php b/db/access.php index f7abe9b4..d745f294 100644 --- a/db/access.php +++ b/db/access.php @@ -35,9 +35,9 @@ 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ), 'mod/hsuforum:viewdiscussion' => array( @@ -50,8 +50,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewhiddentimedposts' => array( @@ -61,8 +61,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:startdiscussion' => array( @@ -75,8 +75,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:replypost' => array( @@ -89,8 +89,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:addnews' => array( @@ -102,8 +102,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:replynews' => array( @@ -115,8 +115,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewrating' => array( @@ -127,8 +127,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewanyrating' => array( @@ -139,8 +139,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewallratings' => array( @@ -151,9 +151,9 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'mod/hsuforum:viewanyrating' + 'clonepermissionsfrom' => 'mod/hsuforum:viewanyrating', ), 'mod/hsuforum:rate' => array( @@ -163,8 +163,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:createattachment' => array( @@ -177,8 +177,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:deleteownpost' => array( @@ -189,8 +189,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:deleteanypost' => array( @@ -200,8 +200,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:splitdiscussions' => array( @@ -211,8 +211,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:movediscussions' => array( @@ -222,8 +222,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:pindiscussions' => array( @@ -233,8 +233,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:editanypost' => array( @@ -246,8 +246,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:revealpost' => array( @@ -258,8 +258,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewqandawithoutposting' => array( @@ -269,8 +269,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewsubscribers' => array( @@ -280,8 +280,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:managesubscriptions' => array( @@ -293,8 +293,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:postwithoutthrottling' => array( @@ -306,8 +306,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:exportdiscussion' => array( @@ -319,8 +319,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:exportpost' => array( @@ -331,8 +331,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:exportownpost' => array( @@ -345,7 +345,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, 'student' => CAP_ALLOW, - ) + ), ), 'mod/hsuforum:addquestion' => array( @@ -356,8 +356,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewposters' => array( @@ -371,8 +371,8 @@ 'student' => CAP_PREVENT, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:viewflags'=> array( @@ -384,8 +384,8 @@ 'student' => CAP_PREVENT, 'teacher' => CAP_PREVENT, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:allowprivate' => array( @@ -396,8 +396,8 @@ 'manager' => CAP_ALLOW, 'coursecreator' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'teacher' => CAP_ALLOW - ) + 'teacher' => CAP_ALLOW, + ), ), 'mod/hsuforum:allowforcesubscribe' => array( @@ -407,8 +407,8 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'frontpage' => CAP_ALLOW - ) + 'frontpage' => CAP_ALLOW, + ), ), 'mod/hsuforum:canposttomygroups' => array( @@ -417,8 +417,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), 'mod/hsuforum:canoverridediscussionlock' => array( 'captype' => 'write', @@ -426,8 +426,8 @@ 'archetypes' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) + 'manager' => CAP_ALLOW, + ), ), ); diff --git a/db/events.php b/db/events.php index ab1629ca..614b2608 100644 --- a/db/events.php +++ b/db/events.php @@ -35,7 +35,7 @@ array( 'eventname' => '\core\event\role_assigned', - 'callback' => 'mod_hsuforum_observer::role_assigned' + 'callback' => 'mod_hsuforum_observer::role_assigned', ), array( diff --git a/db/services.php b/db/services.php index 5b752471..97bb0bee 100644 --- a/db/services.php +++ b/db/services.php @@ -33,7 +33,7 @@ returned.', 'type' => 'read', 'capabilities' => 'mod/hsuforum:viewdiscussion', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_get_forum_discussion_posts' => array( @@ -43,7 +43,7 @@ 'description' => 'Returns a list of forum posts for a discussion.', 'type' => 'read', 'capabilities' => 'mod/hsuforum:viewdiscussion, mod/hsuforum:viewqandawithoutposting', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_get_forum_discussions_paginated' => array( @@ -53,7 +53,7 @@ 'description' => 'Returns a list of forum discussions optionally sorted and paginated.', 'type' => 'read', 'capabilities' => 'mod/hsuforum:viewdiscussion, mod/hsuforum:viewqandawithoutposting', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_view_forum' => array( @@ -63,7 +63,7 @@ 'description' => 'Trigger the course module viewed event and update the module completion status.', 'type' => 'write', 'capabilities' => 'mod/hsuforum:viewdiscussion', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_view_forum_discussion' => array( @@ -73,7 +73,7 @@ 'description' => 'Trigger the forum discussion viewed event.', 'type' => 'write', 'capabilities' => 'mod/hsuforum:viewdiscussion', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_add_discussion_post' => array( @@ -83,7 +83,7 @@ 'description' => 'Create new posts into an existing discussion.', 'type' => 'write', 'capabilities' => 'mod/hsuforum:replypost', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_add_discussion' => array( @@ -93,7 +93,7 @@ 'description' => 'Add a new discussion into an existing forum.', 'type' => 'write', 'capabilities' => 'mod/hsuforum:startdiscussion', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), 'mod_hsuforum_can_add_discussion' => array( @@ -102,7 +102,7 @@ 'classpath' => 'mod/hsuforum/externallib.php', 'description' => 'Check if the current user can add discussions in the given forum (and optionally for the given group).', 'type' => 'read', - 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) + 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), ); diff --git a/db/tasks.php b/db/tasks.php index c5399816..79ca6727 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -33,6 +33,6 @@ 'hour' => '*', 'day' => '*', 'month' => '*', - 'dayofweek' => '*' - ) + 'dayofweek' => '*', + ), ); diff --git a/db/upgrade.php b/db/upgrade.php index a60d6d73..bfbc165d 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -55,7 +55,7 @@ function xmldb_hsuforum_upgrade($oldversion) { $replacements = array( 11 => 20, 12 => 50, - 13 => 100 + 13 => 100, ); // Run the replacements. @@ -164,7 +164,7 @@ function xmldb_hsuforum_upgrade($oldversion) { 'showsubstantive', 'trackingtype', 'trackreadposts', - 'usermarksread' + 'usermarksread', ); // Migrate legacy configs to plugin configs. diff --git a/discuss.php b/discuss.php index d3037fa9..326289dd 100644 --- a/discuss.php +++ b/discuss.php @@ -79,7 +79,7 @@ $params = array( 'context' => $modcontext, - 'objectid' => $forum->id + 'objectid' => $forum->id, ); $event = \mod_hsuforum\event\course_module_viewed::create($params); $event->add_record_snapshot('course_modules', $cm); @@ -142,7 +142,7 @@ 'other' => array( 'fromforumid' => $forum->id, 'toforumid' => $forumto->id, - ) + ), ); $event = \mod_hsuforum\event\discussion_moved::create($params); $event->add_record_snapshot('hsuforum_discussions', $discussion); diff --git a/externallib.php b/externallib.php index 5deface1..c8490534 100644 --- a/externallib.php +++ b/externallib.php @@ -171,7 +171,7 @@ public static function get_forum_discussion_posts_parameters() { return new external_function_parameters ( array( 'discussionid' => new external_value(PARAM_INT, 'discussion ID', VALUE_REQUIRED), - ) + ), ); } @@ -192,7 +192,7 @@ public static function get_forum_discussion_posts($discussionid) { // Validate the parameter. $params = self::validate_parameters( self::get_forum_discussion_posts_parameters(), - array('discussionid' => $discussionid) + array('discussionid' => $discussionid, ) ); // Compact/extract functions are not recommended. @@ -341,12 +341,12 @@ public static function get_forum_discussion_posts_returns() { 'postread' => new external_value(PARAM_BOOL, 'The post was read'), 'userfullname' => new external_value(PARAM_TEXT, 'Post author full name'), 'userpictureurl' => new external_value(PARAM_URL, 'Post author picture.', VALUE_OPTIONAL), - 'deleted' => new external_value(PARAM_BOOL, 'This post has been removed.') + 'deleted' => new external_value(PARAM_BOOL, 'This post has been removed.'), ), 'post' ) ), 'ratinginfo' => \core_rating\external\util::external_ratings_structure(), - 'warnings' => new external_warnings() + 'warnings' => new external_warnings(), ) ); } @@ -397,7 +397,7 @@ public static function get_forum_discussions_paginated($forumid, $sortby = 'time 'sortby' => $sortby, 'sortdirection' => $sortdirection, 'page' => $page, - 'perpage' => $perpage + 'perpage' => $perpage, ) ); @@ -593,7 +593,7 @@ public static function get_forum_discussions_paginated_returns() { ), 'post' ) ), - 'warnings' => new external_warnings() + 'warnings' => new external_warnings(), ) ); } @@ -606,7 +606,7 @@ public static function get_forum_discussions_paginated_returns() { public static function view_forum_parameters() { return new external_function_parameters( array( - 'forumid' => new external_value(PARAM_INT, 'forum instance id') + 'forumid' => new external_value(PARAM_INT, 'forum instance id'), ) ); } @@ -625,7 +625,7 @@ public static function view_forum($forumid) { $params = self::validate_parameters(self::view_forum_parameters(), array( - 'forumid' => $forumid + 'forumid' => $forumid, )); $warnings = array(); $discussions = array(); @@ -658,7 +658,7 @@ public static function view_forum_returns() { return new external_single_structure( array( 'status' => new external_value(PARAM_BOOL, 'status: true if success'), - 'warnings' => new external_warnings() + 'warnings' => new external_warnings(), ) ); } @@ -672,8 +672,8 @@ public static function view_forum_returns() { public static function view_forum_discussion_parameters() { return new external_function_parameters( array( - 'discussionid' => new external_value(PARAM_INT, 'discussion id') - ) + 'discussionid' => new external_value(PARAM_INT, 'discussion id', ), + ), ); } @@ -691,7 +691,7 @@ public static function view_forum_discussion($discussionid) { $params = self::validate_parameters(self::view_forum_discussion_parameters(), array( - 'discussionid' => $discussionid + 'discussionid' => $discussionid, )); $warnings = array(); @@ -726,7 +726,7 @@ public static function view_forum_discussion_returns() { return new external_single_structure( array( 'status' => new external_value(PARAM_BOOL, 'status: true if success'), - 'warnings' => new external_warnings() + 'warnings' => new external_warnings(), ) ); } @@ -755,9 +755,9 @@ public static function add_discussion_post_parameters() { '), 'value' => new external_value(PARAM_RAW, 'the value of the option, this param is validated in the external function.' - ) + ), ) - ), 'Options', VALUE_DEFAULT, array()) + ), 'Options', VALUE_DEFAULT, array()), ) ); } @@ -782,7 +782,7 @@ public static function add_discussion_post($postid, $subject, $message, $options 'postid' => $postid, 'subject' => $subject, 'message' => $message, - 'options' => $options + 'options' => $options, ) ); $warnings = array(); @@ -806,7 +806,7 @@ public static function add_discussion_post($postid, $subject, $message, $options $options = array( 'discussionsubscribe' => true, 'inlineattachmentsid' => 0, - 'attachmentsid' => null + 'attachmentsid' => null, ); foreach ($params['options'] as $option) { $name = trim($option['name']); @@ -865,7 +865,7 @@ public static function add_discussion_post($postid, $subject, $message, $options 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); $event = \mod_hsuforum\event\post_created::create($params); $event->add_record_snapshot('hsuforum_posts', $post); @@ -902,7 +902,7 @@ public static function add_discussion_post_returns() { return new external_single_structure( array( 'postid' => new external_value(PARAM_INT, 'new post id'), - 'warnings' => new external_warnings() + 'warnings' => new external_warnings(), ) ); } @@ -932,9 +932,9 @@ public static function add_discussion_parameters() { '), 'value' => new external_value(PARAM_RAW, 'The value of the option, This param is validated in the external function.' - ) + ), ) - ), 'Options', VALUE_DEFAULT, array()) + ), 'Options', VALUE_DEFAULT, array()), ) ); } @@ -961,7 +961,7 @@ public static function add_discussion($forumid, $subject, $message, $groupid = 0 'subject' => $subject, 'message' => $message, 'groupid' => $groupid, - 'options' => $options + 'options' => $options, )); $warnings = array(); @@ -978,7 +978,7 @@ public static function add_discussion($forumid, $subject, $message, $groupid = 0 'discussionsubscribe' => true, 'discussionpinned' => false, 'inlineattachmentsid' => 0, - 'attachmentsid' => null + 'attachmentsid' => null, ); foreach ($params['options'] as $option) { $name = trim($option['name']); @@ -1061,7 +1061,7 @@ public static function add_discussion($forumid, $subject, $message, $groupid = 0 'objectid' => $discussion->id, 'other' => array( 'forumid' => $forum->id, - ) + ), ); $event = \mod_hsuforum\event\discussion_created::create($params); $event->add_record_snapshot('hsuforum_discussions', $discussion); @@ -1095,9 +1095,9 @@ public static function add_discussion($forumid, $subject, $message, $groupid = 0 public static function add_discussion_returns() { return new external_single_structure( array( - 'discussionid' => new external_value(PARAM_INT, 'New Discussion ID'), - 'warnings' => new external_warnings() - ) + 'discussionid' => new external_value(PARAM_INT, 'New Discussion ID', ), + 'warnings' => new external_warnings(), + ), ); } @@ -1112,7 +1112,7 @@ public static function can_add_discussion_parameters() { array( 'forumid' => new external_value(PARAM_INT, 'Forum instance ID'), 'groupid' => new external_value(PARAM_INT, 'The group to check, default to active group. - Use -1 to check if the user can post in all the groups.', VALUE_DEFAULT, null) + Use -1 to check if the user can post in all the groups.', VALUE_DEFAULT, null), ) ); } @@ -1168,7 +1168,7 @@ public static function can_add_discussion_returns() { VALUE_OPTIONAL), 'cancreateattachment' => new external_value(PARAM_BOOL, 'True if the user can add attachments, false otherwise.', VALUE_OPTIONAL), - 'warnings' => new external_warnings() + 'warnings' => new external_warnings(), ) ); } diff --git a/index.php b/index.php index c61d9475..d691c8e4 100644 --- a/index.php +++ b/index.php @@ -55,7 +55,7 @@ unset($SESSION->fromdiscussion); $params = array( - 'context' => context_course::instance($course->id) + 'context' => context_course::instance($course->id), ); $event = \mod_hsuforum\event\course_module_instance_list_viewed::create($params); $event->add_record_snapshot('course', $course); diff --git a/lib.php b/lib.php index 1c04623d..d8d8ce1f 100644 --- a/lib.php +++ b/lib.php @@ -3567,7 +3567,7 @@ function hsuforum_print_post_start($post, $return = false) { $attributes = [ 'id' => 'p'.$post->id, 'tabindex' => -1, - 'class' => 'relativelink' + 'class' => 'relativelink', ]; $output .= html_writer::start_tag('article', $attributes); } @@ -3616,7 +3616,7 @@ function hsuforum_rating_permissions($contextid, $component, $ratingarea) { 'view' => has_capability('mod/hsuforum:viewrating', $context), 'viewany' => has_capability('mod/hsuforum:viewanyrating', $context), 'viewall' => has_capability('mod/hsuforum:viewallratings', $context), - 'rate' => has_capability('mod/hsuforum:rate', $context) + 'rate' => has_capability('mod/hsuforum:rate', $context), ); } @@ -4503,7 +4503,7 @@ function hsuforum_verify_and_delete_post($course, $cm, $forum, $modcontext, $dis 'context' => $modcontext, 'other' => array( 'forumid' => $forum->id, - ) + ), ); $event = \mod_hsuforum\event\discussion_deleted::create($params); @@ -4532,7 +4532,7 @@ function hsuforum_verify_and_delete_post($course, $cm, $forum, $modcontext, $dis 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); if ($post->userid !== $USER->id) { @@ -4669,7 +4669,7 @@ function hsuforum_delete_post($post, $children, $course, $cm, $forum, $skipcompl 'discussionid' => $post->discussion, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); $post->deleted = 1; if ($post->userid !== $USER->id) { @@ -4703,7 +4703,7 @@ function hsuforum_trigger_content_uploaded_event($post, $cm, $name) { 'pathnamehashes' => array_keys($files), 'discussionid' => $post->discussion, 'triggeredfrom' => $name, - ) + ), ); $event = \mod_hsuforum\event\assessable_uploaded::create($params); $event->trigger(); @@ -5032,7 +5032,7 @@ function hsuforum_get_subscribe_link($forum, $context, $messages = array(), $can 'unsubscribed' => get_string('subscribe', 'hsuforum'), 'cantaccessgroup' => get_string('no'), 'forcesubscribed' => get_string('everyoneissubscribed', 'hsuforum'), - 'cantsubscribe' => get_string('disallowsubscribe','hsuforum') + 'cantsubscribe' => get_string('disallowsubscribe','hsuforum'), ); $messages = $messages + $defaultmessages; @@ -6002,7 +6002,7 @@ function hsuforum_get_recent_mod_activity(&$activities, &$index, $timestart, $co $tmpactivity->user = hsuforum_anonymize_user($tmpactivity->user, (object) array( 'id' => $post->forum, 'course' => $courseid, - 'anonymous' => $post->forumanonymous + 'anonymous' => $post->forumanonymous, ), $post); $activities[$index++] = $tmpactivity; @@ -6039,7 +6039,7 @@ function hsuforum_print_recent_mod_activity($activity, $courseid, $detail, $modn 'border' => '0', 'cellpadding' => '3', 'cellspacing' => '0', - 'class' => 'forum-recent' + 'class' => 'forum-recent', ]; $output = html_writer::start_tag('table', $tableoptions); $output .= html_writer::start_tag('tr'); @@ -6541,7 +6541,7 @@ function hsuforum_delete_read_records_for_forum($forumid) { */ function hsuforum_delete_read_records_for_discussion($discussionid) { global $DB; - return $DB->delete_records('hsuforum_read', array('discussionid' => $discussionid)); + return $DB->delete_records('hsuforum_read', array('discussionid' => $discussionid, )); } /** @@ -7060,7 +7060,7 @@ function hsuforum_get_grading_types(){ return array( HSUFORUM_GRADETYPE_NONE => get_string('gradetypenone', 'hsuforum'), HSUFORUM_GRADETYPE_MANUAL => get_string('gradetypemanual', 'hsuforum'), - HSUFORUM_GRADETYPE_RATING => get_string('gradetyperating', 'hsuforum') + HSUFORUM_GRADETYPE_RATING => get_string('gradetyperating', 'hsuforum'), ); } @@ -7513,7 +7513,7 @@ function hsuforum_page_type_list($pagetype, $parentcontext, $currentcontext) { $hsuforum_pagetype = array( 'mod-hsuforum-*'=>get_string('page-mod-hsuforum-x', 'hsuforum'), 'mod-hsuforum-view'=>get_string('page-mod-hsuforum-view', 'hsuforum'), - 'mod-hsuforum-discuss'=>get_string('page-mod-hsuforum-discuss', 'hsuforum') + 'mod-hsuforum-discuss'=>get_string('page-mod-hsuforum-discuss', 'hsuforum'), ); return $hsuforum_pagetype; } @@ -8015,7 +8015,7 @@ function hsuforum_anonymize_user($user, $forum, $post) { 'email' => $CFG->noreplyaddress, 'imagealt' => '', 'profilelink' => new moodle_url('/user/view.php', array('id'=>$guest->id, 'course'=>$forum->course)), - 'anonymous' => true + 'anonymous' => true, ); $anonymous->fullname = fullname($anonymous, true); $anonymous->imagealt = $anonymous->fullname; @@ -8514,7 +8514,7 @@ function hsuforum_str_empty($str) { 'param', 'source', 'track', - 'wbr' + 'wbr', ); foreach ($voidtags as $check) { if (stripos($str, $check) !== false) { @@ -8573,7 +8573,7 @@ function hsuforum_view($forum, $course, $cm, $context) { $params = array( 'context' => $context, - 'objectid' => $forum->id + 'objectid' => $forum->id, ); $event = \mod_hsuforum\event\course_module_viewed::create($params); @@ -8619,7 +8619,7 @@ function hsuforum_discussion_pin($modcontext, $forum, $discussion) { $params = array( 'context' => $modcontext, 'objectid' => $discussion->id, - 'other' => array('forumid' => $forum->id) + 'other' => array('forumid' => $forum->id), ); $event = \mod_hsuforum\event\discussion_pinned::create($params); @@ -8643,7 +8643,7 @@ function hsuforum_discussion_unpin($modcontext, $forum, $discussion) { $params = array( 'context' => $modcontext, 'objectid' => $discussion->id, - 'other' => array('forumid' => $forum->id) + 'other' => array('forumid' => $forum->id), ); $event = \mod_hsuforum\event\discussion_unpinned::create($params); diff --git a/lib/userselector/discussion/existing.php b/lib/userselector/discussion/existing.php index d05aff65..3a27c14b 100644 --- a/lib/userselector/discussion/existing.php +++ b/lib/userselector/discussion/existing.php @@ -39,7 +39,7 @@ public function get_filepath() { public function find_users($search) { return array( get_string("existingsubscribers", 'hsuforum') => - $this->get_repo()->get_subscribed_users($this->forum, $this->discussion, $this->context, $this->currentgroup, $this->required_fields_sql('u'), $this->search_sql($search, 'u')) + $this->get_repo()->get_subscribed_users($this->forum, $this->discussion, $this->context, $this->currentgroup, $this->required_fields_sql('u'), $this->search_sql($search, 'u')), ); } } diff --git a/lib/userselector/discussion/potential.php b/lib/userselector/discussion/potential.php index aad212e1..32c124c0 100644 --- a/lib/userselector/discussion/potential.php +++ b/lib/userselector/discussion/potential.php @@ -39,7 +39,7 @@ public function get_filepath() { public function find_users($search) { return array( get_string("potentialsubscribers", 'hsuforum') => - $this->get_repo()->get_unsubscribed_users($this->forum, $this->discussion, $this->context, $this->currentgroup, $this->required_fields_sql('u'), $this->search_sql($search, 'u')) + $this->get_repo()->get_unsubscribed_users($this->forum, $this->discussion, $this->context, $this->currentgroup, $this->required_fields_sql('u'), $this->search_sql($search, 'u')), ); } } diff --git a/locallib.php b/locallib.php index c5110f9c..39a5214d 100644 --- a/locallib.php +++ b/locallib.php @@ -163,7 +163,7 @@ function get_navigation() { $navlinks[] = array( 'name' => format_string($this->discussion->name), 'link' => $CFG->wwwroot . '/mod/hsuforum/discuss.php?d=' . $this->discussion->id, - 'type' => 'title' + 'type' => 'title', ); return array($navlinks, $this->cm); } @@ -652,19 +652,19 @@ function mod_hsuforum_get_tagged_posts($tag, $exclusivemode = false, $fromctx = $cm = $modinfo->get_cm($taggeditem->cmid); $forum = (object)['id' => $taggeditem->forum, 'course' => $taggeditem->courseid, - 'type' => $taggeditem->type + 'type' => $taggeditem->type, ]; $discussion = (object)['id' => $taggeditem->discussion, 'timestart' => $taggeditem->timestart, 'timeend' => $taggeditem->timeend, 'groupid' => $taggeditem->groupid, - 'firstpost' => $taggeditem->firstpost + 'firstpost' => $taggeditem->firstpost, ]; $post = (object)['id' => $taggeditem->id, 'parent' => $taggeditem->parent, 'userid' => $taggeditem->userid, 'groupid' => $taggeditem->groupid, - 'privatereply' => 0 + 'privatereply' => 0, ]; $accessible = hsuforum_user_can_see_post($forum, $discussion, $post, null, $cm); diff --git a/mod_form.php b/mod_form.php index bcef8ac6..c490a429 100644 --- a/mod_form.php +++ b/mod_form.php @@ -119,7 +119,7 @@ function definition() { 10 => 10, 20 => 20, 50 => 50, - 100 => 100 + 100 => 100, ); $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'hsuforum'), $choices); $mform->addHelpButton('maxattachments', 'maxattachments', 'hsuforum'); diff --git a/post.php b/post.php index ed18b3c5..8a90090b 100644 --- a/post.php +++ b/post.php @@ -444,7 +444,7 @@ 'objectid' => $discussion->id, 'other' => array( 'forumid' => $forum->id, - ) + ), ); $event = \mod_hsuforum\event\discussion_updated::create($params); $event->trigger(); @@ -454,7 +454,7 @@ 'objectid' => $newid, 'other' => array( 'forumid' => $forum->id, - ) + ), ); $event = \mod_hsuforum\event\discussion_created::create($params); $event->trigger(); @@ -466,7 +466,7 @@ 'discussionid' => $newid, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); $event = \mod_hsuforum\event\post_updated::create($params); $event->add_record_snapshot('hsuforum_discussions', $discussion); @@ -615,7 +615,7 @@ 'message'=>array( 'text'=>$currenttext, 'format'=>empty($post->messageformat) ? editors_get_preferred_format() : $post->messageformat, - 'itemid'=>$draftideditor + 'itemid'=>$draftideditor, ), 'subscribe'=>$subscribe?1:0, 'mailnow'=>!empty($post->mailnow), @@ -624,7 +624,7 @@ 'reveal'=>$post->reveal, 'privatereply'=>$post->privatereply, 'discussion'=>$post->discussion, - 'course'=>$course->id + 'course'=>$course->id, ) + $pageparams + @@ -751,7 +751,7 @@ 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); if ($realpost->userid !== $USER->id) { @@ -804,7 +804,7 @@ 'discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type, - ) + ), ); $event = \mod_hsuforum\event\post_created::create($params); $event->add_record_snapshot('hsuforum_posts', $post); @@ -904,7 +904,7 @@ 'objectid' => $discussion->id, 'other' => array( 'forumid' => $forum->id, - ) + ), ); $event = \mod_hsuforum\event\discussion_created::create($params); $event->add_record_snapshot('hsuforum_discussions', $discussion); diff --git a/renderer.php b/renderer.php index fae6be1b..b6f5e663 100644 --- a/renderer.php +++ b/renderer.php @@ -759,7 +759,7 @@ public function post_template($p) { $byline = get_string('postbyxinreplytox', 'hsuforum', array( 'parent' => $p->parentuserpic.$parent, 'author' => $byuser, - 'parentpost' => "".get_string('parentofthispost', 'hsuforum')."" + 'parentpost' => "".get_string('parentofthispost', 'hsuforum')."", )); } if (!empty($p->privatereply)) { @@ -768,7 +768,7 @@ public function post_template($p) { } else { $byline = get_string('postbyxinprivatereplytox', 'hsuforum', array( 'author' => $byuser, - 'parent' => $p->parentuserpic.$parent + 'parent' => $p->parentuserpic.$parent, )); } } @@ -1006,9 +1006,9 @@ public function get_js_module() { array('toggled:bookmark', 'hsuforum'), array('toggled:subscribe', 'hsuforum'), array('toggled:substantive', 'hsuforum'), - array('addareply', 'hsuforum') + array('addareply', 'hsuforum'), - ) + ), ); } @@ -1067,7 +1067,7 @@ public function post_get_flags($post, $cm, $discussion, $reply = false) { 'returnurl' => $returnurl, 'postid' => $post->id, 'flag' => $flag, - 'sesskey' => sesskey() + 'sesskey' => sesskey(), )); // Create appropriate area described by. @@ -1395,7 +1395,7 @@ public function user_posts_overview($userid, $cm, $showonlypreference = null) { $counts = array( get_string('totalpostsanddiscussions', 'hsuforum', ($discussioncount+$postcount)), get_string('totaldiscussions', 'hsuforum', $discussioncount), - get_string('totalreplies', 'hsuforum', $postcount) + get_string('totalreplies', 'hsuforum', $postcount), ); if (!empty($config->showsubstantive)) { diff --git a/search.php b/search.php index d91dbf1d..fb29ab1b 100644 --- a/search.php +++ b/search.php @@ -124,7 +124,7 @@ $params = array( 'context' => $PAGE->context, - 'other' => array('searchterm' => $search) + 'other' => array('searchterm' => $search), ); $event = \mod_hsuforum\event\course_searched::create($params); @@ -211,7 +211,7 @@ 'notwords' => $notwords, 'dateto' => $dateto, 'datefrom' => $datefrom, - 'showform' => 1 + 'showform' => 1, ]; $url = new moodle_url("/mod/hsuforum/search.php", $params); foreach ($tags as $tag) { diff --git a/settings.php b/settings.php index 8937b369..d01b7237 100644 --- a/settings.php +++ b/settings.php @@ -66,7 +66,7 @@ 10 => 10, 20 => 20, 50 => 50, - 100 => 100 + 100 => 100, ); $settings->add(new admin_setting_configselect('hsuforum/maxattachments', get_string('maxattachments', 'hsuforum'), get_string('configmaxattachments', 'hsuforum'), 9, $options)); @@ -107,7 +107,7 @@ $options = array( 0 => get_string('none'), 1 => get_string('discussions', 'hsuforum'), - 2 => get_string('posts', 'hsuforum') + 2 => get_string('posts', 'hsuforum'), ); $settings->add(new admin_setting_configselect('hsuforum_rsstype', get_string('rsstypedefault', 'hsuforum'), get_string('configrsstypedefault', 'hsuforum'), 0, $options)); @@ -125,7 +125,7 @@ 25 => '25', 30 => '30', 40 => '40', - 50 => '50' + 50 => '50', ); $settings->add(new admin_setting_configselect('hsuforum_rssarticles', get_string('rssarticles', 'hsuforum'), get_string('configrssarticlesdefault', 'hsuforum'), 0, $options)); diff --git a/tests/custom_completion_test.php b/tests/custom_completion_test.php index 4d4be0de..458638cf 100644 --- a/tests/custom_completion_test.php +++ b/tests/custom_completion_test.php @@ -58,34 +58,34 @@ class custom_completion_test extends advanced_testcase { public function get_state_provider(): array { return [ 'Undefined rule' => [ - 'somenonexistentrule', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, coding_exception::class + 'somenonexistentrule', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, coding_exception::class, ], 'Completion discussions rule not available' => [ - 'completiondiscussions', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, moodle_exception::class + 'completiondiscussions', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, moodle_exception::class, ], 'Completion discussions rule available, user has not created discussion' => [ - 'completiondiscussions', 0, COMPLETION_TRACKING_AUTOMATIC, 5, 0, 0, COMPLETION_INCOMPLETE, null + 'completiondiscussions', 0, COMPLETION_TRACKING_AUTOMATIC, 5, 0, 0, COMPLETION_INCOMPLETE, null, ], 'Rule available, user has created discussions' => [ - 'completiondiscussions', 5, COMPLETION_TRACKING_AUTOMATIC, 5, 0, 0, COMPLETION_COMPLETE, null + 'completiondiscussions', 5, COMPLETION_TRACKING_AUTOMATIC, 5, 0, 0, COMPLETION_COMPLETE, null, ], 'Completion replies rule not available' => [ - 'completionreplies', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, moodle_exception::class + 'completionreplies', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, moodle_exception::class, ], 'Rule available, user has not replied' => [ - 'completionreplies', 0, COMPLETION_TRACKING_AUTOMATIC, 0, 5, 0, COMPLETION_INCOMPLETE, null + 'completionreplies', 0, COMPLETION_TRACKING_AUTOMATIC, 0, 5, 0, COMPLETION_INCOMPLETE, null, ], 'Rule available, user has created replied' => [ - 'completionreplies', 5, COMPLETION_TRACKING_AUTOMATIC, 0, 5, 0, COMPLETION_COMPLETE, null + 'completionreplies', 5, COMPLETION_TRACKING_AUTOMATIC, 0, 5, 0, COMPLETION_COMPLETE, null, ], 'Completion posts rule not available' => [ - 'completionposts', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, moodle_exception::class + 'completionposts', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, moodle_exception::class, ], 'Rule available, user has not posted' => [ - 'completionposts', 0, COMPLETION_TRACKING_AUTOMATIC, 0, 0, 5, COMPLETION_INCOMPLETE, null + 'completionposts', 0, COMPLETION_TRACKING_AUTOMATIC, 0, 0, 5, COMPLETION_INCOMPLETE, null, ], 'Rule available, user has posted' => [ - 'completionposts', 5, COMPLETION_TRACKING_AUTOMATIC, 0, 0, 5, COMPLETION_COMPLETE, null + 'completionposts', 5, COMPLETION_TRACKING_AUTOMATIC, 0, 0, 5, COMPLETION_COMPLETE, null, ], ]; } @@ -122,7 +122,7 @@ public function test_get_state(string $rule, int $rulecount, int $available, ?in 'completion' => $available, 'completiondiscussions' => $discussions, 'completionreplies' => $replies, - 'completionposts' => $posts + 'completionposts' => $posts, ]; $hsuforum = $this->getDataGenerator()->create_module('hsuforum', $params); @@ -217,22 +217,22 @@ public function test_is_defined() { public function get_available_custom_rules_provider(): array { return [ 'Completion discussions available' => [ - COMPLETION_ENABLED, ['completiondiscussions'] + COMPLETION_ENABLED, ['completiondiscussions'], ], 'Completion discussions not available' => [ - COMPLETION_DISABLED, [] + COMPLETION_DISABLED, [], ], 'Completion replies available' => [ - COMPLETION_ENABLED, ['completionreplies'] + COMPLETION_ENABLED, ['completionreplies'], ], 'Completion replies not available' => [ - COMPLETION_DISABLED, [] + COMPLETION_DISABLED, [], ], 'Completion posts available' => [ - COMPLETION_ENABLED, ['completionposts'] + COMPLETION_ENABLED, ['completionposts'], ], 'Completion posts not available' => [ - COMPLETION_DISABLED, [] + COMPLETION_DISABLED, [], ], ]; } @@ -246,12 +246,12 @@ public function get_available_custom_rules_provider(): array { */ public function test_get_available_custom_rules(int $status, array $expected) { $customdataval = [ - 'customcompletionrules' => [] + 'customcompletionrules' => [], ]; if ($status == COMPLETION_ENABLED) { $rule = $expected[0]; $customdataval = [ - 'customcompletionrules' => [$rule => $status] + 'customcompletionrules' => [$rule => $status], ]; } diff --git a/tests/events_test.php b/tests/events_test.php index b3520e55..ab695733 100644 --- a/tests/events_test.php +++ b/tests/events_test.php @@ -354,7 +354,7 @@ public function test_discussion_moved_fromforumid_validation() { $params = array( 'context' => $context, - 'other' => array('toforumid' => $toforum->id) + 'other' => array('toforumid' => $toforum->id), ); $this->expectException(coding_exception::class); @@ -373,7 +373,7 @@ public function test_discussion_moved_toforumid_validation() { $params = array( 'context' => $context, - 'other' => array('fromforumid' => $fromforum->id) + 'other' => array('fromforumid' => $fromforum->id), ); $this->expectException(coding_exception::class); @@ -400,7 +400,7 @@ public function test_discussion_moved_context_validation() { $params = array( 'context' => context_system::instance(), 'objectid' => $discussion->id, - 'other' => array('fromforumid' => $fromforum->id, 'toforumid' => $toforum->id) + 'other' => array('fromforumid' => $fromforum->id, 'toforumid' => $toforum->id), ); $this->expectException(coding_exception::class); @@ -430,7 +430,7 @@ public function test_discussion_moved() { $params = array( 'context' => $context, 'objectid' => $discussion->id, - 'other' => array('fromforumid' => $fromforum->id, 'toforumid' => $toforum->id) + 'other' => array('fromforumid' => $fromforum->id, 'toforumid' => $toforum->id), ); $event = \mod_hsuforum\event\discussion_moved::create($params); @@ -1130,7 +1130,7 @@ public function test_post_created_postid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), - 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type, 'discussionid' => $discussion->id) + 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type, 'discussionid' => $discussion->id), ); \mod_hsuforum\event\post_created::create($params); @@ -1160,7 +1160,7 @@ public function test_post_created_discussionid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1192,7 +1192,7 @@ public function test_post_created_forumid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1224,7 +1224,7 @@ public function test_post_created_forumtype_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id), ); $this->expectException(coding_exception::class); @@ -1256,7 +1256,7 @@ public function test_post_created_context_validation() { $params = array( 'context' => context_system::instance(), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1291,7 +1291,7 @@ public function test_post_created() { $params = array( 'context' => $context, 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $event = \mod_hsuforum\event\post_created::create($params); @@ -1344,7 +1344,7 @@ public function test_post_created_single() { $params = array( 'context' => $context, 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $event = \mod_hsuforum\event\post_created::create($params); @@ -1387,7 +1387,7 @@ public function test_post_deleted_postid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), - 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type, 'discussionid' => $discussion->id) + 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type, 'discussionid' => $discussion->id), ); \mod_hsuforum\event\post_deleted::create($params); @@ -1417,7 +1417,7 @@ public function test_post_deleted_discussionid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1449,7 +1449,7 @@ public function test_post_deleted_forumid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1481,7 +1481,7 @@ public function test_post_deleted_forumtype_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id), ); $this->expectException(coding_exception::class); @@ -1513,7 +1513,7 @@ public function test_post_deleted_context_validation() { $params = array( 'context' => context_system::instance(), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1624,7 +1624,7 @@ public function test_post_deleted_single() { $params = array( 'context' => $context, 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $event = \mod_hsuforum\event\post_deleted::create($params); @@ -1672,7 +1672,7 @@ public function test_post_updated_discussionid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1704,7 +1704,7 @@ public function test_post_updated_forumid_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1736,7 +1736,7 @@ public function test_post_updated_forumtype_validation() { $params = array( 'context' => context_module::instance($forum->cmid), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id), ); $this->expectException(coding_exception::class); @@ -1768,7 +1768,7 @@ public function test_post_updated_context_validation() { $params = array( 'context' => context_system::instance(), 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $this->expectException(coding_exception::class); @@ -1803,7 +1803,7 @@ public function test_post_updated() { $params = array( 'context' => $context, 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $event = \mod_hsuforum\event\post_updated::create($params); @@ -1856,7 +1856,7 @@ public function test_post_updated_single() { $params = array( 'context' => $context, 'objectid' => $post->id, - 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) + 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type), ); $event = \mod_hsuforum\event\post_updated::create($params); @@ -1902,7 +1902,7 @@ public function test_observers() { // them just in case there are APIs changes in future. $user = $this->getDataGenerator()->create_user(array( 'maildigest' => 1, - 'trackforums' => 1 + 'trackforums' => 1, )); $manplugin = enrol_get_plugin('manual'); diff --git a/tests/externallib_test.php b/tests/externallib_test.php index a19fe16a..f77aac4d 100644 --- a/tests/externallib_test.php +++ b/tests/externallib_test.php @@ -294,7 +294,7 @@ public function test_mod_hsuforum_get_forum_discussion_posts() { 'timemodified' => $timepost, 'mimetype' => 'image/jpeg', 'isexternalfile' => false, - ) + ), ), 'totalscore' => $discussion1reply1->totalscore, 'mailnow' => $discussion1reply1->mailnow, @@ -303,7 +303,7 @@ public function test_mod_hsuforum_get_forum_discussion_posts() { 'postread' => false, 'userfullname' => fullname($user2), 'userpictureurl' => '', - 'deleted' => false + 'deleted' => false, ); $expectedposts['posts'][] = array( 'id' => $discussion1reply2->id, @@ -326,7 +326,7 @@ public function test_mod_hsuforum_get_forum_discussion_posts() { 'postread' => false, 'userfullname' => fullname($user3), 'userpictureurl' => '', - 'deleted' => false + 'deleted' => false, ); // Test a discussion with two additional posts (total 3 posts). @@ -576,7 +576,7 @@ public function test_mod_hsuforum_get_forum_discussions_paginated() { $discussions = external_api::clean_returnvalue(mod_hsuforum_external::get_forum_discussions_paginated_returns(), $discussions); $expectedreturn = array( 'discussions' => array($expecteddiscussions), - 'warnings' => array() + 'warnings' => array(), ); // Wait the theme to be loaded (the external_api call does that) to generate the user profiles. diff --git a/tests/form_service_test.php b/tests/form_service_test.php index f652cfe8..6b8b1587 100644 --- a/tests/form_service_test.php +++ b/tests/form_service_test.php @@ -79,13 +79,13 @@ public function test_prepare_draft_area() { 'filearea' => 'draft', 'itemid' => $draftid, 'filepath' => '/', - 'filename' => '' + 'filename' => '', ); // Create some files. $imagefiles = array( 'testgif_small.gif', - 'testgif2_small.gif' + 'testgif2_small.gif', ); // Add files to draft area and make sure they exist! diff --git a/tests/generator/lib.php b/tests/generator/lib.php index f6b849ec..6f0099bf 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -347,7 +347,7 @@ public function create_content($instance, $record = array()) { $record = (array)$record + array( 'forum' => $instance->id, 'userid' => $USER->id, - 'course' => $instance->course + 'course' => $instance->course, ); if (empty($record['discussion']) && empty($record['parent'])) { // Create discussion. diff --git a/tests/lib_test.php b/tests/lib_test.php index d64d9f13..c8d3abe7 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -54,7 +54,7 @@ public function test_hsuforum_trigger_content_uploaded_event() { 'filearea' => 'attachment', 'itemid' => $fakepost->id, 'filepath' => '/', - 'filename' => 'myassignmnent.pdf' + 'filename' => 'myassignmnent.pdf', ); $fi = $fs->create_file_from_string($dummy, 'Content of ' . $dummy->filename); @@ -2733,7 +2733,7 @@ public function test_function_validate_files(){ 'filearea' => 'attachment', 'itemid' => $post->id, 'filepath' => '/', - 'filename' => 'testgif_small.gif' + 'filename' => 'testgif_small.gif', ); $file = (array) $fs->create_file_from_pathname($filerecord, $path); @@ -2744,7 +2744,7 @@ public function test_function_validate_files(){ 'attachment' => array( 'name' => $filerecord['filename'], 'tmp_name' => $path, - 'error' => 0 + 'error' => 0, )); // Get Context @@ -2764,7 +2764,7 @@ public function test_function_validate_files(){ // Define the expected exception with its error message $params = array( 'file' => '\'' . $filerecord['filename'] . '\'', - 'size' => '10B' + 'size' => '10B', ); $errormessage = get_string('maxbytesfile', 'error', $params); $this->expectException('file_exception'); @@ -2888,7 +2888,7 @@ public function hsuforum_get_unmailed_posts_provider() { 'discussion' => [ 'timecreated' => - WEEKSECS, 'timestart' => - DAYSECS, - 'timeend' => + DAYSECS + 'timeend' => + DAYSECS, ], 'timedposts' => true, 'postcount' => 1, @@ -2907,7 +2907,7 @@ public function hsuforum_get_unmailed_posts_provider() { 'Timed discussion; Single post; Posted 1 week ago; timeend not reached' => [ 'discussion' => [ 'timecreated' => - WEEKSECS, - 'timeend' => + DAYSECS + 'timeend' => + DAYSECS, ], 'timedposts' => true, 'postcount' => 0, @@ -3028,37 +3028,37 @@ public function hsuforum_discussion_is_locked_provider() { 'Unlocked: lockdiscussionafter is unset' => [ (object) [], (object) [], - false + false, ], 'Unlocked: lockdiscussionafter is false' => [ (object) ['lockdiscussionafter' => false], (object) [], - false + false, ], 'Unlocked: lockdiscussionafter is null' => [ (object) ['lockdiscussionafter' => null], (object) [], - false + false, ], 'Unlocked: lockdiscussionafter is set; forum is of type single; post is recent' => [ (object) ['lockdiscussionafter' => DAYSECS, 'type' => 'single'], (object) ['timemodified' => time()], - false + false, ], 'Unlocked: lockdiscussionafter is set; forum is of type single; post is old' => [ (object) ['lockdiscussionafter' => MINSECS, 'type' => 'single'], (object) ['timemodified' => time() - DAYSECS], - false + false, ], 'Unlocked: lockdiscussionafter is set; forum is of type eachuser; post is recent' => [ (object) ['lockdiscussionafter' => DAYSECS, 'type' => 'eachuser'], (object) ['timemodified' => time()], - false + false, ], 'Locked: lockdiscussionafter is set; forum is of type eachuser; post is old' => [ (object) ['lockdiscussionafter' => MINSECS, 'type' => 'eachuser'], (object) ['timemodified' => time() - DAYSECS], - true + true, ], ]; } @@ -3487,14 +3487,14 @@ public function test_mod_hsuforum_completion_get_active_rule_descriptions() { 'completion' => 2, 'completiondiscussions' => 3, 'completionreplies' => 3, - 'completionposts' => 3 + 'completionposts' => 3, ]); $forum2 = $this->getDataGenerator()->create_module('hsuforum', [ 'course' => $course->id, 'completion' => 2, 'completiondiscussions' => 0, 'completionreplies' => 0, - 'completionposts' => 0 + 'completionposts' => 0, ]); $cm1 = cm_info::create(get_coursemodule_from_instance('hsuforum', $forum1->id)); $cm2 = cm_info::create(get_coursemodule_from_instance('hsuforum', $forum2->id)); @@ -3506,14 +3506,14 @@ public function test_mod_hsuforum_completion_get_active_rule_descriptions() { $moddefaults->customdata = ['customcompletionrules' => [ 'completiondiscussions' => 3, 'completionreplies' => 3, - 'completionposts' => 3 + 'completionposts' => 3, ]]; $moddefaults->completion = 2; $activeruledescriptions = [ get_string('completiondiscussionsdesc', 'hsuforum', 3), get_string('completionrepliesdesc', 'hsuforum', 3), - get_string('completionpostsdesc', 'hsuforum', 3) + get_string('completionpostsdesc', 'hsuforum', 3), ]; $this->assertEquals(mod_hsuforum_get_completion_active_rule_descriptions($cm1), $activeruledescriptions); $this->assertEquals(mod_hsuforum_get_completion_active_rule_descriptions($cm2), []); diff --git a/tests/mail_test.php b/tests/mail_test.php index 58ca3598..280ddda6 100644 --- a/tests/mail_test.php +++ b/tests/mail_test.php @@ -980,7 +980,7 @@ public function forum_post_email_templates_provider() { 'attachments' => array( array( 'filename' => 'example.txt', - 'filecontents' => 'Basic information about the course' + 'filecontents' => 'Basic information about the course', ), ), ), @@ -995,7 +995,7 @@ public function forum_post_email_templates_provider() { '~&(amp|lt|gt|quot|\#039);(?!course)', 'Attachments example.txt:\r\n' . $CFG->wwwroot.'/pluginfile.php/\d*/mod_hsuforum/attachment/\d*/example.txt\r\n', - 'Hello Moodle', 'Moodle Forum', 'Welcome.*Moodle', 'Love Moodle', '1\d1' + 'Hello Moodle', 'Moodle Forum', 'Welcome.*Moodle', 'Love Moodle', '1\d1', ), ), ), @@ -1173,7 +1173,7 @@ public function test_forum_post_email_templates($data) { 'filearea' => 'attachment', 'itemid' => $post->id, 'filepath' => '/', - 'filename' => $attachment['filename'] + 'filename' => $attachment['filename'], ); $fs->create_file_from_string($filerecord, $attachment['filecontents']); } diff --git a/tests/portfolio_caller_test.php b/tests/portfolio_caller_test.php index f3eb52c1..a45dba74 100644 --- a/tests/portfolio_caller_test.php +++ b/tests/portfolio_caller_test.php @@ -53,7 +53,7 @@ public function test_file_in_user_post_is_loaded() { 'course' => $course->id, 'forum' => $forum->id, 'userid' => $user->id, - 'attachment' => 1 + 'attachment' => 1, ) ); @@ -64,13 +64,13 @@ public function test_file_in_user_post_is_loaded() { 'filearea' => 'attachment', 'itemid' => $discussion->firstpost, 'filepath' => '/', - 'filename' => 'myassignmnent.pdf' + 'filename' => 'myassignmnent.pdf', ); $firstpostfile = $fs->create_file_from_string($dummy, 'Content of '.$dummy->filename); $caller = new hsuforum_portfolio_caller(array( 'postid' => $discussion->firstpost, - 'attachment' => $firstpostfile->get_id() + 'attachment' => $firstpostfile->get_id(), )); $caller->load_data(); @@ -98,7 +98,7 @@ public function test_file_not_in_user_post_not_loaded() { 'course' => $course->id, 'forum' => $forum->id, 'userid' => $user->id, - 'attachment' => 1 + 'attachment' => 1, ) ); @@ -109,7 +109,7 @@ public function test_file_not_in_user_post_not_loaded() { 'filearea' => 'attachment', 'itemid' => $discussion->firstpost, 'filepath' => '/', - 'filename' => 'myassignmnent.pdf' + 'filename' => 'myassignmnent.pdf', ); $firstpostfile = $fs->create_file_from_string($dummyone, 'Content of '.$dummyone->filename); @@ -118,7 +118,7 @@ public function test_file_not_in_user_post_not_loaded() { array( 'discussion' => $discussion->id, 'userid' => $user->id, - 'attachment' => 1 + 'attachment' => 1, ) ); $dummytwo = (object) array( @@ -127,13 +127,13 @@ public function test_file_not_in_user_post_not_loaded() { 'filearea' => 'attachment', 'itemid' => $secondpost->id, 'filepath' => '/', - 'filename' => 'myotherthing.pdf' + 'filename' => 'myotherthing.pdf', ); $secondpostfile = $fs->create_file_from_string($dummytwo, 'Content of '.$dummytwo->filename); $caller = new hsuforum_portfolio_caller(array( 'postid' => $discussion->firstpost, - 'attachment' => $secondpostfile->get_id() + 'attachment' => $secondpostfile->get_id(), )); $this->expectExceptionMessage('Sorry, the requested file could not be found'); diff --git a/tests/search_test.php b/tests/search_test.php index 6e0baec2..caf7f327 100644 --- a/tests/search_test.php +++ b/tests/search_test.php @@ -402,7 +402,7 @@ public function test_attach_files() { 'filearea' => 'attachment', 'itemid' => $post->id, 'filepath' => '/', - 'filename' => 'myfile1' + 'filename' => 'myfile1', ); $file1 = $fs->create_file_from_string($filerecord, 'Some contents 1'); $filerecord['filename'] = 'myfile2'; @@ -514,7 +514,7 @@ public function test_posts_get_contexts_to_reindex() { $expected = [ \context_module::instance($forum2->cmid), \context_module::instance($forum3->cmid), - \context_module::instance($forum1->cmid) + \context_module::instance($forum1->cmid), ]; $this->assertEquals($expected, $contexts); } diff --git a/user.php b/user.php index e42a94a1..4691408d 100644 --- a/user.php +++ b/user.php @@ -230,7 +230,7 @@ $userheading = array( 'heading' => fullname($user), 'user' => $user, - 'usercontext' => $usercontext + 'usercontext' => $usercontext, ); echo $OUTPUT->context_header($userheading, 2); } @@ -387,7 +387,7 @@ $userheading = array( 'heading' => fullname($user), 'user' => $user, - 'usercontext' => $usercontext + 'usercontext' => $usercontext, ); echo $OUTPUT->context_header($userheading, 2); } else { From 23e85da01a347cf7e885323fdd2d12dafe4ca524 Mon Sep 17 00:00:00 2001 From: JuanPablo-Openlms Date: Thu, 4 Jan 2024 09:15:59 -0500 Subject: [PATCH 3/4] Fixed syntax error with the 'and' operator. --- classes/controller/kernel.php | 2 +- classes/message/inbound/reply_handler.php | 2 +- classes/post_form.php | 4 +- classes/service/form_service.php | 6 +- classes/service/post_service.php | 2 +- discuss.php | 12 ++-- index.php | 6 +- lib.php | 70 +++++++++++------------ mod_form.php | 6 +- post.php | 12 ++-- renderer.php | 14 ++--- subscribe.php | 4 +- tests/mail_test.php | 2 +- unsubscribeall.php | 2 +- view.php | 2 +- 15 files changed, 73 insertions(+), 73 deletions(-) diff --git a/classes/controller/kernel.php b/classes/controller/kernel.php index ec75c66c..ce1cf9a1 100644 --- a/classes/controller/kernel.php +++ b/classes/controller/kernel.php @@ -125,7 +125,7 @@ public function generate_response($callback) { $buffer = trim(ob_get_contents()); ob_end_clean(); - if (!empty($response) and !empty($buffer)) { + if (!empty($response) && !empty($buffer)) { throw new \coding_exception('Mixed return output and buffer output', "Buffer: $buffer"); } else if (!empty($buffer)) { $response = $buffer; diff --git a/classes/message/inbound/reply_handler.php b/classes/message/inbound/reply_handler.php index 3df02036..1a712a93 100644 --- a/classes/message/inbound/reply_handler.php +++ b/classes/message/inbound/reply_handler.php @@ -103,7 +103,7 @@ public function process_message(\stdClass $record, \stdClass $messagedata) { } else { $groupmode = $course->groupmode; } - if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $modcontext)) { + if ($groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $modcontext)) { if ($discussion->groupid == -1) { $canpost = false; } else { diff --git a/classes/post_form.php b/classes/post_form.php index 30806ba4..69beb6e9 100644 --- a/classes/post_form.php +++ b/classes/post_form.php @@ -149,7 +149,7 @@ function definition() { $mform->addHelpButton('pinned', 'discussionpinned', 'hsuforum'); } - if (!empty($forum->anonymous) and $post->userid == $USER->id and has_capability('mod/hsuforum:revealpost', $modcontext)) { + if (!empty($forum->anonymous) && $post->userid == $USER->id && has_capability('mod/hsuforum:revealpost', $modcontext)) { $mform->addElement('advcheckbox', 'reveal', get_string('reveal', 'hsuforum')); $mform->addHelpButton('reveal', 'reveal', 'hsuforum'); } @@ -158,7 +158,7 @@ function definition() { $mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'hsuforum')); } - if (!empty($forum->allowprivatereplies) and !empty($post->parent) and has_capability('mod/hsuforum:allowprivate', $modcontext)) { + if (!empty($forum->allowprivatereplies) && !empty($post->parent) && has_capability('mod/hsuforum:allowprivate', $modcontext)) { if ($post->userid != $USER->id) { $mform->addElement('hidden', 'privatereply', 0); $mform->setType('privatereply', PARAM_INT); diff --git a/classes/service/form_service.php b/classes/service/form_service.php index f1f927b7..229fbc46 100644 --- a/classes/service/form_service.php +++ b/classes/service/form_service.php @@ -88,14 +88,14 @@ protected function file_prepare_draft_area(&$draftitemid, $contextid, $component $draftitemid = file_get_unused_draft_itemid(); } $file_record = array('contextid'=>$usercontext->id, 'component'=>'user', 'filearea'=>'draft', 'itemid'=>$draftitemid); - if (!is_null($itemid) and $files = $fs->get_area_files($contextid, $component, $filearea, $itemid)) { + if (!is_null($itemid) && $files = $fs->get_area_files($contextid, $component, $filearea, $itemid)) { foreach ($files as $file) { - if ($file->is_directory() and $file->get_filepath() === '/') { + if ($file->is_directory() && $file->get_filepath() === '/') { // we need a way to mark the age of each draft area, // by not copying the root dir we force it to be created automatically with current timestamp continue; } - if (!$options['subdirs'] and ($file->is_directory() or $file->get_filepath() !== '/')) { + if (!$options['subdirs'] && ($file->is_directory() or $file->get_filepath() !== '/')) { continue; } diff --git a/classes/service/post_service.php b/classes/service/post_service.php index b362809f..e3ae4182 100644 --- a/classes/service/post_service.php +++ b/classes/service/post_service.php @@ -193,7 +193,7 @@ public function require_can_edit_post($forum, \context_module $context, $discuss global $CFG, $USER; if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) { - if (((time() - $post->created) > $CFG->maxeditingtime) and + if (((time() - $post->created) > $CFG->maxeditingtime) && !has_capability('mod/hsuforum:editanypost', $context) ) { throw new \moodle_exception('maxtimehaspassed', 'hsuforum', '', format_time($CFG->maxeditingtime)); diff --git a/discuss.php b/discuss.php index 326289dd..ea9162fc 100644 --- a/discuss.php +++ b/discuss.php @@ -98,7 +98,7 @@ } /// move discussion if requested - if ($move > 0 and confirm_sesskey()) { + if ($move > 0 && confirm_sesskey()) { $return = $CFG->wwwroot.'/mod/hsuforum/discuss.php?d='.$discussion->id; require_capability('mod/hsuforum:movediscussions', $modcontext); @@ -236,11 +236,11 @@ /// Also, if we know they should be able to reply, then explicitly set $canreply for performance reasons $canreply = hsuforum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext); - if (!$canreply and $forum->type !== 'news') { + if (!$canreply && $forum->type !== 'news') { if (isguestuser() or !isloggedin()) { $canreply = true; } - if (!is_enrolled($modcontext) and !is_viewing($modcontext)) { + if (!is_enrolled($modcontext) && !is_viewing($modcontext)) { // allow guests and not-logged-in to see the link - they are prompted to log in after clicking the link // normal users with temporary guest access see this link too, they are asked to enrol instead $canreply = enrol_selfenrol_available($course->id); @@ -249,7 +249,7 @@ // Print Notice of Warning if Moving this Discussion - if ($move > 0 and confirm_sesskey()) { + if ($move > 0 && confirm_sesskey()) { echo $OUTPUT->confirm( get_string('anonymouswarning', 'hsuforum'), new moodle_url('/mod/hsuforum/discuss.php', array('d' => $discussion->id, 'move' => $move, 'warned' => 1)), @@ -274,7 +274,7 @@ echo $OUTPUT->notification(get_string('qandanotify', 'hsuforum')); } - if ($move == -1 and confirm_sesskey()) { + if ($move == -1 && confirm_sesskey()) { echo $OUTPUT->notification(get_string('discussionmoved', 'hsuforum', format_string($forum->name,true)), 'success'); } @@ -319,7 +319,7 @@ } $forumidcompare = $forumcm->instance != $forum->id; $forumtypecheck = $forumcheck[$forumcm->instance]->type !== 'single'; - if ($forumidcompare and $forumtypecheck) { + if ($forumidcompare && $forumtypecheck) { $url = "/mod/hsuforum/discuss.php?d=$discussion->id&move=$forumcm->instance&sesskey=".sesskey(); $forummenu[$section][$sectionname][$url] = format_string($forumcm->name); } diff --git a/index.php b/index.php index d691c8e4..fcd9b3b3 100644 --- a/index.php +++ b/index.php @@ -173,7 +173,7 @@ } /// Do course wide subscribe/unsubscribe -if (!is_null($subscribe) and !isguestuser()) { +if (!is_null($subscribe) && !isguestuser()) { foreach ($modinfo->get_instances_of('hsuforum') as $forumid=>$cm) { $forum = $forums[$forumid]; $modcontext = context_module::instance($cm->id); @@ -249,7 +249,7 @@ // If this forum has RSS activated, calculate it. if ($show_rss) { - if ($forum->rsstype and $forum->rssarticles) { + if ($forum->rsstype && $forum->rssarticles) { //Calculate the tooltip text if ($forum->rsstype == 1) { $tooltiptext = get_string('rsssubscriberssdiscussions', 'hsuforum'); @@ -360,7 +360,7 @@ //If this forum has RSS activated, calculate it if ($show_rss) { - if ($forum->rsstype and $forum->rssarticles) { + if ($forum->rsstype && $forum->rssarticles) { //Calculate the tolltip text if ($forum->rsstype == 1) { $tooltiptext = get_string('rsssubscriberssdiscussions', 'hsuforum'); diff --git a/lib.php b/lib.php index d8d8ce1f..a5bc345b 100644 --- a/lib.php +++ b/lib.php @@ -127,7 +127,7 @@ function hsuforum_add_instance($forum, $mform = null) { $discussion->id = hsuforum_add_discussion($discussion, null, $message); - if ($mform and $draftid = file_get_submitted_draft_itemid('introeditor')) { + if ($mform && $draftid = file_get_submitted_draft_itemid('introeditor')) { // Ugly hack - we need to copy the files somehow. $discussion = $DB->get_record('hsuforum_discussions', array('id'=>$discussion->id), '*', MUST_EXIST); $post = $DB->get_record('hsuforum_posts', array('id'=>$discussion->firstpost), '*', MUST_EXIST); @@ -247,7 +247,7 @@ function hsuforum_update_instance($forum, $mform) { $post->modified = $forum->timemodified; $post->userid = $USER->id; // MDL-18599, so that current teacher can take ownership of activities. - if ($mform and $draftid = file_get_submitted_draft_itemid('introeditor')) { + if ($mform && $draftid = file_get_submitted_draft_itemid('introeditor')) { // Ugly hack - we need to copy the files somehow. $options = array('subdirs'=>true); // Use the same options as intro field! $post->message = file_save_draft_area_files($draftid, $modcontext->id, 'mod_hsuforum', 'post', $post->id, $options, $post->message); @@ -636,7 +636,7 @@ function hsuforum_cron() { } $coursecontext = context_course::instance($course->id); - if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext, $userto->id)) { + if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext, $userto->id)) { // The course is hidden and the user does not have access to it. continue; } @@ -698,14 +698,14 @@ function hsuforum_cron() { } // Make sure groups allow this user to see this email. - if ($discussion->groupid > 0 and $groupmode = groups_get_activity_groupmode($cm, $course)) { + if ($discussion->groupid > 0 && $groupmode = groups_get_activity_groupmode($cm, $course)) { // Groups are being used. if (!groups_group_exists($discussion->groupid)) { // Can't find group - be safe and don't this message. continue; } - if (!groups_is_member($discussion->groupid) and !has_capability('moodle/site:accessallgroups', $modcontext)) { + if (!groups_is_member($discussion->groupid) && !has_capability('moodle/site:accessallgroups', $modcontext)) { // Do not send posts from other groups when in SEPARATEGROUPS or VISIBLEGROUPS. continue; } @@ -910,7 +910,7 @@ function hsuforum_cron() { $DB->delete_records_select('hsuforum_queue', "timemodified < ?", array($weekago)); mtrace ('Cleaned old digest records'); - if ($config->digestmailtimelast < $digesttime and $timenow > $digesttime) { + if ($config->digestmailtimelast < $digesttime && $timenow > $digesttime) { mtrace('Sending forum digests: '.userdate($timenow, '', $sitetimezone)); @@ -985,7 +985,7 @@ function hsuforum_cron() { // Init user caches - we keep the cache for one cycle only, // otherwise it would unnecessarily consume memory. - if (array_key_exists($userid, $users) and isset($users[$userid]->username)) { + if (array_key_exists($userid, $users) && isset($users[$userid]->username)) { $userto = clone($users[$userid]); } else { $userto = $DB->get_record('user', array('id' => $userid)); @@ -1502,7 +1502,7 @@ function hsuforum_print_overview($courses,&$htmlarray) { } } - if (empty($unread) and empty($forumsnewposts)) { + if (empty($unread) && empty($forumsnewposts)) { return; } @@ -1649,8 +1649,8 @@ function hsuforum_recent_activity($course, $viewfullnames, $timestart, $forumid continue; } - if (!empty($config->enabletimedposts) and $USER->id != $post->duserid - and (($post->timestart > 0 and $post->timestart > time()) or ($post->timeend > 0 and $post->timeend < time())) + if (!empty($config->enabletimedposts) && $USER->id != $post->duserid + && (($post->timestart > 0 && $post->timestart > time()) or ($post->timeend > 0 && $post->timeend < time())) ) { if (!has_capability('mod/hsuforum:viewhiddentimedposts', $context)) { continue; @@ -1718,7 +1718,7 @@ function hsuforum_media_object($url, $picture, $username, $time, $subject) { */ function hsuforum_get_user_formatted_rating_grade($forum, $userid) { $grades = hsuforum_get_user_rating_grades($forum, $userid); - if (!empty($grades) and array_key_exists($userid, $grades)) { + if (!empty($grades) && array_key_exists($userid, $grades)) { $gradeitem = grade_item::fetch(array( 'courseid' => $forum->course, 'itemtype' => 'mod', @@ -1796,13 +1796,13 @@ function hsuforum_update_grades($forum, $userid=0, $nullifnone=true) { require_once($CFG->libdir.'/gradelib.php'); if ($forum->gradetype == HSUFORUM_GRADETYPE_NONE or $forum->gradetype == HSUFORUM_GRADETYPE_MANUAL or - ($forum->gradetype == HSUFORUM_GRADETYPE_RATING and !$forum->assessed)) { + ($forum->gradetype == HSUFORUM_GRADETYPE_RATING && !$forum->assessed)) { hsuforum_grade_item_update($forum); } else if ($grades = hsuforum_get_user_grades($forum, $userid)) { hsuforum_grade_item_update($forum, $grades); - } else if ($userid and $nullifnone) { + } else if ($userid && $nullifnone) { $grade = new stdClass(); $grade->userid = $userid; $grade->rawgrade = NULL; @@ -1861,7 +1861,7 @@ function hsuforum_grade_item_update($forum, $grades=NULL) { $params = array('itemname'=>$forum->name, 'idnumber'=>$forum->cmidnumber); - if ($forum->gradetype == HSUFORUM_GRADETYPE_NONE or ($forum->gradetype == HSUFORUM_GRADETYPE_RATING and !$forum->assessed) or $forum->scale == 0) { + if ($forum->gradetype == HSUFORUM_GRADETYPE_NONE or ($forum->gradetype == HSUFORUM_GRADETYPE_RATING && !$forum->assessed) or $forum->scale == 0) { $params['gradetype'] = GRADE_TYPE_NONE; } else if ($forum->scale > 0) { @@ -1928,7 +1928,7 @@ function hsuforum_scale_used ($forumid,$scaleid) { */ function hsuforum_scale_used_anywhere($scaleid) { global $DB; - if ($scaleid and $DB->record_exists('hsuforum', array('scale' => -$scaleid))) { + if ($scaleid && $DB->record_exists('hsuforum', array('scale' => -$scaleid))) { return true; } else { return false; @@ -2104,7 +2104,7 @@ function hsuforum_get_readable_forums($userid, $courseid=0, $excludeanonymous = } /// group access - if (groups_get_activity_groupmode($cm, $course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { + if (groups_get_activity_groupmode($cm, $course) == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $context)) { $forum->onlygroups = $modinfo->get_groups($cm->groupingid); $forum->onlygroups[] = -1; @@ -2669,7 +2669,7 @@ function hsuforum_count_discussion_replies($forumid, $forumsort="", $limit=-1, $ $groupby = str_replace('asc', '', $groupby); } - if (($limitfrom == 0 and $limitnum == 0) or $forumsort == "") { + if (($limitfrom == 0 && $limitnum == 0) or $forumsort == "") { $sql = "SELECT p.discussion, COUNT(p.id) AS replies, MAX(p.id) AS lastpostid FROM {hsuforum_posts} p JOIN {hsuforum_discussions} d ON p.discussion = d.id @@ -2960,7 +2960,7 @@ function hsuforum_get_discussions($cm, $forumsort="", $forumselect=true, $unused } // Sort of hacky, but allows for custom select - if (is_string($forumselect) and !empty($forumselect)) { + if (is_string($forumselect) && !empty($forumselect)) { $selectsql = $forumselect; } else { $allnames = $userfieldsapi->get_sql('u', false, '', '', false)->selects; @@ -3701,7 +3701,7 @@ function hsuforum_rating_validate($params) { } // Make sure groups allow this user to see the item they're rating - if ($discussion->groupid > 0 and $groupmode = groups_get_activity_groupmode($cm, $course)) { // Groups are being used + if ($discussion->groupid > 0 && $groupmode = groups_get_activity_groupmode($cm, $course)) { // Groups are being used if (!groups_group_exists($discussion->groupid)) { // Can't find group throw new rating_exception('cannotfindgroup');//something is wrong } @@ -3716,7 +3716,7 @@ function hsuforum_rating_validate($params) { $replystring .= ''; } - if (!groups_is_member($discussion->groupid) and !has_capability('moodle/site:accessallgroups', $context)) { + if (!groups_is_member($discussion->groupid) && !has_capability('moodle/site:accessallgroups', $context)) { // do not allow rating of posts from other groups when in SEPARATEGROUPS or VISIBLEGROUPS throw new rating_exception('notmemberofgroup'); } @@ -4167,7 +4167,7 @@ function hsuforum_pluginfile($course, $cm, $context, $filearea, $args, $forcedow if ($discussion->groupid > 0) { $groupmode = groups_get_activity_groupmode($cm, $course); if ($groupmode == SEPARATEGROUPS) { - if (!groups_is_member($discussion->groupid) and !has_capability('moodle/site:accessallgroups', $context)) { + if (!groups_is_member($discussion->groupid) && !has_capability('moodle/site:accessallgroups', $context)) { return false; } } @@ -5287,7 +5287,7 @@ function hsuforum_user_can_post($forum, $discussion, $user=NULL, $cm=NULL, $cour } // normal users with temporary guest access can not post, suspended users can not post either - if (!is_viewing($context, $user->id) and !is_enrolled($context, $user->id, '', true)) { + if (!is_viewing($context, $user->id) && !is_enrolled($context, $user->id, '', true)) { return false; } @@ -5505,7 +5505,7 @@ function hsuforum_user_can_see_post($forum, $discussion, $post, $user=NULL, $cm= throw new coding_exception('Must set post\'s privatereply property!'); } if (!empty($post->privatereply)) { - if ($post->userid != $user->id and $post->privatereply != $user->id) { + if ($post->userid != $user->id && $post->privatereply != $user->id) { return false; } } @@ -5595,11 +5595,11 @@ function hsuforum_print_latest_discussions($course, $forum, $maxdiscussions=-1, // and the current user is a guest. $canstart = hsuforum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context); - if (!$canstart and $forum->type !== 'news') { + if (!$canstart && $forum->type !== 'news') { if (isguestuser() or !isloggedin()) { $canstart = true; } - if (!is_enrolled($context) and !is_viewing($context)) { + if (!is_enrolled($context) && !is_viewing($context)) { // allow guests and not-logged-in to see the button - they are prompted to log in after clicking the link // normal users with temporary guest access see this button too, they are asked to enrol instead // do not show the button to users with suspended enrolments here @@ -5617,7 +5617,7 @@ function hsuforum_print_latest_discussions($course, $forum, $maxdiscussions=-1, // Get the number of discussions found. $numdiscussions = hsuforum_get_discussions_count($cm); } else { - if ($maxdiscussions > 0 and $maxdiscussions <= count($discussions)) { + if ($maxdiscussions > 0 && $maxdiscussions <= count($discussions)) { $olddiscussionlink = true; } } @@ -5627,10 +5627,10 @@ function hsuforum_print_latest_discussions($course, $forum, $maxdiscussions=-1, if (!$canstart && (isguestuser() or !isloggedin() or $forum->type == 'news' - or $forum->type == 'qanda' and !has_capability('mod/hsuforum:addquestion', $context) - or $forum->type != 'qanda' and !has_capability('mod/hsuforum:startdiscussion', $context))) { + or $forum->type == 'qanda' && !has_capability('mod/hsuforum:addquestion', $context) + or $forum->type != 'qanda' && !has_capability('mod/hsuforum:startdiscussion', $context))) { // no button and no info - } else if (!$canstart && $groupmode and !has_capability('moodle/site:accessallgroups', $context)) { + } else if (!$canstart && $groupmode && !has_capability('moodle/site:accessallgroups', $context)) { // inform users why they can not post new discussion if (!$currentgroup) { if (!has_capability('mod/hsuforum:canposttomygroups', $context)) { @@ -5945,8 +5945,8 @@ function hsuforum_get_recent_mod_activity(&$activities, &$index, $timestart, $co $printposts = array(); foreach ($posts as $post) { - if (!empty($config->enabletimedposts) and $USER->id != $post->duserid - and (($post->timestart > 0 and $post->timestart > time()) or ($post->timeend > 0 and $post->timeend < time()))) { + if (!empty($config->enabletimedposts) && $USER->id != $post->duserid + && (($post->timestart > 0 && $post->timestart > time()) or ($post->timeend > 0 && $post->timeend < time()))) { if (!$viewhiddentimed) { continue; } @@ -7098,7 +7098,7 @@ function hsuforum_extend_settings_navigation(settings_navigation $settingsnav, n $cansubscribe = ($activeenrolled && $subscriptionmode != HSUFORUM_FORCESUBSCRIBE && ($subscriptionmode != HSUFORUM_DISALLOWSUBSCRIBE || $canmanage)); $discussionid = optional_param('d', 0, PARAM_INT); - $viewingdiscussion = ($settingsnav->get_page()->url->compare(new moodle_url('/mod/hsuforum/discuss.php'), URL_MATCH_BASE) and $discussionid); + $viewingdiscussion = ($settingsnav->get_page()->url->compare(new moodle_url('/mod/hsuforum/discuss.php'), URL_MATCH_BASE) && $discussionid); if (!is_guest($settingsnav->get_page()->cm->context)) { $forumnode->add( @@ -7809,7 +7809,7 @@ function hsuforum_get_posts_by_user($user, array $courses, $musthaveaccess = fal $forumsearchselect = array(); if (!$iscurrentuser && !$hascapsonuser) { // Make sure we check group access - if (groups_get_activity_groupmode($cm, $course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $cm->context)) { + if (groups_get_activity_groupmode($cm, $course) == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $cm->context)) { $groups = $modinfo->get_groups($cm->groupingid); $groups[] = -1; list($groupid_sql, $groupid_params) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED, 'grps'.$forumid.'_'); @@ -8277,7 +8277,7 @@ function mod_hsuforum_comment_message(stdClass $comment, stdClass $options) { $recipients = get_users_by_capability($context, 'local/joulegrader:grade'); // Add the item user if they are different from commenter. - if ($comment->userid != $user->id and has_capability('mod/hsuforum:replypost', $context, $user)) { + if ($comment->userid != $user->id && has_capability('mod/hsuforum:replypost', $context, $user)) { $recipients[$user->id] = $user; } @@ -8815,7 +8815,7 @@ function hsuforum_change_format($messagecontent, $prefilledpostformat, $modconte // Only if there are prefilled contents coming. if (!empty($messagecontent)) { // If the prefilled post is not HTML and the preferred format is HTML, convert to it. - if ($prefilledpostformat != FORMAT_HTML and $preferredformat == FORMAT_HTML) { + if ($prefilledpostformat != FORMAT_HTML && $preferredformat == FORMAT_HTML) { $messagecontent = format_text($messagecontent, $prefilledpostformat, ['context' => $modcontext]); } } diff --git a/mod_form.php b/mod_form.php index c490a429..30b427e3 100644 --- a/mod_form.php +++ b/mod_form.php @@ -556,8 +556,8 @@ public function standard_hsuforum_grading_coursemodule_elements() { $mform->setDefault('grade', $CFG->gradepointdefault); if ($this->_features->advancedgrading - and !empty($this->current->_advancedgradingdata['methods']) - and !empty($this->current->_advancedgradingdata['areas'])) { + && !empty($this->current->_advancedgradingdata['methods']) + && !empty($this->current->_advancedgradingdata['areas'])) { if (count($this->current->_advancedgradingdata['areas']) == 1) { // if there is just one gradable area (most cases), display just the selector @@ -805,7 +805,7 @@ function validation($data, $files) { if (!empty($data['completionusegrade'])) { // This is the same logic as in hsuforum_grade_item_update() for determining that the gradetype is GRADE_TYPE_NONE // If GRADE_TYPE_NONE, then we cannot have this completion criteria because there may be no grade item! - if ($data['gradetype'] == HSUFORUM_GRADETYPE_NONE or ($data['gradetype'] == HSUFORUM_GRADETYPE_RATING and !$data['assessed']) or $data['scale'] == 0) { + if ($data['gradetype'] == HSUFORUM_GRADETYPE_NONE or ($data['gradetype'] == HSUFORUM_GRADETYPE_RATING && !$data['assessed']) or $data['scale'] == 0) { $errors['completionusegrade'] = get_string('completionusegradeerror', 'hsuforum'); } } diff --git a/post.php b/post.php index 8a90090b..6e273778 100644 --- a/post.php +++ b/post.php @@ -59,7 +59,7 @@ if (!isloggedin() or isguestuser()) { - if (!isloggedin() and !get_local_referer()) { + if (!isloggedin() && !get_local_referer()) { // No referer+not logged in - probably coming in via email See MDL-9052. require_login(); } @@ -134,7 +134,7 @@ throw new \moodle_exception('nopostforum', 'hsuforum'); } - if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $modcontext)) { + if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $modcontext)) { throw new \moodle_exception("activityiscurrentlyhidden"); } @@ -210,7 +210,7 @@ } else { $groupmode = $course->groupmode; } - if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $modcontext)) { + if ($groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $modcontext)) { if ($discussion->groupid == -1) { throw new \moodle_exception('nopostforum', 'hsuforum'); } else { @@ -220,7 +220,7 @@ } } - if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $modcontext)) { + if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $modcontext)) { throw new \moodle_exception("activityiscurrentlyhidden"); } @@ -279,12 +279,12 @@ $PAGE->requires->js_init_call('M.mod_hsuforum.init', null, false, $renderer->get_js_module()); if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) { - if (((time() - $post->created) > $CFG->maxeditingtime) and + if (((time() - $post->created) > $CFG->maxeditingtime) && !has_capability('mod/hsuforum:editanypost', $modcontext)) { throw new \moodle_exception('maxtimehaspassed', 'hsuforum', '', format_time($CFG->maxeditingtime)); } } - if (($post->userid <> $USER->id) and + if (($post->userid <> $USER->id) && !has_capability('mod/hsuforum:editanypost', $modcontext)) { throw new \moodle_exception('cannoteditposts', 'hsuforum'); } diff --git a/renderer.php b/renderer.php index b6f5e663..1fb94229 100644 --- a/renderer.php +++ b/renderer.php @@ -156,7 +156,7 @@ public function render_discussionsview($forum) { $completion->set_module_viewed($cm); /// Some capability checks. - if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { + if (empty($cm->visible) && !has_capability('moodle/course:viewhiddenactivities', $context)) { notice(get_string("activityiscurrentlyhidden")); } @@ -1317,7 +1317,7 @@ public function user_posts_overview($userid, $cm, $showonlypreference = null) { $forum = hsuforum_get_cm_forum($cm); $showonlypreferencebutton = ''; - if (!empty($showonlypreference) and !empty($showonlypreference->button) and !$forum->anonymous) { + if (!empty($showonlypreference) && !empty($showonlypreference->button) && !$forum->anonymous) { $showonlypreferencebutton = $showonlypreference->button; } @@ -1326,10 +1326,10 @@ public function user_posts_overview($userid, $cm, $showonlypreference = null) { $flaglib = new hsuforum_lib_flag(); if ($posts = hsuforum_get_user_posts($forum->id, $userid, context_module::instance($cm->id))) { $discussions = hsuforum_get_user_involved_discussions($forum->id, $userid); - if (!empty($showonlypreference) and !empty($showonlypreference->preference)) { + if (!empty($showonlypreference) && !empty($showonlypreference->preference)) { foreach ($discussions as $discussion) { - if ($discussion->userid == $userid and array_key_exists($discussion->firstpost, $posts)) { + if ($discussion->userid == $userid && array_key_exists($discussion->firstpost, $posts)) { $discussionpost = $posts[$discussion->firstpost]; $discussioncount++; @@ -1347,7 +1347,7 @@ public function user_posts_overview($userid, $cm, $showonlypreference = null) { $output .= html_writer::start_tag('div', array('class' => 'indent')); } foreach ($posts as $post) { - if ($post->discussion == $discussion->id and !empty($post->parent)) { + if ($post->discussion == $discussion->id && !empty($post->parent)) { $postcount++; if ($flaglib->is_flagged($post->flags, 'substantive')) { $flagcount++; @@ -1815,7 +1815,7 @@ public function post_get_commands($post, $discussion, $cm, $canreply) { global $CFG, $USER, $OUTPUT; $discussionlink = new moodle_url('/mod/hsuforum/discuss.php', array('d' => $post->discussion)); - $ownpost = (isloggedin() and $post->userid == $USER->id); + $ownpost = (isloggedin() && $post->userid == $USER->id); $commands = array(); if (!property_exists($post, 'privatereply')) { @@ -1824,7 +1824,7 @@ public function post_get_commands($post, $discussion, $cm, $canreply) { $forum = hsuforum_get_cm_forum($cm); - if ($canreply and empty($post->privatereply)) { + if ($canreply && empty($post->privatereply)) { $postuser = hsuforum_extract_postuser($post, $forum, context_module::instance($cm->id)); $replytitle = get_string('replybuttontitle', 'hsuforum', strip_tags($postuser->fullname)); $commands['reply'] = html_writer::link( diff --git a/subscribe.php b/subscribe.php index 4d1a0800..b9b71e2d 100644 --- a/subscribe.php +++ b/subscribe.php @@ -81,7 +81,7 @@ require_login($course, false, $cm); -if (is_null($mode) and !is_enrolled($context, $USER, '', true)) { // Guests and visitors can't subscribe - only enrolled +if (is_null($mode) && !is_enrolled($context, $USER, '', true)) { // Guests and visitors can't subscribe - only enrolled $PAGE->set_title($course->shortname); $PAGE->set_heading($course->fullname); if (isguestuser()) { @@ -105,7 +105,7 @@ ? "index.php?id=".$course->id : "view.php?f=$id"; -if (!is_null($mode) and has_capability('mod/hsuforum:managesubscriptions', $context)) { +if (!is_null($mode) && has_capability('mod/hsuforum:managesubscriptions', $context)) { require_sesskey(); switch ($mode) { case HSUFORUM_CHOOSESUBSCRIBE : // 0 diff --git a/tests/mail_test.php b/tests/mail_test.php index 280ddda6..3bef5814 100644 --- a/tests/mail_test.php +++ b/tests/mail_test.php @@ -1224,7 +1224,7 @@ public function test_forum_post_email_templates($data) { $this->assertNotEmpty($foundexpectation, 'Expectation not found for the mail'); // If we have found the expectation and have contents to match, let's do it. - if (isset($foundexpectation) and isset($foundexpectation['contents'])) { + if (isset($foundexpectation) && isset($foundexpectation['contents'])) { $mail->body = quoted_printable_decode($mail->body); if (!is_array($foundexpectation['contents'])) { // Accept both string and array. $foundexpectation['contents'] = array($foundexpectation['contents']); diff --git a/unsubscribeall.php b/unsubscribeall.php index f233d931..da4eb17b 100644 --- a/unsubscribeall.php +++ b/unsubscribeall.php @@ -48,7 +48,7 @@ echo $OUTPUT->header(); echo $OUTPUT->heading($strunsubscribeall); -if (data_submitted() and $confirm and confirm_sesskey()) { +if (data_submitted() && $confirm && confirm_sesskey()) { $forums = hsuforum_get_optional_subscribed_forums(); foreach($forums as $forum) { diff --git a/view.php b/view.php index aea0b16f..0c11463c 100644 --- a/view.php +++ b/view.php @@ -97,7 +97,7 @@ // Some capability checks. $courselink = new moodle_url('/course/view.php', ['id' => $cm->course]); - if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { + if (empty($cm->visible) && !has_capability('moodle/course:viewhiddenactivities', $context)) { notice(get_string("activityiscurrentlyhidden"), $courselink); } From 5599ff37e29abf0424f758b741983fff17a7752e Mon Sep 17 00:00:00 2001 From: JuanPablo-Openlms Date: Fri, 5 Jan 2024 13:45:30 -0500 Subject: [PATCH 4/4] Removed extra newline after the opening PHP tag. --- backup/moodle1/lib.php | 1 - backup/moodle2/backup_hsuforum_activity_task.class.php | 1 - backup/moodle2/backup_hsuforum_settingslib.php | 1 - backup/moodle2/backup_hsuforum_stepslib.php | 1 - backup/moodle2/restore_hsuforum_activity_task.class.php | 1 - backup/moodle2/restore_hsuforum_stepslib.php | 1 - classes/post_form.php | 1 - db/log.php | 1 - db/messages.php | 1 - externallib.php | 1 - index.php | 1 - locallib.php | 1 - maildigest.php | 1 - mod_form.php | 1 - renderer.php | 1 - rsslib.php | 1 - search.php | 1 - settings.php | 1 - subscribe.php | 1 - subscribers.php | 1 - tests/maildigest_test.php | 1 - unsubscribeall.php | 1 - user.php | 1 - view.php | 1 - 24 files changed, 24 deletions(-) diff --git a/backup/moodle1/lib.php b/backup/moodle1/lib.php index 69f3f8c7..337ab44c 100644 --- a/backup/moodle1/lib.php +++ b/backup/moodle1/lib.php @@ -1,5 +1,4 @@