2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Settings for the Fee enrolment plugin
21 * @copyright 2019 Shamim Rezaie <shamim@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
27 if ($ADMIN->fulltree
) {
29 $currencies = enrol_get_plugin('fee')->get_possible_currencies();
31 if (empty($currencies)) {
32 $notify = new \core\output\notification
(
33 get_string('nocurrencysupported', 'core_payment'),
34 \core\output\notification
::NOTIFY_WARNING
36 $settings->add(new admin_setting_heading('enrol_fee_nocurrency', '', $OUTPUT->render($notify)));
39 $settings->add(new admin_setting_heading('enrol_fee_settings', '', get_string('pluginname_desc', 'enrol_fee')));
41 // Note: let's reuse the ext sync constants and strings here, internally it is very similar,
42 // it describes what should happen when users are not supposed to be enrolled any more.
44 ENROL_EXT_REMOVED_KEEP
=> get_string('extremovedkeep', 'enrol'),
45 ENROL_EXT_REMOVED_SUSPENDNOROLES
=> get_string('extremovedsuspendnoroles', 'enrol'),
46 ENROL_EXT_REMOVED_UNENROL
=> get_string('extremovedunenrol', 'enrol'),
48 $settings->add(new admin_setting_configselect(
49 'enrol_fee/expiredaction',
50 get_string('expiredaction', 'enrol_fee'),
51 get_string('expiredaction_help', 'enrol_fee'),
52 ENROL_EXT_REMOVED_SUSPENDNOROLES
,
55 $settings->add(new admin_setting_heading('enrol_fee_defaults',
56 get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
58 $options = array(ENROL_INSTANCE_ENABLED
=> get_string('yes'),
59 ENROL_INSTANCE_DISABLED
=> get_string('no'));
60 $settings->add(new admin_setting_configselect('enrol_fee/status',
61 get_string('status', 'enrol_fee'), get_string('status_desc', 'enrol_fee'), ENROL_INSTANCE_DISABLED
, $options));
63 if (!empty($currencies)) {
64 $settings->add(new admin_setting_configtext('enrol_fee/cost', get_string('cost', 'enrol_fee'), '', 0, PARAM_FLOAT
, 4));
65 $settings->add(new admin_setting_configselect('enrol_fee/currency', get_string('currency', 'enrol_fee'), '', 'USD',
69 if (!during_initial_install()) {
70 $options = get_default_enrol_roles(context_system
::instance());
71 $student = get_archetype_roles('student');
72 $student = reset($student);
73 $settings->add(new admin_setting_configselect('enrol_fee/roleid',
74 get_string('defaultrole', 'enrol_fee'), get_string('defaultrole_desc', 'enrol_fee'), $student->id ??
null, $options));
77 $settings->add(new admin_setting_configduration('enrol_fee/enrolperiod',
78 get_string('enrolperiod', 'enrol_fee'), get_string('enrolperiod_desc', 'enrol_fee'), 0));