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

Incoming Message address manager. More...

Public Member Functions

 fetch_data_key ()
 Return the data key for the data item.
 
 generate ($userid, $userkey=null)
 Generate an e-mail address for the Inbound Message handler, storing a private key for the data object if one was not specified.
 
 get_data ()
 Retrieve the data parsed from the address.
 
 get_handler ()
 Return the active handler.
 
 handle_message (\stdClass $messagedata)
 Process the message against the relevant handler.
 
 process_envelope ($recipient, $sender)
 Process the message recipient, load the handler, and then validate the sender with the associated data record.
 
 set_data ($datavalue, $datakey=null)
 Specify an integer data item value for this record.
 
 set_data_key ($datakey=null)
 Specify a known data key for this data item.
 
 set_handler ($classname)
 Set the handler to use for the subsequent Inbound Message commands.
 

Static Public Member Functions

static is_correct_format ($address)
 Determine whether the supplied address is of the correct format.
 

Public Attributes

int const HASHSIZE = 24
 The size of the hash component of the address.
 
int const VALIDATION_ADDRESS_MISMATCH = 256
 A validation status indicating that the originator address did not match the user on record.
 
int const VALIDATION_DISABLED_HANDLER = 16
 A validation status indicating that the mail processing handler was not enabled.
 
int const VALIDATION_DISABLED_USER = 32
 A validation status indicating that the user specified was deleted or unconfirmed.
 
int const VALIDATION_EXPIRED_DATAKEY = 64
 A validation status indicating that the datakey specified had reached it's expiration time.
 
int const VALIDATION_INVALID_ADDRESS_FORMAT = 1
 A validation status indicating an invalid address format.
 
int const VALIDATION_INVALID_HASH = 128
 A validation status indicating that the hash could not be verified.
 
int const VALIDATION_SUCCESS = 0
 A validation status indicating successful validation.
 
int const VALIDATION_UNKNOWN_DATAKEY = 8
 A validation status indicating that the data key specified could not be found.
 
int const VALIDATION_UNKNOWN_HANDLER = 2
 A validation status indicating that a handler could not be found for this address.
 
int const VALIDATION_UNKNOWN_USER = 4
 A validation status indicating that an unknown user was specified.
 

Protected Member Functions

 generate_data_key ()
 Generate a new secret key for the current data item and handler combination.
 
 pack_int ($int)
 Pack an integer into a pair of 32-bit numbers.
 
 process ($address)
 Process an inbound address to obtain the data stored within it.
 
 validate ($address)
 Ensure that the parsed data is valid, and if the handler requires address validation, validate the sender against the user record of identified user record.
 

Detailed Description

Incoming Message address manager.

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

Member Function Documentation

◆ fetch_data_key()

core\message\inbound\address_manager::fetch_data_key ( )

Return the data key for the data item.

If no data key has been defined yet, this will call generate_data_key() to generate a new key on the fly.

Return values
stringThe secret key for this data item.

◆ generate()

core\message\inbound\address_manager::generate ( $userid,
$userkey = null )

Generate an e-mail address for the Inbound Message handler, storing a private key for the data object if one was not specified.

Parameters
int$useridThe ID of the user to generated an address for.
string$userkeyThe unique key for this user. If not specified this will be retrieved using get_user_key(). This key must have been created using get_user_key(). This parameter is provided as a performance optimisation for when generating multiple addresses for the same user.
Return values
string|nullThe generated address, or null if an address could not be generated.

◆ generate_data_key()

core\message\inbound\address_manager::generate_data_key ( )
protected

Generate a new secret key for the current data item and handler combination.

Return values
stringThe new generated secret key for this data item.

◆ get_data()

core\message\inbound\address_manager::get_data ( )

Retrieve the data parsed from the address.

Return values
stdClassthe parsed data.

◆ get_handler()

core\message\inbound\address_manager::get_handler ( )

Return the active handler.

Return values
core\message\inbound\handler|null;

◆ handle_message()

core\message\inbound\address_manager::handle_message ( \stdClass $messagedata)

Process the message against the relevant handler.

Parameters
stdClass$messagedataThe data for the current message being processed.
Return values
mixedThe result of the handler's message processor. A truthy result suggests a successful send.

◆ is_correct_format()

static core\message\inbound\address_manager::is_correct_format ( $address)
static

Determine whether the supplied address is of the correct format.

Parameters
string$addressThe address to test
Return values
boolWhether the address matches the correct format

◆ pack_int()

core\message\inbound\address_manager::pack_int ( $int)
protected

Pack an integer into a pair of 32-bit numbers.

Parameters
int$intThe integer to pack
Return values
stringThe encoded binary data

◆ process()

core\message\inbound\address_manager::process ( $address)
protected

Process an inbound address to obtain the data stored within it.

Parameters
string$addressThe fully formed e-mail address to process.

◆ process_envelope()

core\message\inbound\address_manager::process_envelope ( $recipient,
$sender )

Process the message recipient, load the handler, and then validate the sender with the associated data record.

Parameters
string$recipientThe recipient of the message
string$senderThe sender of the message

◆ set_data()

core\message\inbound\address_manager::set_data ( $datavalue,
$datakey = null )

Specify an integer data item value for this record.

Parameters
int$datavalueThe value of the data item.
string$datakeyA hash to use for the datakey

◆ set_data_key()

core\message\inbound\address_manager::set_data_key ( $datakey = null)

Specify a known data key for this data item.

If specified, the datakey must already exist in the messageinbound_datakeys table, typically as a result of a previous Inbound Message setup.

This is intended as a performance optimisation when sending many e-mails with different data to many users.

Parameters
string$datakeyA hash to use for the datakey

◆ set_handler()

core\message\inbound\address_manager::set_handler ( $classname)

Set the handler to use for the subsequent Inbound Message commands.

Parameters
string$classnameThe name of the class for the handler.

◆ validate()

core\message\inbound\address_manager::validate ( $address)
protected

Ensure that the parsed data is valid, and if the handler requires address validation, validate the sender against the user record of identified user record.

Parameters
string$addressThe fully formed e-mail address to process.
Return values
intThe validation status.

Member Data Documentation

◆ HASHSIZE

int const core\message\inbound\address_manager::HASHSIZE = 24

The size of the hash component of the address.

Note: Increasing this value will invalidate all previous key values and reduce the potential length of the e-mail address being checked. Do not change this value.

◆ VALIDATION_INVALID_ADDRESS_FORMAT

int const core\message\inbound\address_manager::VALIDATION_INVALID_ADDRESS_FORMAT = 1

A validation status indicating an invalid address format.

Typically this is an address which does not contain a subaddress or all of the required data.


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