Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Management of payment accounts 19 * 20 * @package core_payment 21 * @copyright 2020 Marina Glancy 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once(__DIR__ . '/../config.php'); 26 require_once($CFG->libdir . '/adminlib.php'); 27 28 $showarchived = optional_param('showarchived', false, PARAM_BOOL); 29 30 admin_externalpage_setup('paymentaccounts'); 31 $PAGE->set_heading(get_string('paymentaccounts', 'payment')); 32 33 $enabledplugins = \core\plugininfo\paygw::get_enabled_plugins(); 34 35 echo $OUTPUT->header(); 36 37 $accounts = \core_payment\helper::get_payment_accounts_to_manage(context_system::instance(), $showarchived); 38 $table = new html_table(); 39 $table->head = [get_string('accountname', 'payment'), get_string('type_paygw_plural', 'plugin'), '']; 40 $table->colclasses = ['', '', 'mdl-right']; 41 $table->data = []; 42 foreach ($accounts as $account) { 43 $gateways = []; 44 $canmanage = has_capability('moodle/payment:manageaccounts', $account->get_context()); 45 foreach ($account->get_gateways() as $gateway) { 46 $status = $gateway->get('enabled') ? $OUTPUT->pix_icon('i/valid', get_string('gatewayenabled', 'payment')) : 47 $OUTPUT->pix_icon('i/invalid', get_string('gatewaydisabled', 'payment')); 48 $gateways[] = $status . 49 ($canmanage ? html_writer::link($gateway->get_edit_url(), $gateway->get_display_name()) : $gateway->get_display_name()); 50 } 51 $name = $account->get_formatted_name(); 52 if (!$account->is_available()) { 53 $name .= ' ' . html_writer::span(get_string('accountnotavailable', 'payment'), 'badge badge-warning'); 54 } 55 if ($account->get('archived')) { 56 $name .= ' ' . html_writer::span(get_string('accountarchived', 'payment'), 'badge badge-secondary'); 57 } 58 59 $menu = new action_menu(); 60 $menu->set_alignment(action_menu::TL, action_menu::BL); 61 $menu->set_menu_trigger(get_string('edit')); 62 if ($canmanage) { 63 $menu->add(new action_menu_link_secondary($account->get_edit_url(), null, get_string('edit'))); 64 if (!$account->get('archived')) { 65 $deleteurl = $account->get_edit_url(['delete' => 1, 'sesskey' => sesskey()]); 66 $menu->add(new action_menu_link_secondary($deleteurl, null, get_string('deleteorarchive', 'payment'), 67 ['data-action' => 'delete'])); 68 } else { 69 $restoreurl = $account->get_edit_url(['restore' => 1, 'sesskey' => sesskey()]); 70 $menu->add(new action_menu_link_secondary($restoreurl, null, get_string('restoreaccount', 'payment'))); 71 } 72 } 73 74 $table->data[] = [$name, join(', ', $gateways), $OUTPUT->render($menu)]; 75 } 76 77 echo html_writer::div(get_string('paymentaccountsexplained', 'payment'), 'pb-2'); 78 79 if (has_capability('moodle/site:config', context_system::instance())) { 80 // For administrators add a link to "Manage payment gateways" page. 81 $link = html_writer::link(new moodle_url('/admin/settings.php', ['section' => 'managepaymentgateways']), 82 get_string('type_paygwmanage', 'plugin')); 83 $text = get_string('gotomanageplugins', 'payment', $link); 84 echo html_writer::div($text, 'pb-2'); 85 } 86 87 echo html_writer::table($table); 88 89 $PAGE->requires->event_handler('[data-action=delete]', 'click', 'M.util.show_confirm_dialog', 90 array('message' => get_string('accountdeleteconfirm', 'payment'))); 91 92 echo html_writer::div(html_writer::link(new moodle_url($PAGE->url, ['showarchived' => !$showarchived]), 93 $showarchived ? get_string('hidearchived', 'payment') : get_string('showarchived', 'payment')), 'mdl-right'); 94 95 echo $OUTPUT->single_button(new moodle_url('/payment/manage_account.php'), get_string('createaccount', 'payment'), 'get'); 96 97 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body