Skip to content

Commit

Permalink
fixup! MDL-81732 core_sms: Add SMS gateway management UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mickhawkins committed Aug 26, 2024
1 parent 696c798 commit b48368a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lang/en/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
$string['status:unknown'] = 'Unable to determine the status of the message';
$string['sms_gateways'] = 'SMS gateways';
$string['sms_gateway_deleted'] = '{$a->gateway} SMS gateway has been deleted';
$string['sms_gateway_delete_failed'] = 'Cannot delete {$a->gateway} SMS gateway. The gateway is either in use or there\'s a database issue. Please contact your database administrator for help.';
$string['sms_gateway_disable_failed'] = 'Cannot disable the SMS gateway. The gateway is either in use or there\'s a database issue. Please contact your database administrator for help.';
$string['sms_gateway_delete_failed'] = 'Cannot delete the {$a->gateway} SMS gateway. The gateway is either in use or there\'s a database issue. Check if the gateway is active or contact your database administrator for help.';
$string['sms_gateway_disable_failed'] = 'Cannot disable the SMS gateway. The gateway is either in use or there\'s a database issue. Check if the gateway is active or contact your database administrator for help.';
$string['select_sms_gateways'] = 'SMS gateway provider';
4 changes: 4 additions & 0 deletions sms/classes/external/sms_gateway_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public static function execute(int $gatewayid, bool $enabled): array {
'enabled' => $enabled,
]);

$context = context_system::instance();
self::validate_context($context);
require_capability('moodle/site:config', $context);

$result = [
'result' => true,
'message' => '',
Expand Down
3 changes: 2 additions & 1 deletion sms/classes/gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @property-read int $id The id of the gateway in the database
* @property-read bool $enabled Whether the gateway is enabled
* @property-read stdClass $config The configuration for this instance
* @property-write string $name The name of the gateway config
* @property string $name The name of the gateway config
*/
abstract class gateway {
use Cloneable;
Expand All @@ -48,6 +48,7 @@ abstract class gateway {
public function __construct(
/** @var bool Whether the gateway is enabled */
public readonly bool $enabled,
/** @var string The name of the gateway config */
public string $name,
string $config,
/** @var null|int The ID of the gateway in the database, or null if it has not been persisted yet */
Expand Down
3 changes: 2 additions & 1 deletion sms/configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
require_once('../config.php');

require_login();

$context = context_system::instance();
require_capability('moodle/site:config', $context);

$id = optional_param('id', null, PARAM_INT);
$gateway = optional_param('smsgateway', null, PARAM_PLUGIN);
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
Expand Down
3 changes: 2 additions & 1 deletion sms/sms_gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
require_once($CFG->dirroot . '/lib/adminlib.php');

require_login();

$context = context_system::instance();
require_capability('moodle/site:config', $context);

$id = optional_param('id', null, PARAM_INT);
$action = optional_param('action', '', PARAM_TEXT);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
Expand Down

0 comments on commit b48368a

Please sign in to comment.