-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.php
200 lines (152 loc) · 7.72 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?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/>.
/**
*
* @package enrol_ues
* @copyright 2008 onwards Louisiana State University
* @copyright 2008 onwards Philip Cali, Adam Zapletal, Chad Mazilly, Robert Russo, Dave Elliott
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
require_once(dirname(__FILE__) . '/publiclib.php');
$plugins = ues::list_plugins();
$s = ues::gen_str();
$settings->add(new admin_setting_heading('enrol_ues_settings', '',
$s('pluginname_desc')));
// Scheduled Task Status.
$settings->add(new admin_setting_heading('enrol_ues_task_status',
$s('task_status'), ues::get_task_status_description()));
// Internal Links.
$urls = new stdClass;
$urls->cleanup_url = $CFG->wwwroot . '/enrol/ues/cleanup.php';
$urls->failure_url = $CFG->wwwroot . '/enrol/ues/failures.php';
$urls->ignore_url = $CFG->wwwroot . '/enrol/ues/ignore.php';
$urls->adhoc_url = $CFG->wwwroot . '/enrol/ues/adhoc.php';
$settings->add(new admin_setting_heading('enrol_ues_internal_links',
$s('management'), $s('management_links', $urls)));
// General Settings.
$settings->add(new admin_setting_heading('enrol_ues_general_settings',
$s('general_settings'), ''));
if (!empty($plugins)) {
$settings->add(new admin_setting_configselect('enrol_ues/enrollment_provider',
$s('provider'), $s('provider_desc'), key($plugins), $plugins));
}
$settings->add(new admin_setting_configcheckbox('enrol_ues/process_by_department',
$s('process_by_department'), $s('process_by_department_desc'), 1));
$settings->add(new admin_setting_configcheckbox('enrol_ues/running',
$s('running'), $s('running_desc'), 0));
$settings->add(new admin_setting_configtext('enrol_ues/grace_period',
$s('grace_period'), $s('grace_period_desc'), 3600));
$settings->add(new admin_setting_configtext('enrol_ues/sub_days',
$s('sub_days'), $s('sub_days_desc'), 60));
$settings->add(new admin_setting_configtext('enrol_ues/error_threshold',
$s('error_threshold'), $s('error_threshold_desc'), 100));
$settings->add(new admin_setting_configcheckbox('enrol_ues/email_report',
$s('email_report'), $s('email_report_desc'), 1));
// User Creation Settings.
$settings->add(new admin_setting_heading('enrol_ues_user_settings',
$s('user_settings'), ''));
$settings->add(new admin_setting_configtext('enrol_ues/user_email',
$s('user_email'), $s('user_email_desc'), '@example.com'));
$settings->add(new admin_setting_configcheckbox('enrol_ues/user_confirm',
$s('user_confirm'), $s('user_confirm_desc'), 1));
$languages = get_string_manager()->get_list_of_translations();
$settings->add(new admin_setting_configselect('enrol_ues/user_lang',
get_string('language'), '', $CFG->lang, $languages));
$auths = get_plugin_list('auth');
$authoptions = array();
foreach ($auths as $auth => $unused) {
$authoptions[$auth] = get_string('pluginname', "auth_{$auth}");
}
$settings->add(new admin_setting_configselect('enrol_ues/user_auth',
$s('user_auth'), $s('user_auth_desc'), 'manual', $authoptions));
$settings->add(new admin_setting_configtext('enrol_ues/user_city',
$s('user_city'), $s('user_city_desc'), ''));
$countries = get_string_manager()->get_list_of_countries();
$settings->add(new admin_setting_configselect('enrol_ues/user_country',
$s('user_country'), $s('user_country_desc'), $CFG->country, $countries));
// Course Creation Settings.
$settings->add(new admin_setting_heading('enrol_ues_course_settings',
$s('course_settings'), ''));
$settings->add(new admin_setting_configtext('enrol_ues/course_fullname',
get_string('fullname'), '', $s('course_shortname')));
$settings->add(new admin_setting_configtext('enrol_ues/course_shortname',
get_string('shortname'), $s('course_shortname_desc'),
$s('course_shortname')));
$settings->add(new admin_setting_configcheckbox('enrol_ues/course_form_replace',
$s('course_form_replace'), $s('course_form_replace_desc'), 0));
$fields = array(
'newsitems' => get_string('newsitemsnumber'),
'showgrades' => get_string('showgrades'),
'showreports' => get_string('showreports'),
'maxbytes' => get_string('maximumupload'),
'groupmode' => get_string('groupmode'),
'groupmodeforce' => get_string('groupmodeforce'),
'lang' => get_string('forcelanguage')
);
$defaults = array('groupmode', 'groupmodeforce');
$settings->add(new admin_setting_configmultiselect('enrol_ues/course_restricted_fields',
$s('course_restricted_fields'), $s('course_restricted_fields_desc'),
$defaults, $fields));
// User Enrollment Settings.
$settings->add(new admin_setting_heading('enrol_ues_enrol_settings',
$s('enrol_settings'), ''));
$roles = role_get_names(null, null, true);
foreach (array('editingteacher', 'teacher', 'student') as $shortname) {
$typeid = $DB->get_field('role', 'id', array('shortname' => $shortname));
$settings->add(new admin_setting_configselect('enrol_ues/'.$shortname.'_role',
$s($shortname.'_role'), $s($shortname.'_role_desc'), $typeid, $roles));
}
$settings->add(new admin_setting_configcheckbox('enrol_ues/recover_grades',
$s('recover_grades'), $s('recover_grades_desc'), 1));
$settings->add(new admin_setting_configcheckbox('enrol_ues/suspend_enrollment',
$s('suspend_enrollment'), $s('suspend_enrollment_desc'), 0));
// Specific Provider Settings.
$provider = ues::provider_class();
if ($provider) {
try {
// Attempting to create the provider.
$testprovider = new $provider();
$testprovider->settings($settings);
$works = (
$testprovider->supports_section_lookups() or
$testprovider->supports_department_lookups()
);
if ($works === false) {
throw new Exception('enrollment_unsupported');
}
$a = new stdClass;
$a->name = $testprovider->get_name();
$a->list = '';
if ($testprovider->supports_department_lookups()) {
$a->list .= '<li>' . ues::_s('process_by_department') . '</li>';
}
if ($testprovider->supports_section_lookups()) {
$a->list .= '<li>' . ues::_s('process_by_section') . '</li>';
}
if ($testprovider->supports_reverse_lookups()) {
$a->list .= '<li>' . ues::_s('reverse_lookups') . '</li>';
}
$settings->add(new admin_setting_heading('provider_information',
$s('provider_information'), $s('provider_information_desc', $a)));
} catch (Exception $e) {
$a = ues::translate_error($e);
$settings->add(new admin_setting_heading('provider_problem',
$s('provider_problems'), $s('provider_problems_desc', $a)));
}
}
}