Skip to content

Commit 6bbea90

Browse files
davewoloszynsafatshahin
authored andcommitted
Suggested changes
1 parent a96fd88 commit 6bbea90

File tree

2 files changed

+46
-33
lines changed

2 files changed

+46
-33
lines changed

docs/apis/plugintypes/sms/index.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
---
2-
title: SMS gateway plugin
2+
title: SMS gateway
33
tags:
44
- SMS
55
- Gateway
6-
- SMS gateway
76
- Notification
87
---
98

109
<Since version="4.5" issueNumber="MDL-83406" />
1110

12-
SMS gateway plugins allows you to create SMS gateway provider, which can be used to send SMS notification to users from your Moodle instance.
13-
For example, you use MFA (Multi-Factor Authentication) to user authentication in Moodle and you use AWS as your SMS gateway provider. You can
14-
now build more SMS Gateway providers to allow sending SMS to your users.
11+
SMS gateway plugins allow you to create SMS gateway providers.
12+
Providers are an interface between [SMS API](/apis/subsystems/sms/index.md) and the external SMS provider (e.g. Amazon Web Services).
13+
This allows for the sending of SMS notifications to users from your Moodle instance.
14+
15+
For example, you set up MFA (Multi-Factor Authentication) in Moodle and choose 'AWS' as your SMS gateway provider.
16+
This enables users to receive SMS notifications as part of the authentication process.
1517

1618
## File structure
1719

18-
SMS gateway plugins are located in the /sms/gateway directory. A plugin should not include any custom files outside its own
20+
SMS gateway plugins are located in the `/sms/gateway` directory. A plugin should not include any custom files outside its own
1921
plugin folder.
2022

21-
Each plugin is in a separate subdirectory and consists of a number of _mandatory files_ and any other files the developer is going to use.
22-
23-
:::important
24-
25-
Some important files are described below. See the [common plugin files](../../commonfiles/index.mdx) documentation for details of other
26-
files which may be useful in your plugin.
27-
28-
:::
23+
Each plugin is in a separate subdirectory and consists of a number of mandatory files and any other files the developer is going to use. See the [common plugin files](/apis/commonfiles/index.mdx) documentation for other files which may be useful in your plugin.
2924

3025
<details>
3126
<summary>The directory layout for the `smsgateway` plugin.</summary>
@@ -48,11 +43,15 @@ sms/gateway/example
4843

4944
## Key files
5045

51-
There are a number of key files within the plugin, described below.
46+
There are a number of key files within the SMS gateway plugin which will need to be configured for correct functionality.
47+
48+
- gateway.php
49+
- hook_listener.php
5250

5351
### gateway.php
5452

55-
Each plugin must implement this class and should have the exact class name. The core_sms api will pick the extended methods from this class.
53+
Each plugin must create a class called `gateway` which extends the `\core_sms\gateway` class.
54+
The SMS API will use the extended methods from this class.
5655

5756
```php title="Implementing the base SMS gateway"
5857

@@ -92,12 +91,12 @@ class gateway extends \core_sms\gateway {
9291

9392
### hook_listener.php
9493

95-
There a couple of hooks dispatched from the core_sms API which can be listened by the plugin. It is necessary for plugins developers to assess
96-
these hooks and implement accordingly.
94+
[Hooks](/apis/core/hooks/index.md) can be dispatched from the SMS API which the plugin can then listened to.
95+
It is necessary for plugins developers to assess these hooks and implement accordingly.
9796

9897
#### after_sms_gateway_form_hook
9998

100-
This hook will allow plugins to add their relevant form field from the plugin to allow users to add required configs for the SMS gateway.
99+
This hook will allow plugins to add required form fields to assist users in configuring their SMS gateway.
101100

102101
```php title="Listener method for after_sms_gateway_form_hook"
103102

@@ -121,6 +120,6 @@ public static function set_form_definition_for_aws_sms_gateway(after_sms_gateway
121120

122121
:::info
123122

124-
For a real plugin example, please look at the [AWS SMS Gateway plugin](https://github.com/moodle/moodle/tree/main/sms/gateway/aws).
123+
For a real plugin example, see the [AWS SMS Gateway plugin](https://github.com/moodle/moodle/tree/main/sms/gateway/aws).
125124

126125
:::

docs/apis/subsystems/sms/index.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
---
22
title: SMS API
3+
tags:
4+
- SMS
35
---
46

57
<Since version="4.5" issueNumber="MDL-79808" />
68

7-
The SMS API lets you send SMS messages using configured gateways, fetch messages that were previously sent, and check on their status.
9+
The SMS API allows developers to implement SMS-related features into their plugins.
10+
The subsystem contains an SMS Manager class `\core_sms\manager` which facilitates the actions performed by the API.
11+
12+
Some of the actions made possible are:
13+
14+
- Sending messages
15+
- Fetching messages
16+
- Checking the status of a message
17+
- Getting SMS gateways.
18+
19+
Currently, the design of the SMS API features the following plugin types:
20+
21+
- [SMS gateway](/apis/plugintypes/sms/index.md)
822

923
## Sending an SMS
1024

@@ -26,7 +40,7 @@ $message = \core\di::get(\core_sms\manager::class)
2640

2741
:::info Message lengths
2842

29-
A single SMS sent by the API may consist of up to 480 UTF-8 characters. It is up to the message _gateway_ plugin to determine how this message is sent to the recipient.
43+
A single SMS sent by the API may consist of up to 480 UTF-8 characters. It is up to the message _gateway plugin_ to determine how this message is sent to the recipient.
3044

3145
Any message longer than the maximum length will be immediately rejected.
3246

@@ -124,32 +138,32 @@ graph TD
124138
end
125139
```
126140

127-
## Getting the list of SMS gateways
141+
## Getting SMS gateways
128142

129-
Once the gateway is configured from UI, any component implementing the core_sms API can get the list of gateways. The list can also be filtered.
143+
[SMS gateways](/apis/plugintypes/sms/index.md) are plugins that provide a way to interface with external SMS providers.
144+
Once a gateway is configured, any component implementing the SMS API can get a list of gateways.
130145

131146
```php title="Getting the list of enabled gateways"
132147
$manager = \core\di::get(\core_sms\manager::class);
133148
$gatewayrecords = $manager->get_gateway_records();
134149

135-
// It is also possible to filter the requst.
150+
// It is also possible to filter the request.
136151
$gatewayrecords = $manager->get_gateway_records(['id' => $id]);
137152

138153
// To get all the enabled gateway instances.
139154
$gatewayrecords = $manager->get_enabled_gateway_instances();
140155
```
141156

142-
## Some important hooks to be aware of
157+
## Important hooks
143158

144-
SMS API dispatches some hooks which should be assessed and used when this API is implemented in a plugin/component. These hooks helps with
145-
managing the data, like save them from deletion or accidental deactivation from the SMS Gateway management UI while a specific gateway is
146-
being used by a component.
159+
The SMS API dispatches some [hooks](/apis/core/hooks/index.md) which should be considered when implemented by a plugin/component.
147160

148-
### before_gateway_deleted & before_gateway_disabled
161+
- before_gateway_deleted
162+
- before_gateway_disabled
149163

150-
Before deleting or disabling an SMS gateway, these two hooks are dispatched from the core_sms API to allow the components using that specific
151-
gateway to stop that action or do necessary cleanup. It is important to listed to these hooks to prevent data loss or potential issues with a
152-
gateway being used which is deleted or disabled by accident.
164+
Before deleting or disabling an [SMS gateways](/apis/plugintypes/sms/index.md), these two hooks are dispatched from the SMS API.
165+
This allows components that are actively using that gateway to stop the action, or do necessary cleanup.
166+
Listening to these hooks is crucial to avoid data loss or accidental deletion when disabling an active gateway.
153167

154168
```php title="Implement the hooks to check for usage before deletion or deactivation"
155169

0 commit comments

Comments
 (0)