MDL-63683 enrol: Fix plugin settings when no role has student archetype
[moodle.git] / enrol / paypal / settings.php
CommitLineData
5ea88553 1<?php
5ea88553
AB
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 * Paypal enrolments plugin settings and presets.
19 *
31ac2aef 20 * @package enrol_paypal
24a62572
PS
21 * @copyright 2010 Eugene Venter
22 * @author Eugene Venter - based on code by Petr Skoda and others
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
5ea88553
AB
24 */
25
97795859 26defined('MOODLE_INTERNAL') || die();
5ea88553
AB
27
28if ($ADMIN->fulltree) {
29
30 //--- settings ------------------------------------------------------------------------------------------
31 $settings->add(new admin_setting_heading('enrol_paypal_settings', '', get_string('pluginname_desc', 'enrol_paypal')));
32
33 $settings->add(new admin_setting_configtext('enrol_paypal/paypalbusiness', get_string('businessemail', 'enrol_paypal'), get_string('businessemail_desc', 'enrol_paypal'), '', PARAM_EMAIL));
34
35 $settings->add(new admin_setting_configcheckbox('enrol_paypal/mailstudents', get_string('mailstudents', 'enrol_paypal'), '', 0));
36
37 $settings->add(new admin_setting_configcheckbox('enrol_paypal/mailteachers', get_string('mailteachers', 'enrol_paypal'), '', 0));
38
39 $settings->add(new admin_setting_configcheckbox('enrol_paypal/mailadmins', get_string('mailadmins', 'enrol_paypal'), '', 0));
40
d9a707ad
PS
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.
43 $options = array(
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'),
47 );
48 $settings->add(new admin_setting_configselect('enrol_paypal/expiredaction', get_string('expiredaction', 'enrol_paypal'), get_string('expiredaction_help', 'enrol_paypal'), ENROL_EXT_REMOVED_SUSPENDNOROLES, $options));
49
5ea88553
AB
50 //--- enrol instance defaults ----------------------------------------------------------------------------
51 $settings->add(new admin_setting_heading('enrol_paypal_defaults',
52 get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
53
42761bc6
PS
54 $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
55 ENROL_INSTANCE_DISABLED => get_string('no'));
56 $settings->add(new admin_setting_configselect('enrol_paypal/status',
57 get_string('status', 'enrol_paypal'), get_string('status_desc', 'enrol_paypal'), ENROL_INSTANCE_DISABLED, $options));
5ea88553 58
42761bc6 59 $settings->add(new admin_setting_configtext('enrol_paypal/cost', get_string('cost', 'enrol_paypal'), '', 0, PARAM_FLOAT, 4));
5ea88553 60
0456edb4 61 $paypalcurrencies = enrol_get_plugin('paypal')->get_currencies();
0cd579d7 62 $settings->add(new admin_setting_configselect('enrol_paypal/currency', get_string('currency', 'enrol_paypal'), '', 'USD', $paypalcurrencies));
5ea88553 63
5ea88553 64 if (!during_initial_install()) {
55bcef29 65 $options = get_default_enrol_roles(context_system::instance());
5ea88553
AB
66 $student = get_archetype_roles('student');
67 $student = reset($student);
42761bc6 68 $settings->add(new admin_setting_configselect('enrol_paypal/roleid',
12b9c605
DM
69 get_string('defaultrole', 'enrol_paypal'),
70 get_string('defaultrole_desc', 'enrol_paypal'),
71 $student->id ?? null,
72 $options));
5ea88553
AB
73 }
74
ef2737a4
PS
75 $settings->add(new admin_setting_configduration('enrol_paypal/enrolperiod',
76 get_string('enrolperiod', 'enrol_paypal'), get_string('enrolperiod_desc', 'enrol_paypal'), 0));
5ea88553 77}