Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Files | Namespaces | Classes | Functions | Variables
core_message

Files

file  address_manager.php
 Incoming Message address manager.
 
file  api.php
 Contains class used to return information to display for the message area.
 
file  base_message.php
 Search area base class for messages.
 
file  behat_message.php
 Behat message-related steps definitions.
 
file  contact.php
 Contains class used to prepare a contact for display.
 
file  contacts.php
 Contains class used to prepare the contacts for display.
 
file  externallib.php
 External message API.
 
file  handler.php
 Abstract class describing Inbound Message Handlers.
 
file  helper.php
 Contains helper class for the message area.
 
file  helper.php
 Contains a helper class providing util methods for testing.
 
file  lib.php
 Library functions for messaging.
 
file  lib.php
 Contains a base class for extension by message processors.
 
file  manager.php
 Variable Envelope Return Path management.
 
file  manager.php
 New messaging manager class.
 
file  message.php
 New messaging class.
 
file  message.php
 Contains class used to prepare a message for display.
 
file  message_area.php
 Contains class used to prepare the message area for display.
 
file  message_notification_list.php
 Contains message_notification_list class for displaying on message preferences page.
 
file  message_notification_list_component.php
 Contains notification_list_component class for displaying on message preferences page.
 
file  message_received.php
 Search area for received messages.
 
file  message_sent.php
 Search area for sent messages.
 
file  messageinbound_handlers.php
 Inbound Message Handlers for core.
 
file  messagelib.php
 Functions for interacting with the message system.
 
file  messages.php
 Contains class used to prepare the messages for display.
 
file  migrate_message_data.php
 Adhoc task handling migrating data to the new messaging table schema.
 
file  notification_list.php
 Contains notification_list class for displaying on message preferences page.
 
file  notification_list_component.php
 Contains notification_list_component class for displaying on message preferences page.
 
file  notification_list_processor.php
 Contains notification_list_processor class for displaying on message preferences page.
 
file  private_files_handler.php
 A Handler to store attachments sent in e-mails as private files.
 
file  processing_failed_exception.php
 Variable Envelope Return Path message processing failure exception.
 
file  processor.php
 Contains processor class for displaying on message preferences page.
 
file  processor.php
 Contains class used to prepare a message processor for display.
 
file  profile.php
 Contains class used to prepare a profile for display.
 
file  provider.php
 Privacy Subsystem implementation for core_message.
 
file  renderer.php
 Contains renderer objects for messaging.
 
file  time_last_message_between_users.php
 Cache data source for the time of the last message between users.
 
file  user_search_results.php
 Contains class used to display user search results.
 

Namespaces

namespace  core\message
  
 
namespace  core\message\inbound
  
 
namespace  core_message
  
 
namespace  core_message\output
  
 
namespace  core_message\output\messagearea
  
 
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
 
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\api
 Class used to return information to display for the message area. More...
 
class  core_message\helper
 Helper class for the message area. More...
 
class  core_message\output\messagearea\contact
 Class to prepare a contact for display. More...
 
class  core_message\output\messagearea\contacts
 Class to prepare the contacts for display. More...
 
class  core_message\output\messagearea\message
 Class to prepare a message for display. More...
 
class  core_message\output\messagearea\message_area
 Class to prepare the message area for display. More...
 
class  core_message\output\messagearea\messages
 Class to prepare the messages for display. More...
 
class  core_message\output\messagearea\profile
 Class to prepare a profile for display. More...
 
class  core_message\output\messagearea\user_search_results
 Class used to display user search results. More...
 
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
 
class  core_message_external
 
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. More...
 
 core_message_standard_after_main_region_html ()
 Render the message drawer to be included in the top of the body of each page. More...
 
 core_message_user_preferences ()
 Implements callback user_preferences, whitelists preferences that users are allowed to update directly. More...
 
 get_message_output_default_preferences ()
 Get messaging outputs default (site) preferences. More...
 
 get_message_processor ($type)
 Get an instance of the message_output class for one of the output plugins. More...
 
 get_message_processors ($ready=false, $reset=false, $resetonly=false)
 Get all message processors, validate corresponding plugin existance and system configuration. More...
 
 get_message_providers ()
 Get all message providers, validate their plugin existance and system configuration. More...
 
 message_count_unread_messages ($user1=null, $user2=null)
 Returns the count of unread messages for user. More...
 
 message_format_contexturl ($message)
 Format a the context url and context url name of a message for display. More...
 
 message_format_message ($message, $format='', $keywords='', $class='other')
 Format a message for display in the message history. More...
 
 message_get_messages ($useridto, $useridfrom=0, $notifications=-1, $read=true, $sort='mr.timecreated DESC', $limitfrom=0, $limitnum=0)
 Get messages sent or/and received by the specified users. More...
 
 message_get_providers_for_user ($userid)
 Returns the active providers for the user specified, based on capability. More...
 
 message_get_providers_from_db ($component)
 Gets the message providers that are in the database for this component. More...
 
 message_get_providers_from_file ($component)
 Loads the messages definitions for a component from file. More...
 
 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. More...
 
 message_output_fragment_processor_settings ($args=[])
 Handles displaying processor settings in a fragment. More...
 
 message_post_message ($userfrom, $userto, $message, $format)
 Send a message from one user to another. More...
 
 message_processor_uninstall ($name)
 Uninstall a message processor. More...
 
 message_provider_uninstall ($component)
 Remove all message providers for particular component and corresponding settings. More...
 
 message_search_users ($courseids, $searchtext, $sort='', $exceptions='')
 Search through course users. More...
 
 message_send (\core\message\message $eventdata)
 
 message_set_default_message_preference ($component, $messagename, $fileprovider, $processorname='')
 Setting default messaging preferences for particular message provider. More...
 
 message_update_processors ($processorname)
 This function populates default message preferences for all existing providers when the new message processor is added. More...
 
 message_update_providers ($component='moodle')
 Updates the message_providers table with the current set of message providers. More...
 
 translate_message_default_setting ($plugindefault, $processorname)
 Translate message default settings from binary value to the array of string representing the settings to be stored. More...
 

Variables

 $handlers
 
const MESSAGE_DEFAULT_LOGGEDIN 0x01
 Define contants for messaging default settings population. More...
 
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_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'
 

Detailed Description

Function Documentation

◆ core_message_can_edit_message_profile()

core_message_can_edit_message_profile (   $user)

Checks if current user is allowed to edit messaging preferences of another user.

Parameters
stdClass$useruser whose preferences we are updating
Return values
bool

◆ core_message_standard_after_main_region_html()

core_message_standard_after_main_region_html ( )

Render the message drawer to be included in the top of the body of each page.

Return values
stringHTML

◆ core_message_user_preferences()

core_message_user_preferences ( )

Implements callback user_preferences, whitelists preferences that users are allowed to update directly.

Used in {

See also
core_user::fill_preferences_cache()}, see also {
useredit_update_user_preference()}
Return values
array

◆ get_message_output_default_preferences()

get_message_output_default_preferences ( )

Get messaging outputs default (site) preferences.

Return values
object::$processorsobject containing information on message processors

◆ get_message_processor()

get_message_processor (   $type)

Get an instance of the message_output class for one of the output plugins.

Parameters
string$typethe message output type. E.g. 'email' or 'jabber'.
Return values
message_outputmessage_output the requested class.

◆ get_message_processors()

get_message_processors (   $ready = false,
  $reset = false,
  $resetonly = false 
)

Get all message processors, validate corresponding plugin existance and system configuration.

Parameters
bool$readyonly return ready-to-use processors
bool$resetReset list of message processors (used in unit tests)
bool$resetonlyJust reset, then exit
Return values
mixed::$processorsarray of objects containing information on message processors

◆ get_message_providers()

get_message_providers ( )

Get all message providers, validate their plugin existance and system configuration.

Return values
mixed::$processorsarray of objects containing information on message processors

◆ message_count_unread_messages()

message_count_unread_messages (   $user1 = null,
  $user2 = null 
)

Returns the count of unread messages for user.

Either from a specific user or from all users.

Parameters
object$user1the first user. Defaults to $USER
object$user2the second user. If null this function will count all of user 1's unread messages.
Return values
intthe count of $user1's unread messages

◆ message_format_contexturl()

message_format_contexturl (   $message)

Format a the context url and context url name of a message for display.

Parameters
object$messagethe message object
Return values
stringthe formatted string

◆ message_format_message()

message_format_message (   $message,
  $format = '',
  $keywords = '',
  $class = 'other' 
)

Format a message for display in the message history.

Parameters
object$messagethe message object
string$formatoptional date format
string$keywordskeywords to highlight
string$classCSS class to apply to the div around the message
Return values
stringthe formatted message

◆ message_get_messages()

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

Parameters
int$useridtothe user id who received the message
int$useridfromthe user id who sent the message. -10 or -20 for no-reply or support user
int$notifications1 for retrieving notifications, 0 for messages, -1 for both
bool$readtrue for retrieving read messages, false for unread
string$sortthe column name to order by including optionally direction
int$limitfromlimit from
int$limitnumlimit num
Return values
external_description
Since
2.8

◆ message_get_providers_for_user()

message_get_providers_for_user (   $userid)

Returns the active providers for the user specified, based on capability.

Parameters
int$useridid of user
Return values
arrayAn array of message providers

◆ message_get_providers_from_db()

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

See also
message_update_providers()
Parameters
string$componentA moodle component like 'moodle', 'mod_forum', 'block_quiz_results'
Return values
arrayAn array of message providers

◆ message_get_providers_from_file()

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

See also
message_update_providers()
message_update_processors()
Parameters
string$componentA moodle component like 'moodle', 'mod_forum', 'block_quiz_results'
Return values
arrayAn array of message providers or empty array if not exists

◆ message_handle_phpunit_redirection()

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.

Parameters
core::message::message$eventdatathe message object
string$tablethe table to store the tabledata in, either messages or notifications.
stdClass$tabledatathe data to be stored when creating the message/notification.
Return values
intthe id of the stored message.

◆ message_output_fragment_processor_settings()

message_output_fragment_processor_settings (   $args = [])

Handles displaying processor settings in a fragment.

Parameters
array$args
Return values
bool|string
Exceptions
moodle_exception

◆ message_post_message()

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

Parameters
object$userfromthe message sender
object$usertothe message recipient
string$messagethe message
int$formatmessage format such as FORMAT_PLAIN or FORMAT_HTML
Return values
int|falsethe ID of the new message or false

◆ message_processor_uninstall()

message_processor_uninstall (   $name)

Uninstall a message processor.

Parameters
string$nameA message processor name like 'email', 'jabber'

◆ message_provider_uninstall()

message_provider_uninstall (   $component)

Remove all message providers for particular component and corresponding settings.

Parameters
string$componentA moodle component like 'moodle', 'mod_forum', 'block_quiz_results'
Return values
void

◆ message_search_users()

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.

Parameters
int | array$courseidsCourse ID or array of course IDs.
string$searchtextthe text to search for.
string$sortthe column name to order by.
string | array$exceptionscomma separated list or array of user IDs to exclude.
Return values
arrayAn array of $USER records.

◆ message_set_default_message_preference()

message_set_default_message_preference (   $component,
  $messagename,
  $fileprovider,
  $processorname = '' 
)

Setting default messaging preferences for particular message provider.

Parameters
string$componentThe name of component (e.g. moodle, mod_forum, etc.)
string$messagenameThe name of message provider
array$fileproviderThe value of $messagename key in the array defined in plugin messages.php
string$processornameThe optional name of message processor

◆ message_update_processors()

message_update_processors (   $processorname)

This function populates default message preferences for all existing providers when the new message processor is added.

Parameters
string$processornameThe name of message processor plugin (e.g. 'email', 'jabber')
Exceptions
invalid_parameter_exceptionif $processorname does not exist in the database

◆ message_update_providers()

message_update_providers (   $component = 'moodle')

Updates the message_providers table with the current set of message providers.

Parameters
string$componentFor example 'moodle', 'mod_forum' or 'block_quiz_results'
Return values
booleanTrue on success

◆ translate_message_default_setting()

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.

Parameters
int$plugindefaultDefault setting suggested by plugin
string$processornameThe name of processor
Return values
array::$settingsarray of strings in the order: $permitted, $loggedin, $loggedoff.

Variable Documentation

◆ $handlers

$handlers
Initial value:
= array(
array(
'classname' => '\core\message\inbound\private_files_handler',
'defaultexpiration' => 0,
),
)

◆ MESSAGE_DEFAULT_LOGGEDIN

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 when user is loggedin (MESSAGE_DEFAULT_LOGGEDIN) bit 1 - whether to send message when user is loggedoff (MESSAGE_DEFAULT_LOGGEDOFF) bit 2..3 - messaging permission (MESSAGE_DISALLOWED|MESSAGE_PERMITTED|MESSAGE_FORCED)

MESSAGE_PERMITTED_MASK contains the mask we use to distinguish permission setting