diff --git a/message/classes/api.php b/message/classes/api.php index 3f70e5318ae..0b29e7c8acb 100644 --- a/message/classes/api.php +++ b/message/classes/api.php @@ -1753,46 +1753,11 @@ class api { } /** - * Marks ALL messages being sent from $fromuserid to $touserid as read. - * - * Can be filtered by type. - * * @deprecated since 3.5 - * @param int $touserid the id of the message recipient - * @param int $fromuserid the id of the message sender - * @param string $type filter the messages by type, either MESSAGE_TYPE_NOTIFICATION, MESSAGE_TYPE_MESSAGE or '' for all. - * @return void */ - public static function mark_all_read_for_user($touserid, $fromuserid = 0, $type = '') { - debugging('\core_message\api::mark_all_read_for_user is deprecated. Please either use ' . - '\core_message\api::mark_all_notifications_read_for_user or \core_message\api::mark_all_messages_read_for_user', - DEBUG_DEVELOPER); - - $type = strtolower($type); - - $conversationid = null; - $ignoremessages = false; - if (!empty($fromuserid)) { - $conversationid = self::get_conversation_between_users([$touserid, $fromuserid]); - if (!$conversationid) { // If there is no conversation between the users then there are no messages to mark. - $ignoremessages = true; - } - } - - if (!empty($type)) { - if ($type == MESSAGE_TYPE_NOTIFICATION) { - self::mark_all_notifications_as_read($touserid, $fromuserid); - } else if ($type == MESSAGE_TYPE_MESSAGE) { - if (!$ignoremessages) { - self::mark_all_messages_as_read($touserid, $conversationid); - } - } - } else { // We want both. - self::mark_all_notifications_as_read($touserid, $fromuserid); - if (!$ignoremessages) { - self::mark_all_messages_as_read($touserid, $conversationid); - } - } + public static function mark_all_read_for_user() { + throw new \coding_exception('\core_message\api::mark_all_read_for_user has been removed. Please either use ' . + '\core_message\api::mark_all_notifications_as_read or \core_message\api::mark_all_messages_as_read'); } /** diff --git a/message/tests/api_test.php b/message/tests/api_test.php index 63329f4418d..bbcdd433623 100644 --- a/message/tests/api_test.php +++ b/message/tests/api_test.php @@ -52,8 +52,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { $this->send_fake_message($sender, $recipient); $this->send_fake_message($sender, $recipient); - \core_message\api::mark_all_read_for_user($recipient->id); - $this->assertDebuggingCalled(); + \core_message\api::mark_all_notifications_as_read($recipient->id); + \core_message\api::mark_all_messages_as_read($recipient->id); $this->assertEquals(message_count_unread_messages($recipient), 0); } @@ -75,8 +75,10 @@ class core_message_api_testcase extends core_message_messagelib_testcase { $this->send_fake_message($sender2, $recipient); $this->send_fake_message($sender2, $recipient); - \core_message\api::mark_all_read_for_user($recipient->id, $sender1->id); - $this->assertDebuggingCalled(); + \core_message\api::mark_all_notifications_as_read($recipient->id, $sender1->id); + $conversationid = \core_message\api::get_conversation_between_users([$recipient->id, $sender1->id]); + \core_message\api::mark_all_messages_as_read($recipient->id, $conversationid); + $this->assertEquals(message_count_unread_messages($recipient), 3); } @@ -91,12 +93,10 @@ class core_message_api_testcase extends core_message_messagelib_testcase { $this->send_fake_message($sender, $recipient); $this->send_fake_message($sender, $recipient); - \core_message\api::mark_all_read_for_user($recipient->id, 0, MESSAGE_TYPE_NOTIFICATION); - $this->assertDebuggingCalled(); + \core_message\api::mark_all_notifications_as_read($recipient->id); $this->assertEquals(message_count_unread_messages($recipient), 3); - \core_message\api::mark_all_read_for_user($recipient->id, 0, MESSAGE_TYPE_MESSAGE); - $this->assertDebuggingCalled(); + \core_message\api::mark_all_messages_as_read($recipient->id); $this->assertEquals(message_count_unread_messages($recipient), 0); } diff --git a/message/upgrade.txt b/message/upgrade.txt index 9a1cc117547..efc1f233356 100644 --- a/message/upgrade.txt +++ b/message/upgrade.txt @@ -9,6 +9,7 @@ information provided here is intended especially for developers. - message_mark_message_read - message_can_delete_message - message_delete_message + * mark_all_read_for_user() === 3.8 ===