From 38756fd84acc64edb670d8dc60f7f36a5f17d6c5 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Thu, 26 Sep 2024 03:09:11 +0800 Subject: [PATCH] MDL-82939 core_sms: Update lang strings Also fixed a bug where the gateways page didnt render the correct title. --- lang/en/sms.php | 14 ++++++------ sms/classes/form/sms_gateway_form.php | 2 -- sms/configure.php | 32 ++++++++++++++------------- sms/sms_gateways.php | 17 ++++++++------ sms/templates/sms_gateways.mustache | 3 +++ 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/lang/en/sms.php b/lang/en/sms.php index 3a11332facf5c..f0569db26ffac 100644 --- a/lang/en/sms.php +++ b/lang/en/sms.php @@ -23,12 +23,12 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['actions'] = 'Actions'; -$string['configure_sms_gateway'] = 'Configure SMS gateway'; -$string['countrycode'] = 'Country code'; -$string['countrycode_help'] = 'Set the default phone number format to exclude the "+" symbol if user does not enter an international number with it.'; -$string['createnewgateway'] = 'Create a new SMS gateway'; +$string['countrycode'] = 'Default country code'; +$string['countrycode_help'] = 'Country code to be added to phone numbers if users don\'t enter their own country code. Enter the number without the leading \'+\' symbol.'; +$string['createnewgateway'] = 'Create new SMS gateway'; $string['delete_sms_gateway'] = 'Delete SMS gateway'; -$string['delete_sms_gateway_confirmation'] = 'Are you sure you want to delete the {$a->gateway} SMS gateway?'; +$string['delete_sms_gateway_confirmation'] = ' This will delete the {$a->gateway} SMS gateway.'; +$string['edit_sms_gateway'] = 'Edit {$a->gateway} SMS gateway'; $string['gateway'] = 'Gateway'; $string['gateway_name'] = 'Gateway name'; $string['manage_sms_gateways'] = 'Manage SMS gateways'; @@ -42,7 +42,6 @@ $string['privacy:metadata:sms_messages:timecreated'] = 'The time the message was created'; $string['privacy:sms:sensitive_not_shown'] = 'The content of this message was not stored as it was marked as containing sensitive content.'; $string['sms'] = 'SMS'; -$string['sms_form_information'] = 'This page allow you to set up and manage your SMS gateway for sending text messages.'; $string['status:gateway_failed'] = 'The gateway has failed to send the message'; $string['status:gateway_not_available'] = 'The gateway is not available to send the message'; $string['status:gateway_queued'] = 'The message is queued to be sent by the gateway'; @@ -51,7 +50,8 @@ $string['status:message_over_size'] = 'The message is too large to be sent by the gateway'; $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_deleted'] = '{$a->gateway} SMS gateway deleted'; $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['sms_gateways_info'] = 'Create and manage SMS gateways to send SMS messages from your site.'; $string['select_sms_gateways'] = 'SMS gateway provider'; diff --git a/sms/classes/form/sms_gateway_form.php b/sms/classes/form/sms_gateway_form.php index 9f9265cda02f6..da30ffdf9edf9 100644 --- a/sms/classes/form/sms_gateway_form.php +++ b/sms/classes/form/sms_gateway_form.php @@ -46,8 +46,6 @@ protected function definition() { $smsplugins[$plugin] = get_string('pluginname', $plugin); } - $mform->addElement('static', 'information', get_string('sms_form_information', 'sms')); - $mform->addElement( 'select', 'smsgateway', diff --git a/sms/configure.php b/sms/configure.php index e216932391212..10110bcba340d 100644 --- a/sms/configure.php +++ b/sms/configure.php @@ -32,6 +32,8 @@ $gateway = optional_param('smsgateway', null, PARAM_PLUGIN); $returnurl = optional_param('returnurl', null, PARAM_LOCALURL); +$title = get_string('createnewgateway', 'sms'); +$data = []; $urlparams = []; if ($id) { $urlparams['id'] = $id; @@ -40,21 +42,6 @@ $urlparams['gateway'] = $gateway; } -$title = get_string('configure_sms_gateway', 'sms'); -$PAGE->set_context($context); -$PAGE->set_url('/sms/configure.php', $urlparams); -$PAGE->set_title($title); -$PAGE->set_heading($title); - -if (empty($returnurl)) { - $returnurl = new moodle_url('/sms/sms_gateways.php'); -} else { - $returnurl = new moodle_url($returnurl); -} -$data = [ - 'returnurl' => $returnurl, -]; - if (!empty($gateway)) { $configs = new stdClass(); $configs->smsgateway = $gateway; @@ -77,7 +64,22 @@ $data = [ 'gatewayconfigs' => $configs, ]; + + $a = ['gateway' => $gatewayrecord->name]; + $title = get_string('edit_sms_gateway', 'sms', $a); +} + +$PAGE->set_context($context); +$PAGE->set_url('/sms/configure.php', $urlparams); +$PAGE->set_title($title); +$PAGE->set_heading($title); + +if (empty($returnurl)) { + $returnurl = new moodle_url('/sms/sms_gateways.php'); +} else { + $returnurl = new moodle_url($returnurl); } +$data['returnurl'] = $returnurl; $mform = new \core_sms\form\sms_gateway_form(customdata: $data); diff --git a/sms/sms_gateways.php b/sms/sms_gateways.php index 881d72d6296f3..2686934544f6c 100644 --- a/sms/sms_gateways.php +++ b/sms/sms_gateways.php @@ -38,25 +38,24 @@ // Set up the page. $title = get_string('sms_gateways', 'sms'); $returnurl = new moodle_url('/sms/sms_gateways.php'); +admin_externalpage_setup('smsgateway'); +$PAGE->set_primary_active_tab('siteadminnode'); +$PAGE->navbar->add($title, $returnurl); $PAGE->set_context($context); $PAGE->set_url($returnurl); $PAGE->set_title($title); $PAGE->set_heading($title); -admin_externalpage_setup('smsgateway'); -$PAGE->set_primary_active_tab('siteadminnode'); -$PAGE->navbar->add($title, $returnurl); - if (!empty($id) && !empty($action)) { $manager = \core\di::get(\core_sms\manager::class); $gatewayrecord = $manager->get_gateway_records(['id' => $id]); $gatewayrecord = reset($gatewayrecord); $pluginname = explode('\\', $gatewayrecord->gateway); $pluginname = $pluginname[0]; - $a = new stdClass(); - $a->gateway = get_string('pluginname', $pluginname); $gateway = $manager->get_gateway_instances(['id' => $id]); $gateway = reset($gateway); + $a = new stdClass(); + $a->gateway = $gateway->name; } if ($action === 'delete') { @@ -78,8 +77,12 @@ echo $OUTPUT->header(); $yesurl = new moodle_url($returnurl, ['id' => $id, 'action' => 'delete', 'confirm' => 1]); + $deletedisplay = [ + 'confirmtitle' => get_string('deletecheck', '', $a->gateway), + 'continuestr' => get_string('delete'), + ]; $message = get_string('delete_sms_gateway_confirmation', 'sms', $a); - echo $OUTPUT->confirm($message, $yesurl, $returnurl); + echo $OUTPUT->confirm($message, $yesurl, $returnurl, $deletedisplay); echo $OUTPUT->footer(); die; } diff --git a/sms/templates/sms_gateways.mustache b/sms/templates/sms_gateways.mustache index d0081046fa542..508875456a91b 100644 --- a/sms/templates/sms_gateways.mustache +++ b/sms/templates/sms_gateways.mustache @@ -27,6 +27,9 @@ } }} +
+ {{#str}}sms_gateways_info, sms{{/str}} +
 {{#str}}createnewgateway, sms{{/str}}