|
Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
Functions | |
| message_get_providers_for_user ($userid) | |
| Returns the active providers for the user specified, based on capability. | |
| message_get_providers_from_db ($component) | |
| Gets the message providers that are in the database for this component. | |
| message_get_providers_from_file ($component) | |
| Loads the messages definitions for a component from file. | |
| message_handle_phpunit_redirection (\core\message\message $eventdata, string $table, stdClass $tabledata) | |
| Helper method containing the PHPUnit specific code, used to redirect and capture messages/notifications. | |
| message_processor_uninstall ($name) | |
| Uninstall a message processor. | |
| message_provider_uninstall ($component) | |
| Remove all message providers for particular component and corresponding settings. | |
| message_send (\core\message\message $eventdata) | |
| Called when a message provider wants to send a message. | |
| message_set_default_message_preference ($component, $messagename, $fileprovider, $processorname='') | |
| Setting default messaging preferences for particular message provider. | |
| message_update_processors ($processorname) | |
| This function populates default message preferences for all existing providers when the new message processor is added. | |
| message_update_providers ($component='moodle') | |
| Updates the message_providers table with the current set of message providers. | |
| message_get_providers_for_user | ( | $userid | ) |
Returns the active providers for the user specified, based on capability.
| int | $userid | id of user |
| array | An array of message providers |
| message_get_providers_from_db | ( | $component | ) |
Gets the message providers that are in the database for this component.
This is an internal function used within messagelib.php
| string | $component | A moodle component like 'moodle', 'mod_forum', 'block_activity_results' |
| array | An array of message providers |
| message_get_providers_from_file | ( | $component | ) |
Loads the messages definitions for a component from file.
If no messages are defined for the component, return an empty array. This is an internal function used within messagelib.php
| string | $component | A moodle component like 'moodle', 'mod_forum', 'block_activity_results' |
| array | An array of message providers or empty array if not exists |
| message_handle_phpunit_redirection | ( | \core\message\message | $eventdata, |
| string | $table, | ||
| stdClass | $tabledata ) |
Helper method containing the PHPUnit specific code, used to redirect and capture messages/notifications.
| core\message\message | $eventdata | the message object |
| string | $table | the table to store the tabledata in, either messages or notifications. |
| stdClass | $tabledata | the data to be stored when creating the message/notification. |
| int | the id of the stored message. |
| message_processor_uninstall | ( | $name | ) |
Uninstall a message processor.
| string | $name | A message processor name like 'email', 'jabber' |
| message_provider_uninstall | ( | $component | ) |
Remove all message providers for particular component and corresponding settings.
| string | $component | A moodle component like 'moodle', 'mod_forum', 'block_activity_results' |
| void |
| message_send | ( | \core\message\message | $eventdata | ) |
Called when a message provider wants to send a message.
This functions checks the message recipient's message processor configuration then sends the message to the configured processors
Required parameters of the $eventdata object: component string component name. must exist in message_providers name string message type name. must exist in message_providers userfrom object|int the user sending the message userto object|int the message recipient subject string the message subject fullmessage string the full message in a given format fullmessageformat int the format if the full message (FORMAT_MOODLE, FORMAT_HTML, ..) fullmessagehtml string the full version (the message processor will choose with one to use) smallmessage string the small version of the message
Optional parameters of the $eventdata object: notification bool should the message be considered as a notification rather than a personal message contexturl string if this is a notification then you can specify a url to view the event. For example the forum post the user is being notified of. contexturlname string the display text for contexturl
Note: processor failure will not reported as false return value in all scenarios, for example when it is called while a database transaction is open, earlier versions did not do it consistently either.
| core\message\message | $eventdata | information about the message (component, userfrom, userto, ...) |
| mixed | the integer ID of the new message or false if there was a problem (with submitted data or sending the message to the message processor) |
| message_set_default_message_preference | ( | $component, | |
| $messagename, | |||
| $fileprovider, | |||
| $processorname = '' ) |
Setting default messaging preferences for particular message provider.
| string | $component | The name of component (e.g. moodle, mod_forum, etc.) |
| string | $messagename | The name of message provider |
| array | $fileprovider | The value of $messagename key in the array defined in plugin messages.php |
| string | $processorname | The optional name of message processor |
| message_update_processors | ( | $processorname | ) |
This function populates default message preferences for all existing providers when the new message processor is added.
| string | $processorname | The name of message processor plugin (e.g. 'email', 'jabber') |
| invalid_parameter_exception | if $processorname does not exist in the database |
| message_update_providers | ( | $component = 'moodle' | ) |
Updates the message_providers table with the current set of message providers.
| string | $component | For example 'moodle', 'mod_forum' or 'block_activity_results' |
| boolean | True on success |