Skip to content

Commit

Permalink
MDL-82939 core_sms: Update lang strings
Browse files Browse the repository at this point in the history
Also fixed a bug where the gateways page didnt render the correct title.
  • Loading branch information
mickhawkins committed Sep 25, 2024
1 parent 97c2bea commit 4f4310b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
14 changes: 7 additions & 7 deletions lang/en/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -42,7 +42,7 @@
$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['sms_form_information'] = 'Create and manage SMS gateways to send SMS messages from your site.';
$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';
Expand All @@ -51,7 +51,7 @@
$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['select_sms_gateways'] = 'SMS gateway provider';
2 changes: 0 additions & 2 deletions sms/classes/form/sms_gateway_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
33 changes: 18 additions & 15 deletions sms/configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
$gateway = optional_param('smsgateway', null, PARAM_PLUGIN);
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);

$title = get_string('createnewgateway', 'sms');
$urlparams = [];
if ($id) {
$urlparams['id'] = $id;
Expand All @@ -40,21 +41,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;
Expand All @@ -77,8 +63,25 @@
$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);

if ($mform->is_cancelled()) {
Expand Down
17 changes: 10 additions & 7 deletions sms/sms_gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions sms/templates/sms_gateways.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
}
}}

<div class="d-flex mb-3">
{{#str}}sms_form_information, sms{{/str}}
</div>
<div class="d-flex flex-row-reverse">
<a href="{{createurl}}" title="{{#str}}createnewgateway, sms{{/str}}" class="btn btn-primary mb-3">
<i class="fa fa-plus"></i>&nbsp;{{#str}}createnewgateway, sms{{/str}}
Expand Down

0 comments on commit 4f4310b

Please sign in to comment.