Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Incoming Message address manager.

Copyright: 2014 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 472 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

address_manager:: (14 methods):
  set_handler()
  get_handler()
  set_data()
  set_data_key()
  fetch_data_key()
  generate_data_key()
  generate()
  is_correct_format()
  process()
  get_data()
  validate()
  process_envelope()
  handle_message()
  pack_int()


Class: address_manager  - X-Ref

Incoming Message address manager.

set_handler($classname)   X-Ref
Set the handler to use for the subsequent Inbound Message commands.

param: string $classname The name of the class for the handler.

get_handler()   X-Ref
Return the active handler.

return: \core\message\inbound\handler|null;

set_data($datavalue, $datakey = null)   X-Ref
Specify an integer data item value for this record.

param: int $datavalue The value of the data item.
param: string $datakey A hash to use for the datakey

set_data_key($datakey = null)   X-Ref
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.

param: string $datakey A hash to use for the datakey

fetch_data_key()   X-Ref
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: string The secret key for this data item.

generate_data_key()   X-Ref
Generate a new secret key for the current data item and handler combination.

return: string The new generated secret key for this data item.

generate($userid, $userkey = null)   X-Ref
Generate an e-mail address for the Inbound Message handler, storing a private
key for the data object if one was not specified.

param: int $userid The ID of the user to generated an address for.
param: string $userkey The unique key for this user. If not specified this will be retrieved using
return: string|null The generated address, or null if an address could not be generated.

is_correct_format($address)   X-Ref
Determine whether the supplied address is of the correct format.

param: string $address The address to test
return: bool Whether the address matches the correct format

process($address)   X-Ref
Process an inbound address to obtain the data stored within it.

param: string $address The fully formed e-mail address to process.

get_data()   X-Ref
Retrieve the data parsed from the address.

return: \stdClass the parsed data.

validate($address)   X-Ref
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.

param: string $address The fully formed e-mail address to process.
return: int The validation status.

process_envelope($recipient, $sender)   X-Ref
Process the message recipient, load the handler, and then validate
the sender with the associated data record.

param: string $recipient The recipient of the message
param: string $sender The sender of the message

handle_message(\stdClass $messagedata)   X-Ref
Process the message against the relevant handler.

param: \stdClass $messagedata The data for the current message being processed.
return: mixed The result of the handler's message processor. A truthy result suggests a successful send.

pack_int($int)   X-Ref
Pack an integer into a pair of 32-bit numbers.

param: int $int The integer to pack
return: string The encoded binary data