Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
core_sms\manager Class Reference

Public Member Functions

 __construct (protected moodle_database readonly moodle_database $db,)
 Create a new SMS manager.
 
 create_gateway_instance (string $classname, string $name, bool $enabled=false, ?stdClass $config=null,)
 Create a new gateway instance.
 
 delete_gateway (gateway $gateway)
 Delete the gateway instance.
 
 disable_gateway (gateway $gateway)
 Disable a gateway.
 
 enable_gateway (gateway $gateway)
 Enable a gateway.
 
 get_enabled_gateway_instances ()
 Get a list of all enabled gateway instances.
 
 get_gateway_for_message (message $message, ?int $gatewayid=null,)
 Get the gateway that can send the given message.
 
 get_gateway_instances (?array $filter=null)
 Get a list of all gateway instances.
 
 get_gateway_records (?array $filter=null)
 Get the gateway records according to the filter.
 
 get_message (array $filter,)
 Get a message.
 
 get_messages (string $sort='timecreated ASC', ?array $filter=null, int $pagesize=0, int $page=0,)
 Get all messages.
 
 get_possible_gateways_for_message (message $message,)
 Get the gateways that can send the given message.
 
 save_message (message $message,)
 Save the message to the database.
 
 send (string $recipientnumber, string $content, string $component, string $messagetype, ?int $recipientuserid, bool $issensitive=false, bool $async=true, ?int $gatewayid=null,)
 Send an SMS to the given recipient.
 
 send_message (message $message, bool $async=true, ?int $gatewayid=null,)
 Send a message using the message object.
 
 update_gateway_instance (gateway $gateway, ?stdClass $config=null,)
 Update gateway instance.
 

Static Public Member Functions

static format_number (string $phonenumber, ?string $countrycode=null,)
 This function internationalises a number to E.164 standard.
 

Constructor & Destructor Documentation

◆ __construct()

core_sms\manager::__construct ( protected moodle_database readonly moodle_database $db)

Create a new SMS manager.

Parameters
moodle_database$db
Parameters
$dbThe database instance

Member Function Documentation

◆ create_gateway_instance()

core_sms\manager::create_gateway_instance ( string $classname,
string $name,
bool $enabled = false,
?stdClass $config = null )

Create a new gateway instance.

Parameters
string$classnameClassname of the gateway
string$nameThe name of the gateway config
bool$enabledIf the gateway is enabled or not
stdClass | null$configThe config json
Return values
gateway

◆ delete_gateway()

core_sms\manager::delete_gateway ( gateway $gateway)

Delete the gateway instance.

Parameters
gateway$gatewayThe gateway instance
Return values
bool

◆ disable_gateway()

core_sms\manager::disable_gateway ( gateway $gateway)

Disable a gateway.

Parameters
gateway$gateway
Return values
gateway

◆ enable_gateway()

core_sms\manager::enable_gateway ( gateway $gateway)

Enable a gateway.

Parameters
gateway$gateway
Return values
gateway

◆ format_number()

static core_sms\manager::format_number ( string $phonenumber,
?string $countrycode = null )
static

This function internationalises a number to E.164 standard.

https://46elks.com/kb/e164

Parameters
string$phonenumberthe phone number to format.
?string$countrycodeThe country code of the phone number.
Return values
stringthe formatted phone number.

◆ get_enabled_gateway_instances()

core_sms\manager::get_enabled_gateway_instances ( )

Get a list of all enabled gateway instances.

Return values
array

◆ get_gateway_for_message()

core_sms\manager::get_gateway_for_message ( message $message,
?int $gatewayid = null )

Get the gateway that can send the given message.

Parameters
message$messageThe message instance
?int$gatewayidthe gateway instance id to send the sms in a specific gateway config
Return values
null|gateway

◆ get_gateway_instances()

core_sms\manager::get_gateway_instances ( ?array $filter = null)

Get a list of all gateway instances.

Parameters
null | array$filterThe database filter to apply
Return values
array

◆ get_gateway_records()

core_sms\manager::get_gateway_records ( ?array $filter = null)

Get the gateway records according to the filter.

Parameters
array | null$filterThe filterable elements to get the records from
Return values
array

◆ get_message()

core_sms\manager::get_message ( array $filter)

Get a message.

Parameters
array$filter
Return values
message

◆ get_messages()

core_sms\manager::get_messages ( string $sort = 'timecreated ASC',
?array $filter = null,
int $pagesize = 0,
int $page = 0 )

Get all messages.

Parameters
string$sort
null | array$filter
int$pagesize
int$page
Return values
Generator

◆ get_possible_gateways_for_message()

core_sms\manager::get_possible_gateways_for_message ( message $message)

Get the gateways that can send the given message.

Parameters
message$message
Return values
gateway[]

◆ save_message()

core_sms\manager::save_message ( message $message)

Save the message to the database.

Parameters
message$message
Return values
message

◆ send()

core_sms\manager::send ( string $recipientnumber,
string $content,
string $component,
string $messagetype,
?int $recipientuserid,
bool $issensitive = false,
bool $async = true,
?int $gatewayid = null )

Send an SMS to the given recipient.

Parameters
string$recipientnumberThe phone number to send the SMS to
string$contentThe SMS Content
string$componentThe owning component
string$messagetypeThe message type within the component
null | int$recipientuseridThe user id of the recipient if one exists
bool$issensitiveWhether this SMS contains sensitive information
bool$asyncWhether this SMS should be sent asynchronously. Note: sensitive messages cannot be sent async
?int$gatewayidthe gateway instance id to send the sms in a specific gateway config
Return values
message
Exceptions
coding_exceptionIf a sensitive message is sent asynchronously

◆ send_message()

core_sms\manager::send_message ( message $message,
bool $async = true,
?int $gatewayid = null )

Send a message using the message object.

Parameters
message$messageThe message object
bool$asyncWhether this SMS should be sent asynchronously. Note: sensitive messages cannot be sent async
?int$gatewayidthe gateway instance id to send the sms in a specific gateway config
Return values
messagethe message object after trying to send the message

◆ update_gateway_instance()

core_sms\manager::update_gateway_instance ( gateway $gateway,
?stdClass $config = null )

Update gateway instance.

Parameters
gateway$gatewayThe gateway instance
stdClass | null$configthe configuration of the gateway instance to be updated
Return values
gateway

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