Skip to content

Commit

Permalink
MDL-69166 enrol_fee: Show a warning when no currency is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Oct 27, 2020
1 parent 22a9491 commit 3c87455
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 20 additions & 9 deletions enrol/fee/settings.php
Expand Up @@ -26,6 +26,16 @@

if ($ADMIN->fulltree) {

$currencies = enrol_get_plugin('fee')->get_possible_currencies();

if (empty($currencies)) {
$notify = new \core\output\notification(
get_string('nocurrencysupported', 'core_payment'),
\core\output\notification::NOTIFY_WARNING
);
$settings->add(new admin_setting_heading('enrol_fee_nocurrency', '', $OUTPUT->render($notify)));
}

$settings->add(new admin_setting_heading('enrol_fee_settings', '', get_string('pluginname_desc', 'enrol_fee')));

// Note: let's reuse the ext sync constants and strings here, internally it is very similar,
Expand All @@ -36,11 +46,11 @@
ENROL_EXT_REMOVED_UNENROL => get_string('extremovedunenrol', 'enrol'),
);
$settings->add(new admin_setting_configselect(
'enrol_fee/expiredaction',
get_string('expiredaction', 'enrol_fee'),
get_string('expiredaction_help', 'enrol_fee'),
ENROL_EXT_REMOVED_SUSPENDNOROLES,
$options));
'enrol_fee/expiredaction',
get_string('expiredaction', 'enrol_fee'),
get_string('expiredaction_help', 'enrol_fee'),
ENROL_EXT_REMOVED_SUSPENDNOROLES,
$options));

$settings->add(new admin_setting_heading('enrol_fee_defaults',
get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
Expand All @@ -50,10 +60,11 @@
$settings->add(new admin_setting_configselect('enrol_fee/status',
get_string('status', 'enrol_fee'), get_string('status_desc', 'enrol_fee'), ENROL_INSTANCE_DISABLED, $options));

$settings->add(new admin_setting_configtext('enrol_fee/cost', get_string('cost', 'enrol_fee'), '', 0, PARAM_FLOAT, 4));

$currencies = enrol_get_plugin('fee')->get_possible_currencies();
$settings->add(new admin_setting_configselect('enrol_fee/currency', get_string('currency', 'enrol_fee'), '', '', $currencies));
if (!empty($currencies)) {
$settings->add(new admin_setting_configtext('enrol_fee/cost', get_string('cost', 'enrol_fee'), '', 0, PARAM_FLOAT, 4));
$settings->add(new admin_setting_configselect('enrol_fee/currency', get_string('currency', 'enrol_fee'), '', '',
$currencies));
}

if (!during_initial_install()) {
$options = get_default_enrol_roles(context_system::instance());
Expand Down
1 change: 1 addition & 0 deletions lang/en/payment.php
Expand Up @@ -24,6 +24,7 @@

$string['callbacknotimplemented'] = 'The callback is not implemented for component {$a}.';
$string['feeincludesurcharge'] = '{$a->fee} (includes {$a->surcharge}% surcharge for using this payment type)';
$string['nocurrencysupported'] = 'No payment in any currency is supported. Please make sure that at least one payment gateway is enabled.';
$string['nogateway'] = 'There is no payment gateway that can be used.';
$string['nogatewayselected'] = 'You first need to select a payment gateway.';
$string['selectpaymenttype'] = 'Select payment type';
Expand Down

0 comments on commit 3c87455

Please sign in to comment.