Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Class used to return information to display for the message area. More...
Static Public Member Functions | |
static | add_contact (int $userid, int $contactid) |
Handles adding a contact. More... | |
static | add_members_to_conversation (array $userids, int $convid) |
Add some new members to an existing conversation. More... | |
static | block_user (int $userid, int $usertoblockid) |
Handles blocking a user. More... | |
static | can_create_contact (int $userid, int $requesteduserid) |
Checks if a user can create a contact request. More... | |
static | can_create_group_conversation (int $userid, context $context) |
Checks if a user can create a group conversation. More... | |
static | can_delete_conversation (int $userid, int $conversationid=null) |
Checks if a user can delete messages they have either received or sent. More... | |
static | can_delete_message ($userid, $messageid) |
Checks if a user can delete a message. More... | |
static | can_delete_message_for_all_users (int $userid, int $messageid) |
Checks if a user can delete a message for all users. More... | |
static | can_mark_all_messages_as_read (int $userid, int $conversationid) |
Checks if a user can mark all messages as read. More... | |
static | can_post_message ($recipient, $sender=null) |
Determines if a user is permitted to send another user a private message. More... | |
static | can_send_message (int $recipientid, int $senderid, bool $evenifblocked=false) |
Determines if a user is permitted to send another user a private message. More... | |
static | can_send_message_to_conversation (int $userid, int $conversationid) |
Determines if a user is permitted to send a message to a given conversation. More... | |
static | confirm_contact_request (int $userid, int $requesteduserid) |
Handles confirming a contact request. More... | |
static | count_blocked_users ($user=null) |
Count the number of users blocked by a user. More... | |
static | count_contacts (int $userid) |
Returns the contacts count. More... | |
static | count_conversation_members (int $convid) |
Count conversation members. More... | |
static | count_unread_conversations ($user=null) |
Returns the count of unread conversations (collection of messages from a single user) for the given user. More... | |
static | create_contact_request (int $userid, int $requesteduserid) |
Handles creating a contact request. More... | |
static | create_conversation (int $type, array $userids, string $name=null, int $enabled=self::MESSAGE_CONVERSATION_ENABLED, string $component=null, string $itemtype=null, int $itemid=null, int $contextid=null) |
Creates a conversation with selected users and messages. More... | |
static | create_conversation_between_users (array $userids) |
Creates a conversation between two users. More... | |
static | decline_contact_request (int $userid, int $requesteduserid) |
Handles declining a contact request. More... | |
static | delete_all_conversation_data (int $conversationid) |
Completely removes all related data in the DB for a given conversation. More... | |
static | delete_conversation ($userid, $otheruserid) |
Deletes a conversation. More... | |
static | delete_conversation_by_id (int $userid, int $conversationid) |
Deletes a conversation for a specified user. More... | |
static | delete_message ($userid, $messageid) |
Deletes a message. More... | |
static | delete_message_for_all_users (int $messageid) |
Delete a message for all users. More... | |
static | disable_conversation (int $conversationid) |
Disable a conversation. More... | |
static | does_contact_request_exist (int $userid, int $requesteduserid) |
Checks if a contact request already exists between users. More... | |
static | enable_conversation (int $conversationid) |
Enable a conversation. More... | |
static | get_all_message_preferences ($processors, $providers, $user) |
Returns message preferences. More... | |
static | get_blocked_users ($userid) |
Retrieve users blocked by $user1. More... | |
static | get_contact (int $userid, int $contactid) |
Returns the row in the database table message_contacts that represents the contact between two people. More... | |
static | get_contact_requests (int $userid, int $limitfrom=0, int $limitnum=0) |
Handles returning the contact requests for a user. More... | |
static | get_contact_requests_between_users (int $userid, int $requesteduserid) |
Get contact requests between users. More... | |
static | get_contacts ($userid, $limitfrom=0, $limitnum=0) |
Returns the contacts to display in the contacts area. More... | |
static | get_contacts_with_unread_message_count ($userid, $limitfrom=0, $limitnum=0) |
Returns the an array of the users the given user is in a conversation with who are a contact and the number of unread messages. More... | |
static | get_conversation (int $userid, int $conversationid, bool $includecontactrequests=false, bool $includeprivacyinfo=false, int $memberlimit=0, int $memberoffset=0, int $messagelimit=0, int $messageoffset=0, bool $newestmessagesfirst=true) |
Return a conversation. More... | |
static | get_conversation_between_users (array $userids) |
Returns the conversation between two users. More... | |
static | get_conversation_by_area (string $component, string $itemtype, int $itemid, int $contextid) |
Get conversation by area. More... | |
static | get_conversation_counts (int $userid) |
Returns the count of conversations (collection of messages from a single user) for the given user. More... | |
static | get_conversation_members (int $userid, int $conversationid, bool $includecontactrequests=false, bool $includeprivacyinfo=false, int $limitfrom=0, int $limitnum=0) |
Returns a list of conversation members. More... | |
static | get_conversation_messages (int $userid, int $convid, int $limitfrom=0, int $limitnum=0, string $sort='timecreated ASC', int $timefrom=0, int $timeto=0) |
Returns the messages for the defined conversation. More... | |
static | get_conversations ($userid, $limitfrom=0, $limitnum=20, int $type=null, bool $favourites=null, bool $mergeself=false) |
Returns the contacts and their conversation to display in the contacts area. More... | |
static | get_conversations_between_users (int $userid1, int $userid2, int $limitfrom=0, int $limitnum=20) |
Returns all conversations between two users. More... | |
static | get_individual_conversations_between_users (array $useridsets) |
Returns the conversations between sets of users. More... | |
static | get_message_processor ($name, $ready=false) |
Get specified message processor, validate corresponding plugin existence and system configuration. More... | |
static | get_messages ($userid, $otheruserid, $limitfrom=0, $limitnum=0, $sort='timecreated ASC', $timefrom=0, $timeto=0) |
Returns the messages to display in the message area. More... | |
static | get_most_recent_conversation_message (int $convid, int $currentuserid=0) |
Returns the most recent message in a conversation. More... | |
static | get_most_recent_message ($userid, $otheruserid) |
Returns the most recent message between two users. More... | |
static | get_non_contacts_with_unread_message_count ($userid, $limitfrom=0, $limitnum=0) |
Returns the an array of the users the given user is in a conversation with who are not a contact and the number of unread messages. More... | |
static | get_processed_processor_object (\stdClass $processor) |
Given a processor object, loads information about it's settings and configurations. More... | |
static | get_profile ($userid, $otheruserid) |
Returns the profile information for a contact for a user. More... | |
static | get_received_contact_requests_count (int $userid) |
Returns the number of contact requests the user has received. More... | |
static | get_self_conversation (int $userid) |
Returns the self conversation for a user. More... | |
static | get_unread_conversation_counts (int $userid) |
Get the unread counts for all conversations for the user, sorted by type, and including favourites. More... | |
static | get_user_contacts (int $userid, int $limitfrom=0, int $limitnum=0) |
Get the contacts for a given user. More... | |
static | get_user_privacy_messaging_preference (int $userid) |
Get the messaging preference for a user. More... | |
static | is_blocked (int $userid, int $blockeduserid) |
Checks if a user is already blocked. More... | |
static | is_contact (int $userid, int $contactid) |
Checks if users are already contacts. More... | |
static | is_conversation_area_enabled (string $component, string $itemtype, int $itemid, int $contextid) |
Checks whether or not a conversation area is enabled. More... | |
static | is_conversation_muted (int $userid, int $conversationid) |
Checks whether a conversation is muted or not. More... | |
static | is_processor_enabled ($name) |
Returns weather a given processor is enabled or not. More... | |
static | is_user_blocked ($recipientid, $senderid=null) |
Checks if the recipient has specifically blocked the sending user. More... | |
static | is_user_in_conversation (int $userid, int $conversationid) |
Checks if a user is already in a conversation. More... | |
static | is_user_non_contact_blocked ($recipient, $sender=null) |
Checks if the recipient is allowing messages from users that aren't a contact. More... | |
static | mark_all_messages_as_read ($userid, $conversationid=null) |
Marks all messages being sent to a user in a particular conversation. More... | |
static | mark_all_notifications_as_read ($touserid, $fromuserid=null, $timecreatedto=null) |
Marks all notifications being sent from one user to another user as read. More... | |
static | mark_all_read_for_user () |
static | mark_message_as_read ($userid, $message, $timeread=null) |
Mark a single message as read. More... | |
static | mark_notification_as_read ($notification, $timeread=null) |
Mark a single notification as read. More... | |
static | message_search_users (int $userid, string $search, int $limitfrom=0, int $limitnum=20) |
Handles searching for user. More... | |
static | mute_conversation (int $userid, int $conversationid) |
Handles muting a conversation. More... | |
static | remove_contact (int $userid, int $contactid) |
Handles removing a contact. More... | |
static | remove_members_from_conversation (array $userids, int $convid) |
Remove some members from an existing conversation. More... | |
static | search_messages ($userid, $search, $limitfrom=0, $limitnum=0) |
Handles searching for messages in the message area. More... | |
static | search_users ($userid, $search, $limitnum=0) |
Handles searching for user in the message area. More... | |
static | search_users_in_course ($userid, $courseid, $search, $limitfrom=0, $limitnum=0) |
Handles searching for user in a particular course in the message area. More... | |
static | send_message_to_conversation (int $userid, int $conversationid, string $message, int $format) |
Send a message from a user to a conversation. More... | |
static | set_favourite_conversation (int $conversationid, int $userid) |
Mark a conversation as a favourite for the given user. More... | |
static | unblock_user (int $userid, int $usertounblockid) |
Handles unblocking a user. More... | |
static | unmute_conversation (int $userid, int $conversationid) |
Handles unmuting a conversation. More... | |
static | unset_favourite_conversation (int $conversationid, int $userid) |
Unset a conversation as a favourite for the given user. More... | |
static | update_conversation_name (int $conversationid, string $name) |
Update the name of a conversation. More... | |
static | update_processor_status ($processor, $enabled) |
Set status of a processor. More... | |
Static Protected Member Functions | |
static | can_contact_user (int $recipientid, int $senderid, bool $evenifblocked=false) |
Checks if the sender can message the recipient. More... | |
static | get_linked_conversation_extra_fields (array $conversations) |
Gets extra fields, like image url and subname for any conversations linked to components. More... | |
static | lazy_create_self_conversation (int $userid) |
Create a self conversation for a user, only if one doesn't already exist. More... | |
Class used to return information to display for the message area.
|
static |
Handles adding a contact.
int | $userid | The id of the user who requested to be a contact |
int | $contactid | The id of the contact |
|
static |
Add some new members to an existing conversation.
array | $userids | User ids array to add as members. |
int | $convid | The conversation id. Must exists. |
dml_missing_record_exception | If convid conversation doesn't exist |
dml_exception | If there is a database error |
moodle_exception | If trying to add a member(s) to a non-group conversation |
|
static |
Handles blocking a user.
int | $userid | The id of the user who is blocking |
int | $usertoblockid | The id of the user being blocked |
|
staticprotected |
Checks if the sender can message the recipient.
int | $recipientid | |
int | $senderid | |
bool | $evenifblocked | This lets the user know, that even if the recipient has blocked the user the user is still able to send a message. |
bool | true if recipient hasn't blocked sender and sender can contact to recipient, false otherwise. |
|
static |
Checks if a user can create a contact request.
int | $userid | The id of the user who is creating the contact request |
int | $requesteduserid | The id of the user being requested |
bool |
|
static |
Checks if a user can create a group conversation.
int | $userid | The id of the user attempting to create the conversation |
context | $context | The context they are creating the conversation from, most likely course context |
bool |
|
static |
Checks if a user can delete messages they have either received or sent.
int | $userid | The user id of who we want to delete the messages for (this may be done by the admin but will still seem as if it was by the user) |
int | $conversationid | The id of the conversation |
bool | Returns true if a user can delete the conversation, false otherwise. |
|
static |
Checks if a user can delete a message.
int | $userid | the user id of who we want to delete the message for (this may be done by the admin but will still seem as if it was by the user) |
int | $messageid | The message id |
bool | Returns true if a user can delete the message, false otherwise. |
|
static |
Checks if a user can delete a message for all users.
int | $userid | the user id of who we want to delete the message for all users |
int | $messageid | The message id |
bool | Returns true if a user can delete the message for all users, false otherwise. |
|
static |
Checks if a user can mark all messages as read.
int | $userid | The user id of who we want to mark the messages for |
int | $conversationid | The id of the conversation |
bool | true if user is permitted, false otherwise |
|
static |
Determines if a user is permitted to send another user a private message.
If no sender is provided then it defaults to the logged in user.
stdClass | $recipient | The user object. |
stdClass | null | $sender | The user object. |
bool | true if user is permitted, false otherwise. |
|
static |
Determines if a user is permitted to send another user a private message.
int | $recipientid | The recipient user id. |
int | $senderid | The sender user id. |
bool | $evenifblocked | This lets the user know, that even if the recipient has blocked the user the user is still able to send a message. |
bool | true if user is permitted, false otherwise. |
|
static |
Determines if a user is permitted to send a message to a given conversation.
If no sender is provided then it defaults to the logged in user.
int | $userid | the id of the user on which the checks will be applied. |
int | $conversationid | the id of the conversation we wish to check. |
bool | true if the user can send a message to the conversation, false otherwise. |
moodle_exception |
|
static |
Handles confirming a contact request.
int | $userid | The id of the user who created the contact request |
int | $requesteduserid | The id of the user confirming the request |
|
static |
Count the number of users blocked by a user.
stdClass | $user | The user object |
int | the number of blocked users |
|
static |
Returns the contacts count.
int | $userid | The user id |
array |
|
static |
Count conversation members.
int | $convid | The conversation id. |
int | Number of conversation members. |
dml_exception |
|
static |
Returns the count of unread conversations (collection of messages from a single user) for the given user.
stdClass | $user | the user who's conversations should be counted |
int | the count of the user's unread conversations |
|
static |
Handles creating a contact request.
int | $userid | The id of the user who is creating the contact request |
int | $requesteduserid | The id of the user being requested |
stdClass | the request |
|
static |
Creates a conversation with selected users and messages.
int | $type | The type of conversation |
int[] | $userids | The array of users to add to the conversation |
string | null | $name | The name of the conversation |
int | $enabled | Determines if the conversation is created enabled or disabled |
string | null | $component | Defines the Moodle component which the conversation belongs to, if any |
string | null | $itemtype | Defines the type of the component |
int | null | $itemid | The id of the component |
int | null | $contextid | The id of the context |
stdClass |
|
static |
Creates a conversation between two users.
array | $userids |
int | The id of the conversation |
|
static |
Handles declining a contact request.
int | $userid | The id of the user who created the contact request |
int | $requesteduserid | The id of the user declining the request |
|
static |
Completely removes all related data in the DB for a given conversation.
int | $conversationid | The id of the conversation |
|
static |
Deletes a conversation.
This function does not verify any permissions.
int | $userid | The user id of who we want to delete the messages for (this may be done by the admin but will still seem as if it was by the user) |
int | $otheruserid | The id of the other user in the conversation |
bool |
|
static |
Deletes a conversation for a specified user.
This function does not verify any permissions.
int | $userid | The user id of who we want to delete the messages for (this may be done by the admin but will still seem as if it was by the user) |
int | $conversationid | The id of the other user in the conversation |
|
static |
Deletes a message.
This function does not verify any permissions.
int | $userid | the user id of who we want to delete the message for (this may be done by the admin but will still seem as if it was by the user) |
int | $messageid | The message id |
bool |
|
static |
Delete a message for all users.
This function does not verify any permissions.
int | $messageid | The message id |
void |
|
static |
Disable a conversation.
int | $conversationid | The id of the conversation. |
void |
|
static |
Checks if a contact request already exists between users.
int | $userid | The id of the user who is creating the contact request |
int | $requesteduserid | The id of the user being requested |
bool | Returns true if a contact request exists, false otherwise |
|
static |
Enable a conversation.
int | $conversationid | The id of the conversation. |
void |
|
static |
Returns message preferences.
array | $processors | |
array | $providers | |
stdClass | $user |
stdClass |
|
static |
Retrieve users blocked by $user1.
int | $userid | The user id of the user whos blocked users we are returning |
array | the users blocked |
|
static |
Returns the row in the database table message_contacts that represents the contact between two people.
int | $userid | The id of one of the users |
int | $contactid | The id of the other user |
mixed | A fieldset object containing the record, false otherwise |
|
static |
Handles returning the contact requests for a user.
This also includes the user data necessary to display information about the user.
It will not include blocked users.
int | $userid | |
int | $limitfrom | |
int | $limitnum |
array | The list of contact requests |
|
static |
Get contact requests between users.
int | $userid | The id of the user who is creating the contact request |
int | $requesteduserid | The id of the user being requested |
stdClass[] |
|
static |
Returns the contacts to display in the contacts area.
TODO: This function should be removed once the related web service goes through final deprecation. The related web service is data_for_messagearea_contacts. Followup: MDL-63261
int | $userid | The user id |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Returns the an array of the users the given user is in a conversation with who are a contact and the number of unread messages.
int | $userid | The user id |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Return a conversation.
int | $userid | The user id to get the conversation for |
int | $conversationid | The id of the conversation to fetch |
bool | $includecontactrequests | Should contact requests be included between members |
bool | $includeprivacyinfo | Should privacy info be included between members |
int | $memberlimit | Limit number of members to load |
int | $memberoffset | Offset members by this amount |
int | $messagelimit | Limit number of messages to load |
int | $messageoffset | Offset the messages |
bool | $newestmessagesfirst | Order messages by newest first |
stdClass |
|
static |
Returns the conversation between two users.
array | $userids |
int|bool | The id of the conversation, false if not found |
|
static |
Get conversation by area.
string | $component | Defines the Moodle component which the area was added to. |
string | $itemtype | Defines the type of the component. |
int | $itemid | The id of the component. |
int | $contextid | The id of the context. |
stdClass |
|
static |
Returns the count of conversations (collection of messages from a single user) for the given user.
int | $userid | The user whose conversations should be counted. |
array | the array of conversations counts, indexed by type. |
|
static |
Returns a list of conversation members.
int | $userid | The user we are returning the conversation members for, used by helper::get_member_info. |
int | $conversationid | The id of the conversation |
bool | $includecontactrequests | Do we want to include contact requests with this data? |
bool | $includeprivacyinfo | Do we want to include privacy requests with this data? |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Returns the messages for the defined conversation.
int | $userid | The current user. |
int | $convid | The conversation where the messages belong. Could be an object or just the id. |
int | $limitfrom | Return a subset of records, starting at this point (optional). |
int | $limitnum | Return a subset comprising this many records in total (optional, required if $limitfrom is set). |
string | $sort | The column name to order by including optionally direction. |
int | $timefrom | The time from the message being sent. |
int | $timeto | The time up until the message being sent. |
array | of messages |
|
static |
Returns the contacts and their conversation to display in the contacts area.
** WARNING ** It is HIGHLY recommended to use a sensible limit when calling this function. Trying to retrieve too much information in a single call will cause performance problems. ** WARNING **
This function has specifically been altered to break each of the data sets it requires into separate database calls. This is to avoid the performance problems observed when attempting to join large data sets (e.g. the message tables and the user table).
While it is possible to gather the data in a single query, and it may even be more efficient with a correctly tuned database, we have opted to trade off some of the benefits of a single query in order to ensure this function will work on most databases with default tunings and with large data sets.
int | $userid | The user id |
int | $limitfrom | |
int | $limitnum | |
int | $type | the type of the conversation, if you wish to filter to a certain type (see api constants). |
bool | $favourites | whether to include NO favourites (false) or ONLY favourites (true), or null to ignore this setting. |
bool | $mergeself | whether to include self-conversations (true) or ONLY private conversations (false) when private conversations are requested. |
array | the array of conversations |
moodle_exception |
|
static |
Returns all conversations between two users.
int | $userid1 | One of the user's id |
int | $userid2 | The other user's id |
int | $limitfrom | |
int | $limitnum |
array |
dml_exception |
|
static |
Returns the conversations between sets of users.
The returned array of results will be in the same order as the requested arguments, null will be returned if there is no conversation for that user pair.
For example: If we have 6 users with ids 1, 2, 3, 4, 5, 6 where only 2 conversations exist. One between 1 and 2 and another between 5 and 6.
Then if we call: $conversations = get_individual_conversations_between_users([[1,2], [3,4], [5,6]]);
The conversations array will look like: [<conv_record>, null, <conv_record>];
Where null is returned for the pairing of [3, 4] since no record exists.
array | $useridsets | An array of arrays where the inner array is the set of user ids |
stdClass[] | Array of conversation records |
|
staticprotected |
Gets extra fields, like image url and subname for any conversations linked to components.
The subname is like a subtitle for the conversation, to compliment it's name. The imageurl is the location of the image for the conversation, as might be seen on a listing of conversations for a user.
array | $conversations | a list of conversations records. |
array | the array of subnames, index by conversation id. |
coding_exception | |
dml_exception |
|
static |
Get specified message processor, validate corresponding plugin existence and system configuration.
string | $name | Name of the processor. |
bool | $ready | only return ready-to-use processors. |
mixed::$processor | if processor present else empty array. |
|
static |
Returns the messages to display in the message area.
TODO: This function should be removed once the related web service goes through final deprecation. The related web service is data_for_messagearea_messages. Followup: MDL-63261
int | $userid | the current user |
int | $otheruserid | the other user |
int | $limitfrom | |
int | $limitnum | |
string | $sort | |
int | $timefrom | the time from the message being sent |
int | $timeto | the time up until the message being sent |
array |
|
static |
Returns the most recent message in a conversation.
int | $convid | The conversation identifier. |
int | $currentuserid | The current user identifier. |
stdClass|null | The most recent message. |
|
static |
Returns the most recent message between two users.
TODO: This function should be removed once the related web service goes through final deprecation. The related web service is data_for_messagearea_get_most_recent_message. Followup: MDL-63261
int | $userid | the current user |
int | $otheruserid | the other user |
stdClass|null |
|
static |
Returns the an array of the users the given user is in a conversation with who are not a contact and the number of unread messages.
int | $userid | The user id |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Given a processor object, loads information about it's settings and configurations.
This is not a public api, instead use
stdClass | $processor | processor object |
stdClass | processed processor object |
|
static |
Returns the profile information for a contact for a user.
TODO: This function should be removed once the related web service goes through final deprecation. The related web service is data_for_messagearea_get_profile. Followup: MDL-63261
int | $userid | The user id |
int | $otheruserid | The id of the user whose profile we want to view. |
stdClass |
|
static |
Returns the number of contact requests the user has received.
int | $userid | The ID of the user we want to return the number of received contact requests for |
int | The count |
|
static |
Returns the self conversation for a user.
int | $userid | The user id to get the self-conversations |
stdClass|false | The self-conversation object or false if it doesn't exist |
|
static |
Get the unread counts for all conversations for the user, sorted by type, and including favourites.
int | $userid | the id of the user whose conversations we'll check. |
array | the unread counts for each conversation, indexed by type. |
|
static |
Get the contacts for a given user.
int | $userid | |
int | $limitfrom | |
int | $limitnum |
array | An array of contacts |
|
static |
Get the messaging preference for a user.
If the user has not any messaging privacy preference:
int | $userid | The user identifier. |
int | The default messaging preference. |
|
static |
Checks if a user is already blocked.
int | $userid | |
int | $blockeduserid |
bool | Returns true if they are a blocked, false otherwise |
|
static |
Checks if users are already contacts.
int | $userid | The id of one of the users |
int | $contactid | The id of the other user |
bool | Returns true if they are a contact, false otherwise |
|
static |
Checks whether or not a conversation area is enabled.
string | $component | Defines the Moodle component which the area was added to. |
string | $itemtype | Defines the type of the component. |
int | $itemid | The id of the component. |
int | $contextid | The id of the context. |
bool | Returns if a conversation area exists and is enabled, false otherwise |
|
static |
Checks whether a conversation is muted or not.
int | $userid | The id of the user |
int | $conversationid | The id of the conversation |
bool | Whether or not the conversation is muted or not |
|
static |
Returns weather a given processor is enabled or not.
Note:- This doesn't check if the processor is configured or not.
string | $name | Name of the processor |
bool |
|
static |
Checks if the recipient has specifically blocked the sending user.
Note: This function will always return false if the sender has the readallmessages capability at the system context level.
int | $recipientid | User ID of the recipient. |
int | $senderid | User ID of the sender. |
bool | true if $sender is blocked, false otherwise. |
|
static |
Checks if a user is already in a conversation.
int | $userid | The id of the user we want to check if they are in a group |
int | $conversationid | The id of the conversation |
bool | Returns true if a contact request exists, false otherwise |
|
static |
Checks if the recipient is allowing messages from users that aren't a contact.
If not then it checks to make sure the sender is in the recipient's contacts.
stdClass | $recipient | The user object. |
stdClass | null | $sender | The user object. |
bool | true if $sender is blocked, false otherwise. |
|
staticprotected |
Create a self conversation for a user, only if one doesn't already exist.
int | $userid | the user to whom the conversation belongs. |
|
static |
Marks all messages being sent to a user in a particular conversation.
If $conversationdid is null then it marks all messages as read sent to $userid.
int | $userid | |
int | null | $conversationid | The conversation the messages belong to mark as read, if null mark all |
|
static |
Marks all notifications being sent from one user to another user as read.
If the from user is null then it marks all notifications as read sent to the to user.
int | $touserid | the id of the message recipient |
int | null | $fromuserid | the id of the message sender, null if all messages |
int | null | $timecreatedto | mark notifications created before this time as read |
void |
|
static |
|
static |
Mark a single message as read.
int | $userid | The user id who marked the message as read |
stdClass | $message | The message |
int | null | $timeread | The time the message was marked as read, if null will default to time() |
|
static |
Mark a single notification as read.
stdClass | $notification | The notification |
int | null | $timeread | The time the message was marked as read, if null will default to time() |
|
static |
Handles searching for user.
int | $userid | The user id doing the searching |
string | $search | The string the user is searching |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Handles muting a conversation.
int | $userid | The id of the user |
int | $conversationid | The id of the conversation |
|
static |
Handles removing a contact.
int | $userid | The id of the user who is removing a user as a contact |
int | $contactid | The id of the user to be removed as a contact |
|
static |
Remove some members from an existing conversation.
array | $userids | The user ids to remove from conversation members. |
int | $convid | The conversation id. Must exists. |
dml_exception | |
moodle_exception | If trying to remove a member(s) from a non-group conversation |
|
static |
Handles searching for messages in the message area.
int | $userid | The user id doing the searching |
string | $search | The string the user is searching |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Handles searching for user in the message area.
TODO: This function should be removed once the related web service goes through final deprecation. The related web service is data_for_messagearea_search_users. Followup: MDL-63261
int | $userid | The user id doing the searching |
string | $search | The string the user is searching |
int | $limitnum |
array |
|
static |
Handles searching for user in a particular course in the message area.
TODO: This function should be removed once the related web service goes through final deprecation. The related web service is data_for_messagearea_search_users_in_course. Followup: MDL-63261
int | $userid | The user id doing the searching |
int | $courseid | The id of the course we are searching in |
string | $search | The string the user is searching |
int | $limitfrom | |
int | $limitnum |
array |
|
static |
Send a message from a user to a conversation.
This method will create the basic eventdata and delegate to message creation to message_send. The message_send() method is responsible for event data that is specific to each recipient.
int | $userid | the sender id. |
int | $conversationid | the conversation id. |
string | $message | the message to send. |
int | $format | the format of the message to send. |
stdClass | the message created. |
coding_exception | |
moodle_exception | if the user is not permitted to send a message to the conversation. |
|
static |
Mark a conversation as a favourite for the given user.
int | $conversationid | the id of the conversation to mark as a favourite. |
int | $userid | the id of the user to whom the favourite belongs. |
favourite | the favourite object. |
moodle_exception | if the user or conversation don't exist. |
|
static |
Handles unblocking a user.
int | $userid | The id of the user who is unblocking |
int | $usertounblockid | The id of the user being unblocked |
|
static |
Handles unmuting a conversation.
int | $userid | The id of the user |
int | $conversationid | The id of the conversation |
|
static |
Unset a conversation as a favourite for the given user.
int | $conversationid | the id of the conversation to unset as a favourite. |
int | $userid | the id to whom the favourite belongs. |
moodle_exception | if the favourite does not exist for the user. |
|
static |
Update the name of a conversation.
int | $conversationid | The id of a conversation. |
string | $name | The main name of the area |
void |
|
static |
Set status of a processor.
stdClass | $processor | processor record. |
0 | 1 | $enabled | 0 or 1 to set the processor status. |
bool |