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.
/message/ -> lib.php (source)

Functions that are not part of a class:

message_format_message_text($message, $forcetexttohtml = false)   X-Ref
Try to guess how to convert the message to html.

param: stdClass $message
param: bool $forcetexttohtml
return: string html fragment

message_search_users($courseids, $searchtext, $sort='', $exceptions='')   X-Ref
Search through course users.

If $courseids contains the site course then this function searches
through all undeleted and confirmed users.

param: int|array $courseids Course ID or array of course IDs.
param: string $searchtext the text to search for.
param: string $sort the column name to order by.
param: string|array $exceptions comma separated list or array of user IDs to exclude.
return: array An array of {@link $USER} records.

message_format_message($message, $format='', $keywords='', $class='other')   X-Ref
Format a message for display in the message history

param: object $message the message object
param: string $format optional date format
param: string $keywords keywords to highlight
param: string $class CSS class to apply to the div around the message
return: string the formatted message

message_format_contexturl($message)   X-Ref
Format a the context url and context url name of a message for display

param: object $message the message object
return: string the formatted string

message_post_message($userfrom, $userto, $message, $format)   X-Ref
Send a message from one user to another. Will be delivered according to the message recipients messaging preferences

param: object $userfrom the message sender
param: object $userto the message recipient
param: string $message the message
param: int $format message format such as FORMAT_PLAIN or FORMAT_HTML
return: int|false the ID of the new message or false

get_message_processors($ready = false, $reset = false, $resetonly = false)   X-Ref
Get all message processors, validate corresponding plugin existance and
system configuration

param: bool $ready only return ready-to-use processors
param: bool $reset Reset list of message processors (used in unit tests)
param: bool $resetonly Just reset, then exit
return: mixed $processors array of objects containing information on message processors

get_message_providers()   X-Ref
Get all message providers, validate their plugin existance and
system configuration

return: mixed $processors array of objects containing information on message processors

get_message_processor($type)   X-Ref
Get an instance of the message_output class for one of the output plugins.

param: string $type the message output type. E.g. 'email' or 'jabber'.
return: message_output message_output the requested class.

get_message_output_default_preferences()   X-Ref
Get messaging outputs default (site) preferences

return: object $processors object containing information on message processors

translate_message_default_setting($plugindefault, $processorname)   X-Ref
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.

param: int    $plugindefault Default setting suggested by plugin
param: string $processorname The name of processor
return: array  $settings array of strings in the order: $locked, $enabled.

message_page_type_list(string $pagetype, ?context $parentcontext, ?context $currentcontext)   X-Ref
Return a list of page types

param: string $pagetype current page type
param: context|null $parentcontext Block's parent context
param: context|null $currentcontext Current context of block
return: array

message_get_messages($useridto, $useridfrom = 0, $notifications = -1, $read = MESSAGE_GET_READ,$sort = 'mr.timecreated DESC', $limitfrom = 0, $limitnum = 0)   X-Ref
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.

param: int      $useridto       the user id who received the message
param: int      $useridfrom     the user id who sent the message. -10 or -20 for no-reply or support user
param: int      $notifications  1 for retrieving notifications, 0 for messages, -1 for both
param: int      $read           Either MESSAGE_GET_READ, MESSAGE_GET_UNREAD or MESSAGE_GET_READ_AND_UNREAD.
param: string   $sort           the column name to order by including optionally direction
param: int      $limitfrom      limit from
param: int      $limitnum       limit num
return: external_description

message_output_fragment_processor_settings($args = [])   X-Ref
Handles displaying processor settings in a fragment.

param: array $args
return: bool|string

core_message_can_edit_message_profile($user)   X-Ref
Checks if current user is allowed to edit messaging preferences of another user

param: stdClass $user user whose preferences we are updating
return: bool

core_message_user_preferences()   X-Ref
Implements callback user_preferences, lists preferences that users are allowed to update directly

Used in {@see core_user::fill_preferences_cache()}, see also {@see useredit_update_user_preference()}

return: array

core_message_standard_after_main_region_html()   X-Ref
Render the message drawer to be included in the top of the body of each page.

return: string HTML