1 This files describes API changes in /message/ messaging system,
2 information provided here is intended especially for developers.
6 * The message/index.php page used to support viewing another user's messages (if you had the right capabilities) by
7 altering the URL and adding the parameters 'user1' and 'user2'. There were only some very rare occurrences where you
8 could access a URL generated with these parameters (eg. log report). It was decided to stop supporting this
9 functionality and remove all the legacy code (see MDL-63915).
10 Note - It's still possible to view another user's messages if you have the right capabilities and are able to
12 * A new parameter 'mergeself' has been added to the methods \core_message\api::get_conversations() and
13 core_message_external::get_conversations(), to decide whether the self-conversations should be included or not when the
14 private ones are requested, to display them together.
15 * A new 'customdata' field for both messages and notifications has been added. This new field can store any custom data
16 serialised using json_encode().
17 This new field can be used for storing any data not fitting in the current message structure. For example, it will be used
18 to store additional information for the "Mobile notifications" processor.
19 Existing external functions: core_message_get_messages and message_popup_get_popup_notifications has been udated to return the
21 * External function core_message_get_messages now returns the component and eventtype.
25 * The following functions have been finally deprecated and can not be used anymore:
26 * message_get_course_contexts()
27 * message_remove_url_params()
28 * message_count_messages()
29 * message_count_blocked_users()
30 * message_contact_link()
31 * message_history_link()
32 * message_shorten_message()
33 * message_get_fragment()
34 * message_get_contact_add_remove_link()
35 * message_get_contact_block_link()
36 * message_mark_messages_read()
37 * message_page_type_list()
38 * message_can_post_message()
39 * message_is_user_non_contact_blocked()
40 * message_is_user_blocked()
41 * The following functions have been deprecated and should not be used any more:
42 - message_add_contact()
43 - message_remove_contact()
44 - message_unblock_contact()
45 - message_block_contact()
46 - message_get_contact()
47 Please see their declaration in lib/deprecatedlib.php to view their alternatives (if applicable).
48 * The following methods have been deprecated and should not be used any more:
49 - \core_message\api::is_user_blocked()
50 - \core_message\api::delete_conversation()
51 - \core_message\api::is_user_non_contact_blocked()
52 - \core_message\api::create_conversation_between_users()
53 * The method \core_message\api::can_delete_conversation() now expects a 'conversationid' to be passed
54 as the second parameter.
55 * The following web services have been deprecated. Please do not call these any more.
56 - core_message_external::block_contacts(), please use core_message_external::block_user() instead.
57 - core_message_external::unblock_contacts(), please use core_message_external::unblock_user() instead.
58 - core_message_external::create_contacts(), please use core_message_external::create_contact_request() instead.
59 - core_message_external::delete_conversation(), please use core_message_external::delete_conversations_by_id() instead.
60 - core_message_external::core_message_mark_all_messages_as_read(), please use
61 core_message_external::core_message_mark_all_conversation_messages_as_read() instead.
62 - core_message_external::data_for_messagearea_conversations(), please use core_message_external::get_conversations()
64 - core_message_external::data_for_messagearea_search_users_in_course().
65 - core_message_external::data_for_messagearea_search_users(),
66 please use core_message_external::message_search_users() instead.
67 - core_message_external::data_for_messagearea_contacts().
68 - core_message_external::data_for_messagearea_messages().
69 - core_message_external::data_for_messagearea_get_most_recent_message().
70 - core_message_external::data_for_messagearea_get_profile().
71 - core_message_external::get_contacts().
72 * The following function has been added for getting the privacy messaging preference:
73 - get_user_privacy_messaging_preference()
77 * Changed the database structure so there are no longer two tables for messages, with the only
78 difference being that one stores read messages. The 'message' and 'message_read' tables are
79 still present in core but will no longer be populated by core APIs. The data will be
80 transferred to the new database structure via an ad-hoc task. Please be patient. This can
82 The new database structure is as follows -
83 'messages' - Stores the messages with a 'useridfrom' field specifying the user who sent the
84 message and a 'conversationid' field specifying which conversation it is for.
85 'message_conversations' - The list of conversations.
86 'message_conversation_members' - The list of users in each conversation.
87 'message_user_actions' - The list of user actions against a message, eg. read/deleted.
88 'notifications' - This has a very similar structure to the old table 'message' and still
89 has a one-to-one relation between users.
90 Due to these huge differences the events message_sent, message_deleted and message_viewed
91 have changed quite a lot. Please, if you have any observers or are triggering these events
92 in your code you will have to make some changes!
93 * The webservice external function 'core_message_mark_message_read' now only marks messages as
94 read, and not notifications. A new external function 'core_message_mark_notification_read' was
95 added to mark notifications as read.
96 * Deprecated the following functions.
97 - message_move_userfrom_unread2read
98 - message_get_blocked_users
99 - message_get_contacts
100 - message_mark_message_read
101 - message_can_delete_message
102 - message_delete_message
103 - \core_message\api::mark_all_read_for_user
104 Please see their declaration in lib/deprecatedlib.php to view their alternatives (if applicable).
105 * Final deprecation of the following functions.
106 - message_get_recent_notifications
108 - message_get_history
109 - message_get_recent_conversations
110 * Added new events for when a notification is sent and viewed.
111 * Removed the database table 'message_working'. The 'message_working' table was introduced when
112 the messaging system was first introduced in Moodle, so, a long time ago. It was never necessary.
113 * Replaced the usage of the table 'message_popup' to a new table 'message_popup_notifications'.
117 * Removed all message_print_* functions as well as the files search.html, search_advanced.html and
118 send_form.php due to messaging UI rehaul.
119 * Deprecated the following functions as they are no longer used.
120 - message_get_course_contexts
121 - message_remove_url_params
122 - message_count_messages
123 - message_count_blocked_users
124 - message_contact_link
125 - message_get_recent_notifications
126 - message_history_link
128 - message_shorten_message
129 - message_get_fragment
130 - message_get_history
131 - message_get_contact_add_remove_link
132 - message_get_contact_block_link
133 - message_mark_messages_read
134 - message_page_type_list
135 - message_can_post_message
136 - message_is_user_non_contact_blocked
137 - message_is_user_blocked
140 * get_message_processors accepts an addition parameter for testing, which will just reset processor and exit.
141 * Deprecated method message_current_user_is_involved() has been removed.
144 * Renderer method \core_message_renderer::manage_messagingoptions now accepts a user id parameter as well.
147 * Message processor extending message_output, should return true in can_send_to_any_users()
148 if it supports message sending to internal (noreply/support) users.
149 * Message API has been changed to allow attachments. Message processors that can support
150 attachments can now use additional parameter as a part of $eventdata. To send attachments,
151 $eventdata should contain properties called "attachment" (must be stored_file) and
152 "attachname" (string). Currently, email message processor is the only one to support
158 * lib/messagelib.php message_send($eventdata)
159 $eventdata->userto should contain a property called "emailstop", $eventdata->userto->emailstop
160 If it is absent it will be retrieved from the user table causing an additional database query