1 This files describes API changes in /message/ messaging system,
2 information provided here is intended especially for developers.
6 The following functions have been finally deprecated and can not be used anymore:
8 * get_individual_conversations_between_users()
9 * The message_jabber notification has been completely removed from core. It has been moved to the plugins database repository, so
10 it can still be installed as a third-party plugin.
11 * The type of the parameter $read in the function message_get_messages has changed from boolean to integer. It now accepts either MESSAGE_GET_UNREAD, MESSAGE_GET_READ or MESSAGE_GET_READ_AND_UNREAD.
15 * The `message_page_type_list` method was previouly deprecated, however it was still
16 used so has been recreated in message/lib.php
20 * The following methods have been deprecated and should not be used any more:
21 * message_count_unread_messages()
22 * get_non_contacts_with_unread_message_count()
23 * get_contacts_with_unread_message_count()
25 * The following functions have been finally deprecated and can not be used anymore::
26 * search_users_in_course()
30 * get_most_recent_message()
34 * get_conversations_legacy_formatter()
38 * data_for_messagearea_search_users_in_course()
39 * data_for_messagearea_search_users()
40 * message_search_users()
41 * data_for_messagearea_conversations()
42 * data_for_messagearea_contacts()
43 * data_for_messagearea_messages()
44 * get_conversation_messages()
45 * data_for_messagearea_get_most_recent_message()
46 * data_for_messagearea_get_profile()
47 * mark_all_messages_as_read()
48 * delete_conversation()
51 * Removed the following deprecated functions:
52 - message_move_userfrom_unread2read
53 - message_get_blocked_users
54 - message_get_contacts
55 - message_mark_message_read
56 - message_can_delete_message
57 - message_delete_message
58 - mark_all_read_for_user()
59 * Message processors can implement the following methods which will be executed as part of the messaging cleanup task:
60 - cleanup_all_notifications
61 - cleanup_read_notifications
65 * The following methods have been deprecated and should not be used any more:
66 - \core_message\api::get_individual_conversations_between_users()
67 - \core_message\api::can_post_message()
71 * The message/index.php page used to support viewing another user's messages (if you had the right capabilities) by
72 altering the URL and adding the parameters 'user1' and 'user2'. There were only some very rare occurrences where you
73 could access a URL generated with these parameters (eg. log report). It was decided to stop supporting this
74 functionality and remove all the legacy code (see MDL-63915).
75 Note - It's still possible to view another user's messages if you have the right capabilities and are able to
77 * A new parameter 'mergeself' has been added to the methods \core_message\api::get_conversations() and
78 core_message_external::get_conversations(), to decide whether the self-conversations should be included or not when the
79 private ones are requested, to display them together.
80 * A new 'customdata' field for both messages and notifications has been added. This new field can store any custom data
81 serialised using json_encode().
82 This new field can be used for storing any data not fitting in the current message structure. For example, it will be used
83 to store additional information for the "Mobile notifications" processor.
84 Existing external functions: core_message_get_messages and message_popup_get_popup_notifications has been udated to return the
86 * External function core_message_get_messages now returns the component and eventtype.
90 * The following functions have been finally deprecated and can not be used anymore:
91 * message_get_course_contexts()
92 * message_remove_url_params()
93 * message_count_messages()
94 * message_count_blocked_users()
95 * message_contact_link()
96 * message_history_link()
97 * message_shorten_message()
98 * message_get_fragment()
99 * message_get_contact_add_remove_link()
100 * message_get_contact_block_link()
101 * message_mark_messages_read()
102 * message_page_type_list()
103 * message_can_post_message()
104 * message_is_user_non_contact_blocked()
105 * message_is_user_blocked()
106 * The following functions have been deprecated and should not be used any more:
107 - message_add_contact()
108 - message_remove_contact()
109 - message_unblock_contact()
110 - message_block_contact()
111 - message_get_contact()
112 Please see their declaration in lib/deprecatedlib.php to view their alternatives (if applicable).
113 * The following methods have been deprecated and should not be used any more:
114 - \core_message\api::is_user_blocked()
115 - \core_message\api::delete_conversation()
116 - \core_message\api::is_user_non_contact_blocked()
117 - \core_message\api::create_conversation_between_users()
118 * The method \core_message\api::can_delete_conversation() now expects a 'conversationid' to be passed
119 as the second parameter.
120 * The following web services have been deprecated. Please do not call these any more.
121 - core_message_external::block_contacts(), please use core_message_external::block_user() instead.
122 - core_message_external::unblock_contacts(), please use core_message_external::unblock_user() instead.
123 - core_message_external::create_contacts(), please use core_message_external::create_contact_request() instead.
124 - core_message_external::delete_conversation(), please use core_message_external::delete_conversations_by_id() instead.
125 - core_message_external::core_message_mark_all_messages_as_read(), please use
126 core_message_external::core_message_mark_all_conversation_messages_as_read() instead.
127 - core_message_external::data_for_messagearea_conversations(), please use core_message_external::get_conversations()
129 - core_message_external::data_for_messagearea_search_users_in_course().
130 - core_message_external::data_for_messagearea_search_users(),
131 please use core_message_external::message_search_users() instead.
132 - core_message_external::data_for_messagearea_contacts().
133 - core_message_external::data_for_messagearea_messages().
134 - core_message_external::data_for_messagearea_get_most_recent_message().
135 - core_message_external::data_for_messagearea_get_profile().
136 - core_message_external::get_contacts().
137 * The following function has been added for getting the privacy messaging preference:
138 - get_user_privacy_messaging_preference()
142 * Changed the database structure so there are no longer two tables for messages, with the only
143 difference being that one stores read messages. The 'message' and 'message_read' tables are
144 still present in core but will no longer be populated by core APIs. The data will be
145 transferred to the new database structure via an ad-hoc task. Please be patient. This can
147 The new database structure is as follows -
148 'messages' - Stores the messages with a 'useridfrom' field specifying the user who sent the
149 message and a 'conversationid' field specifying which conversation it is for.
150 'message_conversations' - The list of conversations.
151 'message_conversation_members' - The list of users in each conversation.
152 'message_user_actions' - The list of user actions against a message, eg. read/deleted.
153 'notifications' - This has a very similar structure to the old table 'message' and still
154 has a one-to-one relation between users.
155 Due to these huge differences the events message_sent, message_deleted and message_viewed
156 have changed quite a lot. Please, if you have any observers or are triggering these events
157 in your code you will have to make some changes!
158 * The webservice external function 'core_message_mark_message_read' now only marks messages as
159 read, and not notifications. A new external function 'core_message_mark_notification_read' was
160 added to mark notifications as read.
161 * Deprecated the following functions.
162 - message_move_userfrom_unread2read
163 - message_get_blocked_users
164 - message_get_contacts
165 - message_mark_message_read
166 - message_can_delete_message
167 - message_delete_message
168 - \core_message\api::mark_all_read_for_user
169 Please see their declaration in lib/deprecatedlib.php to view their alternatives (if applicable).
170 * Final deprecation of the following functions.
171 - message_get_recent_notifications
173 - message_get_history
174 - message_get_recent_conversations
175 * Added new events for when a notification is sent and viewed.
176 * Removed the database table 'message_working'. The 'message_working' table was introduced when
177 the messaging system was first introduced in Moodle, so, a long time ago. It was never necessary.
178 * Replaced the usage of the table 'message_popup' to a new table 'message_popup_notifications'.
182 * Removed all message_print_* functions as well as the files search.html, search_advanced.html and
183 send_form.php due to messaging UI rehaul.
184 * Deprecated the following functions as they are no longer used.
185 - message_get_course_contexts
186 - message_remove_url_params
187 - message_count_messages
188 - message_count_blocked_users
189 - message_contact_link
190 - message_get_recent_notifications
191 - message_history_link
193 - message_shorten_message
194 - message_get_fragment
195 - message_get_history
196 - message_get_contact_add_remove_link
197 - message_get_contact_block_link
198 - message_mark_messages_read
199 - message_page_type_list
200 - message_can_post_message
201 - message_is_user_non_contact_blocked
202 - message_is_user_blocked
205 * get_message_processors accepts an addition parameter for testing, which will just reset processor and exit.
206 * Deprecated method message_current_user_is_involved() has been removed.
209 * Renderer method \core_message_renderer::manage_messagingoptions now accepts a user id parameter as well.
212 * Message processor extending message_output, should return true in can_send_to_any_users()
213 if it supports message sending to internal (noreply/support) users.
214 * Message API has been changed to allow attachments. Message processors that can support
215 attachments can now use additional parameter as a part of $eventdata. To send attachments,
216 $eventdata should contain properties called "attachment" (must be stored_file) and
217 "attachname" (string). Currently, email message processor is the only one to support
223 * lib/messagelib.php message_send($eventdata)
224 $eventdata->userto should contain a property called "emailstop", $eventdata->userto->emailstop
225 If it is absent it will be retrieved from the user table causing an additional database query