Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Namespaces | |
namespace | core\message |
namespace | core\message\inbound |
namespace | core_message |
namespace | core_message\external |
namespace | core_message\output |
namespace | core_message\output\preferences |
namespace | core_message\privacy |
namespace | core_message\search |
namespace | core_message\task |
namespace | core_message\tests |
Classes | |
class | behat_message |
Messaging system steps definitions. More... | |
class | core\message\inbound\address_manager |
Incoming Message address manager. More... | |
class | core\message\inbound\handler |
class | core\message\inbound\manager |
Variable Envelope Return Path manager class. More... | |
class | core\message\inbound\private_files_handler |
A Handler to store attachments sent in e-mails as private files. More... | |
class | core\message\inbound\processing_failed_exception |
Variable Envelope Return Path message processing failure exception. More... | |
class | core\message\message |
New messaging class. More... | |
class | core_message\external\get_unread_notification_count |
class | core_message\helper |
Helper class for the message area. More... | |
class | core_message\hook_callbacks |
class | core_message\output\preferences\message_notification_list |
Class to create context for the list of notifications on the message preferences page. More... | |
class | core_message\output\preferences\message_notification_list_component |
Class to create context for a notification component on the message preferences page. More... | |
class | core_message\output\preferences\notification_list |
Class to create context for the list of notifications on the message preferences page. More... | |
class | core_message\output\preferences\notification_list_component |
Class to create context for a notification component on the message preferences page. More... | |
class | core_message\output\preferences\notification_list_processor |
Class to create context for a notification component on the message preferences page. More... | |
class | core_message\output\preferences\processor |
Class to create context for one of the message processors settings on the message preferences page. More... | |
class | core_message\output\processor |
Class to prepare a message processor for display. More... | |
class | core_message\privacy\provider |
Privacy Subsystem implementation for core_message. More... | |
class | core_message\search\base_message |
Search area base class for messages. More... | |
class | core_message\search\message_received |
Search area for received messages. More... | |
class | core_message\search\message_sent |
Search area for sent messages. More... | |
class | core_message\task\migrate_message_data |
Class handling migrating data to the new messaging table schema. More... | |
class | core_message\tests\helper |
The helper class providing util methods for testing. More... | |
class | core_message\time_last_message_between_users |
Cache data source for the time of the last message in a conversation. More... | |
class | core_message_external |
Message external functions. More... | |
class | core_message_renderer |
message Renderer More... | |
class | message_output |
Base message processor class for extension by message processors. More... | |
Functions | |
core_message_can_edit_message_profile ($user) | |
Checks if current user is allowed to edit messaging preferences of another user. | |
core_message_user_preferences () | |
Implements callback user_preferences, lists preferences that users are allowed to update directly. | |
get_message_output_default_preferences () | |
Get messaging outputs default (site) preferences. | |
get_message_processor ($type) | |
Get an instance of the message_output class for one of the output plugins. | |
get_message_processors ($ready=false, $reset=false, $resetonly=false) | |
Get all message processors, validate corresponding plugin existance and system configuration. | |
get_message_providers () | |
Get all message providers, validate their plugin existance and system configuration. | |
message_format_contexturl ($message) | |
Format a the context url and context url name of a message for display. | |
message_format_message ($message, $format='', $keywords='', $class='other') | |
Format a message for display in the message history. | |
message_get_messages ($useridto, $useridfrom=0, $notifications=-1, $read=MESSAGE_GET_READ, $sort='mr.timecreated DESC', $limitfrom=0, $limitnum=0) | |
Get messages sent or/and received by the specified users. | |
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_output_fragment_processor_settings ($args=[]) | |
Handles displaying processor settings in a fragment. | |
message_page_type_list (string $pagetype, ?context $parentcontext, ?context $currentcontext) | |
Return a list of page types. | |
message_post_message ($userfrom, $userto, $message, $format) | |
Send a message from one user to another. | |
message_processor_uninstall ($name) | |
Uninstall a message processor. | |
message_provider_uninstall ($component) | |
Remove all message providers for particular component and corresponding settings. | |
message_search_users ($courseids, $searchtext, $sort='', $exceptions='') | |
Search through course users. | |
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. | |
translate_message_default_setting ($plugindefault, $processorname) | |
Translate message default settings from binary value to the array of string representing the settings to be stored. | |
Variables | |
global | core_message\external::$CFG |
$handlers | |
const | MESSAGE_DEFAULT_ENABLED 0x01 |
const | MESSAGE_DEFAULT_LOGGEDIN 0x01 |
Define contants for messaging default settings population. | |
const | MESSAGE_DEFAULT_LOGGEDOFF 0x02 |
const | MESSAGE_DEFAULT_MAX_POLL_IN_SECONDS 2 * MINSECS |
const | MESSAGE_DEFAULT_MIN_POLL_IN_SECONDS 10 |
Set default values for polling. | |
const | MESSAGE_DEFAULT_PERMITTED 'permitted' |
Set default value for default outputs permitted setting. | |
const | MESSAGE_DEFAULT_TIMEOUT_POLL_IN_SECONDS 5 * MINSECS |
const | MESSAGE_DISALLOWED 0x04 |
const | MESSAGE_FORCED 0x0c |
const | MESSAGE_GET_READ 1 |
const | MESSAGE_GET_READ_AND_UNREAD 2 |
const | MESSAGE_GET_UNREAD 0 |
To get only read, unread or both messages or notifications. | |
const | MESSAGE_HISTORY_ALL 1 |
const | MESSAGE_PERMITTED 0x08 |
const | MESSAGE_PERMITTED_MASK 0x0c |
const | MESSAGE_SEARCH_MAX_RESULTS 200 |
const | MESSAGE_SHORTLENGTH 300 |
const | MESSAGE_TYPE_MESSAGE 'message' |
const | MESSAGE_TYPE_NOTIFICATION 'notification' |
core_message_can_edit_message_profile | ( | $user | ) |
Checks if current user is allowed to edit messaging preferences of another user.
stdClass | $user | user whose preferences we are updating |
bool |
core_message_user_preferences | ( | ) |
Implements callback user_preferences, lists preferences that users are allowed to update directly.
Used in {
array |
get_message_output_default_preferences | ( | ) |
Get messaging outputs default (site) preferences.
object\$processors | object containing information on message processors |
get_message_processor | ( | $type | ) |
Get an instance of the message_output class for one of the output plugins.
string | $type | the message output type. E.g. 'email' or 'jabber'. |
message_output | message_output the requested class. |
get_message_processors | ( | $ready = false, | |
$reset = false, | |||
$resetonly = false ) |
Get all message processors, validate corresponding plugin existance and system configuration.
bool | $ready | only return ready-to-use processors |
bool | $reset | Reset list of message processors (used in unit tests) |
bool | $resetonly | Just reset, then exit |
mixed\$processors | array of objects containing information on message processors |
get_message_providers | ( | ) |
Get all message providers, validate their plugin existance and system configuration.
mixed\$processors | array of objects containing information on message processors |
message_format_contexturl | ( | $message | ) |
Format a the context url and context url name of a message for display.
object | $message | the message object |
string | the formatted string |
message_format_message | ( | $message, | |
$format = '', | |||
$keywords = '', | |||
$class = 'other' ) |
Format a message for display in the message history.
object | $message | the message object |
string | $format | optional date format |
string | $keywords | keywords to highlight |
string | $class | CSS class to apply to the div around the message |
string | the formatted message |
message_get_messages | ( | $useridto, | |
$useridfrom = 0, | |||
$notifications = -1, | |||
$read = MESSAGE_GET_READ, | |||
$sort = 'mr.timecreated DESC', | |||
$limitfrom = 0, | |||
$limitnum = 0 ) |
Get messages sent or/and received by the specified users.
Please note that this function return deleted messages too. Besides, only individual conversation messages are returned to maintain backwards compatibility.
int | $useridto | the user id who received the message |
int | $useridfrom | the user id who sent the message. -10 or -20 for no-reply or support user |
int | $notifications | 1 for retrieving notifications, 0 for messages, -1 for both |
int | $read | Either MESSAGE_GET_READ, MESSAGE_GET_UNREAD or MESSAGE_GET_READ_AND_UNREAD. |
string | $sort | the column name to order by including optionally direction |
int | $limitfrom | limit from |
int | $limitnum | limit num |
external_description |
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_output_fragment_processor_settings | ( | $args = [] | ) |
Handles displaying processor settings in a fragment.
array | $args |
bool|string |
moodle_exception |
message_page_type_list | ( | string | $pagetype, |
?context | $parentcontext, | ||
?context | $currentcontext ) |
Return a list of page types.
string | $pagetype | current page type |
context | null | $parentcontext | Block's parent context |
context | null | $currentcontext | Current context of block |
array |
message_post_message | ( | $userfrom, | |
$userto, | |||
$message, | |||
$format ) |
Send a message from one user to another.
Will be delivered according to the message recipients messaging preferences
object | $userfrom | the message sender |
object | $userto | the message recipient |
string | $message | the message |
int | $format | message format such as FORMAT_PLAIN or FORMAT_HTML |
int|false | the ID of the new message or false |
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_search_users | ( | $courseids, | |
$searchtext, | |||
$sort = '', | |||
$exceptions = '' ) |
Search through course users.
If $courseids contains the site course then this function searches through all undeleted and confirmed users.
int | array | $courseids | Course ID or array of course IDs. |
string | $searchtext | the text to search for. |
string | $sort | the column name to order by. |
string | array | $exceptions | comma separated list or array of user IDs to exclude. |
array | An array of $USER records. |
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 |
translate_message_default_setting | ( | $plugindefault, | |
$processorname ) |
Translate message default settings from binary value to the array of string representing the settings to be stored.
Also validate the provided value and use default if it is malformed.
int | $plugindefault | Default setting suggested by plugin |
string | $processorname | The name of processor |
array\$settings | array of strings in the order: $locked, $enabled. |
$handlers |
const MESSAGE_DEFAULT_LOGGEDIN 0x01 |
Define contants for messaging default settings population.
For unambiguity of plugin developer intentions we use 4-bit value (LSB numbering): bit 0 - whether to send message (MESSAGE_DEFAULT_ENABLED) bit 1 - Deprecated: whether to send message (MESSAGE_DEFAULT_LOGGEDOFF). Used to mean only when the user is logged off. bit 2..3 - messaging permission (MESSAGE_DISALLOWED|MESSAGE_PERMITTED|MESSAGE_FORCED)
MESSAGE_PERMITTED_MASK contains the mask we use to distinguish permission setting.
const MESSAGE_DEFAULT_LOGGEDOFF 0x02 |
const MESSAGE_DEFAULT_PERMITTED 'permitted' |
Set default value for default outputs permitted setting.