-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
115 lines (98 loc) · 4.8 KB
/
settings.php
File metadata and controls
115 lines (98 loc) · 4.8 KB
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
<?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/>.
/**
* Settings for hyperplanningsync
*
* @package tool_hyperplanningsync
* @copyright 2020 CALL Learning
* @author Russell England <Russell.England@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use tool_hyperplanningsync\hyperplanningsync;
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
$ADMIN->add(
'accounts',
new admin_category(
'hyperplanningsync_menu',
new lang_string('hyperplanningsync:menu', 'tool_hyperplanningsync')));
$hyperplanningsyncimport = new admin_externalpage(
'tool_hyperplanningsync_import',
get_string('hyperplanningsync:import', 'tool_hyperplanningsync'),
new moodle_url("/$CFG->admin/tool/hyperplanningsync/index.php"),
'tool/hyperplanningsync:manage'
);
$ADMIN->add('hyperplanningsync_menu', $hyperplanningsyncimport);
$hyperplanningsynclog = new admin_externalpage(
'tool_hyperplanningsync_viewlog',
get_string('hyperplanningsync:viewlog', 'tool_hyperplanningsync'),
new moodle_url("/$CFG->admin/tool/hyperplanningsync/viewlog.php"),
'tool/hyperplanningsync:manage'
);
$ADMIN->add('hyperplanningsync_menu', $hyperplanningsynclog);
$hyperplanningsyncsettings = new admin_settingpage(
'tool_hyperplanningsync_settings',
get_string('hyperplanningsync:settings', 'tool_hyperplanningsync'),
'tool/hyperplanningsync:manage');
$options = [
'email' => get_string('email'),
'idnumber' => get_string('idnumber'),
'username' => get_string('username'),
];
$hyperplanningsyncsettings->add(new admin_setting_configselect(
'tool_hyperplanningsync/moodle_idfield', // Config name.
get_string('settings:moodle_idfield', 'tool_hyperplanningsync'), // Label.
get_string('settings:moodle_idfield_config', 'tool_hyperplanningsync'), // Help.
'email', // Default.
$options));
// Replacement and patterns for group name (see preg_replace).
$hyperplanningsyncsettings->add(new admin_setting_configtext(
'tool_hyperplanningsync/group_transform_pattern', // Group name transformation as a regexp.
get_string('settings:group_transform_pattern', 'tool_hyperplanningsync'), // Label.
get_string('settings:group_transform_pattern', 'tool_hyperplanningsync'), // Help.
'/(A[0-9]+)\s*gr([0-9]?\.[0-9]\.?[a-z0-9]?)/i'
));
$hyperplanningsyncsettings->add(new admin_setting_configtext(
'tool_hyperplanningsync/group_transform_replacement', // Group name replacement (as a regexp).
get_string('settings:group_transform_replacement', 'tool_hyperplanningsync'), // Label.
get_string('settings:group_transform_replacement', 'tool_hyperplanningsync'), // Help.
'\1\3Gr\2'
));
$hyperplanningsyncsettings->add(new admin_setting_configcheckbox(
'tool_hyperplanningsync/sync_new_users_enabled', // Config name.
get_string('settings:sync_new_users_enabled', 'tool_hyperplanningsync'), // Label.
get_string('settings:sync_new_users_enabled', 'tool_hyperplanningsync'), // Help.
false, // Default.
));
$fields = hyperplanningsync::get_fields();
$fields = hyperplanningsync::get_fields();
foreach ($fields as $fieldname => $default) {
$hyperplanningsyncsettings->add(new admin_setting_configtext(
'tool_hyperplanningsync/field_' . $fieldname, // Config name.
get_string('settings:field_' . $fieldname, 'tool_hyperplanningsync'), // Label.
get_string('settings:field_' . $fieldname . '_config', 'tool_hyperplanningsync'), // Help.
$default, // Default.
PARAM_RAW)); // Param type.
}
$ADMIN->add('hyperplanningsync_menu', $hyperplanningsyncsettings);
$hyperplanningsyncimport = new admin_externalpage(
'tool_hyperplanningsync_progress',
get_string('hyperplanningsync:progress', 'tool_hyperplanningsync'),
new moodle_url("/$CFG->admin/tool/hyperplanningsync/progress.php"),
'tool/hyperplanningsync:manage'
);
$ADMIN->add('hyperplanningsync_menu', $hyperplanningsyncimport);
}