From de589ca25d96b7f7b4906856caa3459f151d5a2f Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 8 Apr 2021 22:37:53 +0100 Subject: [PATCH] MDL-67338 message: re-implement block page type patterns. The `page_type_list` method for the message component was deprecated in 5b0769db as part of MDL-54744. However it is still required when trying to configure blocks on any messaging pages. --- lang/en/message.php | 1 + lib/deprecatedlib.php | 7 ------- message/lib.php | 14 ++++++++++++++ message/upgrade.txt | 5 +++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lang/en/message.php b/lang/en/message.php index 2080a0f8231..e6cfcaa1453 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -151,6 +151,7 @@ $string['on'] = 'On'; $string['online'] = 'Online'; $string['otherparticipants'] = 'Other participants'; $string['outputnotavailable'] = 'Not available'; +$string['page-message-x'] = 'Any message pages'; $string['participants'] = 'Participants'; $string['pendingcontactrequests'] = 'There are {$a} pending contact requests'; $string['permitted'] = 'Permitted'; diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index fa9735f7ad7..5601156e93b 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2337,13 +2337,6 @@ function message_mark_messages_read() { '\core_message\api::mark_all_messages_as_read() instead.'); } -/** - * @deprecated since Moodle 3.2 - */ -function message_page_type_list() { - throw new coding_exception('message_page_type_list() can not be used anymore.'); -} - /** * @deprecated since Moodle 3.2 */ diff --git a/message/lib.php b/message/lib.php index a416ee5c2a5..e6d931db163 100644 --- a/message/lib.php +++ b/message/lib.php @@ -530,6 +530,20 @@ function translate_message_default_setting($plugindefault, $processorname) { return array($permitted, $loggedin, $loggedoff); } +/** + * Return a list of page types + * + * @param string $pagetype current page type + * @param context|null $parentcontext Block's parent context + * @param context|null $currentcontext Current context of block + * @return array + */ +function message_page_type_list(string $pagetype, ?context $parentcontext, ?context $currentcontext): array { + return [ + 'message-*' => get_string('page-message-x', 'message'), + ]; +} + /** * Get messages sent or/and received by the specified users. * Please note that this function return deleted messages too. Besides, only individual conversation messages diff --git a/message/upgrade.txt b/message/upgrade.txt index a989150feab..01a9490a4f4 100644 --- a/message/upgrade.txt +++ b/message/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in /message/ messaging system, information provided here is intended especially for developers. +=== 3.11.2 === + +* The `message_page_type_list` method was previouly deprecated, however it was still + used so has been recreated in message/lib.php + === 3.10 === * The following methods have been deprecated and should not be used any more: