Merge branch 'MDL-70010_310' of https://github.com/stronk7/moodle into MOODLE_310_STABLE
[moodle.git] / payment / manage_account.php
index 1a5a0b1..d5d2e26 100644 (file)
@@ -27,19 +27,24 @@ require_once($CFG->libdir . '/adminlib.php');
 
 $id = optional_param('id', 0, PARAM_INT);
 $delete = optional_param('delete', false, PARAM_BOOL);
+$restore = optional_param('restore', false, PARAM_BOOL);
 
 $pageurl = new moodle_url('/payment/manage_account.php');
 admin_externalpage_setup('paymentaccounts', '', [], $pageurl);
 
-$enabledplugins = \core\plugininfo\pg::get_enabled_plugins();
+$enabledplugins = \core\plugininfo\paygw::get_enabled_plugins();
 
 $account = new \core_payment\account($id);
 require_capability('moodle/payment:manageaccounts', $account->get_context());
 
-if ($delete && confirm_sesskey()) {
+if ($delete && !$account->get('archived') && confirm_sesskey()) {
     \core_payment\helper::delete_payment_account($account);
     redirect(new moodle_url('/payment/accounts.php'));
 }
+if ($restore && $account->get('archived') && confirm_sesskey()) {
+    \core_payment\helper::restore_payment_account($account);
+    redirect(new moodle_url('/payment/accounts.php'));
+}
 
 $PAGE->set_heading($id ? format_string($account->get('name')) : get_string('createaccount', 'payment'));