Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403]

New messaging manager class.

Author: Petr Skoda <petr.skoda@totaralms.com>
Copyright: 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 513 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: manager  - X-Ref

Class used for various messaging related stuff.

Note: Do NOT use directly in your code, it is intended to be used from core code only.

send_message_to_conversation(message $eventdata, \stdClass $savemessage)   X-Ref
Used for calling processors, and generating event data when sending a message to a conversation.

This is ONLY used for messages of type 'message' (notification=0), and is responsible for:

1. generation of per-user event data (to pass to processors)
2. generation of the processors for each recipient member of the conversation
3. calling said processors for each member, passing in the per-user (local) eventdata.
4. generation of an appropriate event for the message send, depending on the conversation type
- messages to individual conversations generate a 'message_sent' event (as per legacy send_message())
- messages to group conversations generate a 'group_message_sent' event.

param: message $eventdata
param: \stdClass $savemessage
return: int

send_conversation_message_to_processors(array $eventprocmaps, message $eventdata,\stdClass $savemessage)   X-Ref
Takes a list of localised event data, and tries to send them to their respective member's message processors.

Input format:
[CONVID => [$localisedeventdata, $savemessage, $processorlist], ].

param: array $eventprocmaps the array of localised event data and processors for each member of the conversation.
param: message $eventdata the original conversation message eventdata
param: \stdClass $savemessage the saved message record.

send_message(message $eventdata, \stdClass $savemessage, array $processorlist)   X-Ref
Do the message sending.

NOTE: to be used from message_send() only.

param: \core\message\message $eventdata fully prepared event data for processors
param: \stdClass $savemessage the message saved in 'message' table
param: array $processorlist list of processors for target user
return: int $messageid the id from 'messages' (false is not returned)

send_message_to_processors($eventdata, \stdClass $savemessage, array$processorlist)   X-Ref
Send message to message processors.

param: \stdClass|\core\message\message $eventdata
param: \stdClass $savemessage
param: array $processorlist
return: int $messageid

database_transaction_commited()   X-Ref
Notification from DML layer.

Note: to be used from DML layer only.

database_transaction_rolledback()   X-Ref
Notification from DML layer.

Note: to be used from DML layer only.

process_buffer()   X-Ref
Sent out any buffered messages if necessary.


trigger_message_events(message $eventdata, \stdClass $savemessage)   X-Ref
Trigger an appropriate message creation event, based on the supplied $eventdata and $savemessage.

param: message $eventdata the eventdata for the message.
param: \stdClass $savemessage the message record.

call_processors(message $eventdata, array $processorlist)   X-Ref
For each processor, call it's send_message() method.

param: message $eventdata the message object.
param: array $processorlist the list of processors for a single user.
return: bool false if error calling message processor