diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index f273bfb..19ef45d 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -126,7 +126,7 @@ jobs: fail-fast: false matrix: php: [ '8.0', '8.1', '8.2', '8.3' ] - moodle-branch: [ 'MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE' ] + moodle-branch: [ 'MOODLE_401_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE' ] database: [ 'mariadb', 'pgsql' ] exclude: - php: '8.0' @@ -135,9 +135,7 @@ jobs: moodle-branch: 'MOODLE_401_STABLE' - php: '8.3' moodle-branch: 'MOODLE_401_STABLE' - - php: '8.3' - moodle-branch: 'MOODLE_402_STABLE' - - php: '8.3' + - php: 8.3' moodle-branch: 'MOODLE_403_STABLE' include: - php: '7.4' diff --git a/amd/src/postletter.js b/amd/src/postletter.js index 1152cce..d9c0e5e 100644 --- a/amd/src/postletter.js +++ b/amd/src/postletter.js @@ -126,7 +126,7 @@ async function changeButtonString(index, toshowmore) { } /** - * Removes in a text all   and surrounding

tags excluding the first occurrence. + * Removes in a text all   and surrounding

tags excluding the first occurrence. * * Helper function to make post look better. * @param {object} element @@ -145,4 +145,4 @@ async function replaceParagraghTags(element) { message.substring(firstPTag + 3, lastPTag).replace(/

/g, '
').replace(/<\/p>/g, '') + message.substring(lastPTag); element.innerHTML = message; -} \ No newline at end of file +} diff --git a/amd/src/usersettings_save.js b/amd/src/usersettings_save.js index bab24e9..843ca7d 100644 --- a/amd/src/usersettings_save.js +++ b/amd/src/usersettings_save.js @@ -195,12 +195,12 @@ function collecttimefiltersettings() { // Get the relevant time spans of the time filter. // Check if the alltimebutton is set. alltimebutton.forEach(function(button) { - if (button.parentNode.classList.contains('active')) { - // Get the timespan. - settings['timepast'] = convertidtotime(button.id); - settings['timefuture'] = convertidtotime(button.id); - settingsset = true; - } + if (button.parentNode.classList.contains('active')) { + // Get the timespan. + settings['timepast'] = convertidtotime(button.id); + settings['timefuture'] = convertidtotime(button.id); + settingsset = true; + } }); if (settingsset) { diff --git a/classes/contentcontroller.php b/classes/contentcontroller.php index 7413b30..7d976dc 100644 --- a/classes/contentcontroller.php +++ b/classes/contentcontroller.php @@ -73,7 +73,6 @@ public function build_content(): array { foreach ($this->events as $event) { // Display a orientation marker on the current date between the other events. if (!$orientationmarkerset && (($event->timestart <= $time))) { - $orientationmarkerset = true; $tempcontent = new orientation_marker($index, $time); $this->content[$index] = $tempcontent->export_data(); @@ -87,6 +86,7 @@ public function build_content(): array { $templetter = new letter\letter($index, $event->courseid, $event->modulename, $event->instancename, $event->content, $event->timestart, $event->coursemoduleid); } + $this->content[$index] = $templetter->export_letter(); // Collect the courses shown in the townsquare to be able to filter them afterwards. diff --git a/classes/letter/letter.php b/classes/letter/letter.php index 41d5aab..e73b708 100644 --- a/classes/letter/letter.php +++ b/classes/letter/letter.php @@ -32,7 +32,7 @@ /** * Class that represents an unspecific type of content. * - * This class is used for the basic letter type and is the top-class for more specific letters.. + * This class is used for the basic letter type and is the top-class for more specific letters. * * @package block_townsquare * @copyright 2023 Tamaro Walter diff --git a/classes/letter/post_letter.php b/classes/letter/post_letter.php index 5ed47a5..1a32d5a 100644 --- a/classes/letter/post_letter.php +++ b/classes/letter/post_letter.php @@ -28,9 +28,6 @@ defined('MOODLE_INTERNAL') || die; -global $CFG; -require_once($CFG->libdir . '/portfoliolib.php'); - /** * Class that represents a post from the forum or moodleoverflow module. * diff --git a/classes/output/renderer.php b/classes/output/renderer.php index a9db5c0..fad7fa9 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -43,4 +43,5 @@ class renderer extends plugin_renderer_base { public function render_main($data): string { return $this->render_from_template('block_townsquare/blockcontent', $data); } + } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index baad192..087118c 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -23,6 +23,7 @@ namespace block_townsquare\privacy; use core_privacy\local\request\approved_userlist; +use core_privacy\local\request\core_userlist_provider; use core_privacy\local\request\userlist; use core_privacy\local\metadata\collection; use core_privacy\local\request\approved_contextlist; @@ -40,7 +41,7 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\plugin\provider, - \core_privacy\local\request\core_userlist_provider { + core_userlist_provider { /** * Function that describes the type of data that is stored. @@ -50,11 +51,11 @@ class provider implements public static function get_metadata(collection $collection): collection { $collection->add_database_table('block_townsquare', [ 'userid' => 'privacy:metadata:block_townsquare_preferences:userid', - 'timefilterpast' => 'privacy:metadata:block_townsquare_preferences:timefilterpast', - 'timefilterfuture' => 'privacy:metadata:block_townsquare_preferences:timefilterfuture', - 'basicletter' => 'privacy:metadata:block_townsquare_preferences:basicletter', - 'completionletter' => 'privacy:metadata:block_townsquare_preferences:completionletter', - 'postletter' => 'privacy:metadata:block_townsquare_preferences:postletter', + 'timefilterpast' => 'privacy:metadata:block_townsquare_preferences:timefilterpast', + 'timefilterfuture' => 'privacy:metadata:block_townsquare_preferences:timefilterfuture', + 'basicletter' => 'privacy:metadata:block_townsquare_preferences:basicletter', + 'completionletter' => 'privacy:metadata:block_townsquare_preferences:completionletter', + 'postletter' => 'privacy:metadata:block_townsquare_preferences:postletter', ], 'privacy:metadata:block_townsquare_preferences'); return $collection; } @@ -154,7 +155,6 @@ public static function delete_data_for_all_users_in_context(\context $context) { } } - /** * Delete all user data for the specified user, in the specified contexts. * @param approved_contextlist $contextlist The approved contexts and user information to delete information for. @@ -169,4 +169,5 @@ public static function delete_data_for_user(approved_contextlist $contextlist) { } } } + } diff --git a/classes/townsquareevents.php b/classes/townsquareevents.php index f40dcd6..99dfd2b 100644 --- a/classes/townsquareevents.php +++ b/classes/townsquareevents.php @@ -99,7 +99,7 @@ public function get_all_events_sorted(): array { public function get_coreevents(): array { global $DB; - // Get all events from the last six months and the next six months. + // Get all events from the database. $coreevents = $this->get_events_from_db($this->timestart, $this->timeend, $this->courses); // Filter the events and add the instancename. @@ -123,19 +123,13 @@ public function get_coreevents(): array { } /** - * Function to get the newest posts from modules like the forum or moodleoverflow. + * Function to get the newest posts from the forum. * * The events are sorted in descending order by time created (newest event first) * @return array; */ public function get_postevents(): array { - global $DB; - - // If forum is not installed or not activated, return empty array. - if (!$DB->get_record('modules', ['name' => 'forum', 'visible' => 1])) { - return []; - } - + // Get all post from the database. $forumposts = $this->get_forumposts_from_db($this->courses, $this->timestart); foreach ($forumposts as $post) { @@ -304,8 +298,6 @@ private function filter_forum_privatepost(&$forumpost): bool { $forumpost->privatereplyfrom = $isprivatemessage && $isauthor; $forumpost->privatereplyto = $isprivatemessage && $isreceiver; - // Add attributes as the posts is further processed. - return false; } diff --git a/db/install.php b/db/install.php index 499631d..cf0321c 100644 --- a/db/install.php +++ b/db/install.php @@ -27,6 +27,5 @@ * Custom code to be run on installing the plugin. */ function xmldb_block_townsquare_install() { - return true; } diff --git a/db/install.xml b/db/install.xml index 7cb2ae0..0647384 100644 --- a/db/install.xml +++ b/db/install.xml @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/templates/activitycompletionletter.mustache b/templates/activitycompletionletter.mustache index dbdfdf3..db697d9 100644 --- a/templates/activitycompletionletter.mustache +++ b/templates/activitycompletionletter.mustache @@ -67,4 +67,4 @@ - \ No newline at end of file + diff --git a/templates/basicletter.mustache b/templates/basicletter.mustache index f78d83f..2ce0b24 100644 --- a/templates/basicletter.mustache +++ b/templates/basicletter.mustache @@ -71,4 +71,4 @@ - \ No newline at end of file + diff --git a/templates/blockcontent.mustache b/templates/blockcontent.mustache index f079505..3387c42 100644 --- a/templates/blockcontent.mustache +++ b/templates/blockcontent.mustache @@ -98,4 +98,4 @@ - \ No newline at end of file + diff --git a/templates/orientationmarker.mustache b/templates/orientationmarker.mustache index 3bfca8f..a2cbd13 100644 --- a/templates/orientationmarker.mustache +++ b/templates/orientationmarker.mustache @@ -35,4 +35,4 @@ style="border-color: {{orientationmarkercolor}}; background-color: {{orientationmarkercolor}};">

- \ No newline at end of file + diff --git a/tests/behat/block_townsquare_timefilter.feature b/tests/behat/block_townsquare_timefilter.feature index 8d554f8..7195816 100644 --- a/tests/behat/block_townsquare_timefilter.feature +++ b/tests/behat/block_townsquare_timefilter.feature @@ -100,4 +100,4 @@ Feature: Extra feature file to test the time filter And I should see "Test assign 6" in the "Town Square" "block" And I should see "Test assign 7" in the "Town Square" "block" And I should see "Test assign 4" in the "Town Square" "block" - And I should see "Test choice 1" in the "Town Square" "block" \ No newline at end of file + And I should see "Test choice 1" in the "Town Square" "block"