Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 9 May 2022 (12 months).
  • Bug fixes for security issues in 3.11.x will end 14 November 2022 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
  • /message/ -> lib.php (source)

    Functions that are not part of a class:

    message_count_unread_messages($user1=null, $user2=null)   X-Ref
    Returns the count of unread messages for user. Either from a specific user or from all users.

    return: int the count of $user1's unread messages
    param: object $user1 the first user. Defaults to $USER
    param: object $user2 the second user. If null this function will count all of user 1's unread messages.

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

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

    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.

    return: array An array of {@link $USER} records.
    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.

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

    return: string the formatted message
    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

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

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

    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

    return: int|false the ID of the new message or false
    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

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

    return: mixed $processors array of objects containing information on message processors
    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

    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.

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

    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.

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

    message_get_messages($useridto, $useridfrom = 0, $notifications = -1, $read = true,$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.

    return: external_description
    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: bool     $read           true for retrieving read messages, false for unread
    param: string   $sort           the column name to order by including optionally direction
    param: int      $limitfrom      limit from
    param: int      $limitnum       limit num

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

    return: bool|string
    param: array $args

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

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

    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