Skip to content

Commit

Permalink
MDL-69166 core: list settings page in the admin tree
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Oct 26, 2020
1 parent e52362f commit 9e9ae7a
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
74 changes: 74 additions & 0 deletions admin/classes/local/settings/manage_payment_gateway_plugins.php
@@ -0,0 +1,74 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Payment gateway admin setting.
*
* @package core_admin
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace core_admin\local\settings;

/**
* Generic class for managing plugins in a table that allows re-ordering and enable/disable of each plugin.
*/
class manage_payment_gateway_plugins extends \admin_setting_manage_plugins {
/**
* Get the admin settings section title (use get_string).
*
* @return string
*/
public function get_section_title() {
return get_string('type_pg_plural', 'plugin');
}

/**
* Get the type of plugin to manage.
*
* @return string
*/
public function get_plugin_type() {
return 'pg';
}

/**
* Get the name of the second column.
*
* @return string
*/
public function get_info_column_name() {
return get_string('supportedcurrencies', 'core_payment');
}

/**
* Get the type of plugin to manage.
*
* @param plugininfo The plugin info class.
* @return string
*/
public function get_info_column($plugininfo) {
$codes = $plugininfo->get_supported_currencies();

$currencies = [];
foreach ($codes as $c) {
$currencies[$c] = new \lang_string($c, 'core_currencies');
}

return implode(get_string('listsep', 'langconfig') . ' ', $currencies);
}
}
13 changes: 13 additions & 0 deletions admin/settings/plugins.php
Expand Up @@ -280,6 +280,19 @@
$plugin->load_settings($ADMIN, 'mediaplayers', $hassiteconfig);
}

// Payment gateway plugins.
$ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_pg_plural', 'plugin')));
$temp = new admin_settingpage('managepaymentgateways', new lang_string('type_pgmanage', 'plugin'));
$temp->add(new \core_admin\local\settings\manage_payment_gateway_plugins());
$ADMIN->add('paymentgateways', $temp);

$plugins = core_plugin_manager::instance()->get_plugins_of_type('pg');
core_collator::asort_objects_by_property($plugins, 'displayname');
foreach ($plugins as $plugin) {
/** @var \core\plugininfo\pg $plugin */
$plugin->load_settings($ADMIN, 'paymentgateways', $hassiteconfig);
}

// Data format settings.
$ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
$temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
Expand Down
25 changes: 25 additions & 0 deletions lang/en/payment.php
@@ -0,0 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for component 'payment', language 'en'
*
* @package core_payment
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['supportedcurrencies'] = 'Supported currencies';
2 changes: 2 additions & 0 deletions lang/en/plugin.php
Expand Up @@ -165,6 +165,8 @@
$string['type_mnetservice_plural'] = 'MNet services';
$string['type_mod'] = 'Activity module';
$string['type_mod_plural'] = 'Activity modules';
$string['type_pgmanage'] = 'Manage payment gateways';
$string['type_pg_plural'] = 'Payment gateways';
$string['type_plagiarism'] = 'Plagiarism plugin';
$string['type_plagiarism_plural'] = 'Plagiarism plugins';
$string['type_portfolio'] = 'Portfolio';
Expand Down

0 comments on commit 9e9ae7a

Please sign in to comment.