Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\message\message Class Reference

New messaging class. More...

Public Member Functions

 __get ($prop)
 Magic getter method.
 
 __isset ($prop)
 Magic method to check if property is set.
 
 __set ($prop, $value)
 Magic setter method.
 
 get_eventobject_for_processor ($processorname)
 Get a event object for a specific processor in stdClass format.
 
 set_additional_content ($processorname, $content)
 This method lets you define content that would be added to the message only for specific message processors.
 

Protected Member Functions

 get_fullmessage ($processorname='')
 Fullmessage content including any processor specific content.
 
 get_fullmessagehtml ($processorname='')
 Fullmessagehtml content including any processor specific content.
 
 get_message_with_additional_content ($processorname, $messagetype)
 Helper method used to get message content added with processor specific content.
 
 get_smallmessage ($processorname='')
 Smallmessage content including any processor specific content.
 
 set_customdata ($customdata)
 Always JSON encode customdata.
 

Detailed Description

New messaging class.

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. This is mandatory for NOTIFICACIONS and 1:1 personal messages. 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

Required parameters of the $eventdata object for PERSONAL MESSAGES: convid int The conversation identifier where this message will be sent

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. replyto string An email address which can be used to send an reply. attachment stored_file File instance that needs to be sent as attachment. attachname string Name of the attachment. customdata mixed Custom data to be passed to the message processor. Must be serialisable using json_encode().

Since
Moodle 2.9
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ __get()

core\message\message::__get ( $prop)

Magic getter method.

Parameters
string$propname of property to get.
Return values
mixed
Exceptions
coding_exception

◆ __isset()

core\message\message::__isset ( $prop)

Magic method to check if property is set.

Parameters
string$propname of property to check.
Return values
bool
Exceptions
coding_exception

◆ __set()

core\message\message::__set ( $prop,
$value )

Magic setter method.

Parameters
string$propname of property to set.
mixed$valuevalue to assign to the property.
Return values
mixed
Exceptions
coding_exception

◆ get_eventobject_for_processor()

core\message\message::get_eventobject_for_processor ( $processorname)

Get a event object for a specific processor in stdClass format.

Parameters
string$processornameName of the processor.
Return values
stdClassevent object in stdClass format.

◆ get_fullmessage()

core\message\message::get_fullmessage ( $processorname = '')
protected

Fullmessage content including any processor specific content.

Parameters
string$processornameName of the processor.
Return values
mixed|string

◆ get_fullmessagehtml()

core\message\message::get_fullmessagehtml ( $processorname = '')
protected

Fullmessagehtml content including any processor specific content.

Parameters
string$processornameName of the processor.
Return values
mixed|string

◆ get_message_with_additional_content()

core\message\message::get_message_with_additional_content ( $processorname,
$messagetype )
protected

Helper method used to get message content added with processor specific content.

Parameters
string$processornameName of the processor.
string$messagetypeone of 'fullmessagehtml', 'fullmessage', 'smallmessage'.
Return values
mixed|string

◆ get_smallmessage()

core\message\message::get_smallmessage ( $processorname = '')
protected

Smallmessage content including any processor specific content.

Parameters
string$processornameName of the processor.
Return values
mixed|string

◆ set_additional_content()

core\message\message::set_additional_content ( $processorname,
$content )

This method lets you define content that would be added to the message only for specific message processors.

Example of $content:- array('fullmessagehtml' => array('header' => 'header content', 'footer' => 'footer content'), 'smallmessage' => array('header' => 'header content for small message', 'footer' => 'footer content'), '*' => array('header' => 'header content for all types', 'footer' => 'footer content') )

Parameters
string$processornamename of the processor.
array$contentcontent to add in the above defined format.

◆ set_customdata()

core\message\message::set_customdata ( $customdata)
protected

Always JSON encode customdata.

Parameters
mixed$customdataa data structure that must be serialisable using json_encode().

The documentation for this class was generated from the following file: