forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-81924 smsgateway_aws: Add hooks for SMS gateway management
Originally implemented as MDL-81732. Co-authored by: Michael Hawkins <[email protected]>
- Loading branch information
1 parent
a1209ab
commit 3348832
Showing
5 changed files
with
167 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace smsgateway_aws; | ||
|
||
use core_sms\hook\after_sms_gateway_form_hook; | ||
|
||
/** | ||
* Hook listener for aws sms gateway. | ||
* | ||
* @package smsgateway_aws | ||
* @copyright 2024 Safat Shahin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class hook_listener { | ||
|
||
/** | ||
* Hook listener for the sms gateway setup form. | ||
* | ||
* @param after_sms_gateway_form_hook $hook The hook to add to sms gateway setup. | ||
*/ | ||
public static function set_form_definition_for_aws_sms_gateway(after_sms_gateway_form_hook $hook): void { | ||
if ($hook->plugin !== 'smsgateway_aws') { | ||
return; | ||
} | ||
|
||
$mform = $hook->mform; | ||
|
||
$mform->addElement('static', 'information', get_string('aws_information', 'smsgateway_aws')); | ||
|
||
$gateways = [ | ||
'aws_sns' => get_string('aws_sns', 'smsgateway_aws'), | ||
]; | ||
$mform->addElement( | ||
'select', | ||
'gateway', | ||
get_string('gateway', 'smsgateway_aws'), | ||
$gateways, | ||
); | ||
$mform->setDefault( | ||
elementName: 'gateway', | ||
defaultValue: 'aws_sns', | ||
); | ||
// Remove this if more aws gateway implemented, eg sqs. | ||
$mform->hardFreeze('gateway'); | ||
|
||
$mform->addElement( | ||
'checkbox', | ||
'usecredchain', | ||
get_string('usecredchain', 'smsgateway_aws'), | ||
' ', | ||
); | ||
$mform->setDefault( | ||
elementName: 'usecredchain', | ||
defaultValue: 0, | ||
); | ||
|
||
$mform->addElement( | ||
'text', | ||
'api_key', | ||
get_string('api_key', 'smsgateway_aws'), | ||
'maxlength="255" size="20"', | ||
); | ||
$mform->setType('api_key', PARAM_TEXT); | ||
$mform->addRule('api_key', get_string('maximumchars', '', 255), 'maxlength', 255); | ||
$mform->setDefault( | ||
elementName: 'api_key', | ||
defaultValue: '', | ||
); | ||
$mform->addElement( | ||
'passwordunmask', | ||
'api_secret', | ||
get_string('api_secret', 'smsgateway_aws'), | ||
'maxlength="255" size="20"', | ||
); | ||
$mform->setType('api_secret', PARAM_TEXT); | ||
$mform->addRule('api_secret', get_string('maximumchars', '', 255), 'maxlength', 255); | ||
$mform->setDefault( | ||
elementName: 'api_secret', | ||
defaultValue: '', | ||
); | ||
|
||
$mform->addElement( | ||
'text', | ||
'api_region', | ||
get_string('api_region', 'smsgateway_aws'), | ||
'maxlength="255" size="20"', | ||
); | ||
$mform->setType('api_region', PARAM_TEXT); | ||
$mform->addRule('api_region', get_string('maximumchars', '', 255), 'maxlength', 255); | ||
$mform->setDefault( | ||
elementName: 'api_region', | ||
defaultValue: 'ap-southeast-2', | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Hook listener callbacks for aws sms gateway. | ||
* | ||
* @package smsgateway_aws | ||
* @copyright 2024 Safat Shahin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$callbacks = [ | ||
[ | ||
'hook' => \core_sms\hook\after_sms_gateway_form_hook::class, | ||
'callback' => \smsgateway_aws\hook_listener::class . '::set_form_definition_for_aws_sms_gateway', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters