-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
208 lines (181 loc) · 8.41 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
201
202
203
204
205
206
207
208
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Plugin administration pages are defined here.
*
* @package local_urise
* @category admin
* @copyright 2024 Wunderbyte Gmbh <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $DB;
if ($hassiteconfig) {
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
// TODO: Define the plugin settings page - {@link https://docs.moodle.org/dev/Admin_settings}.
$settings = new admin_settingpage('urise', '');
$ADMIN->add('localplugins', new admin_category('local_urise', get_string('pluginname', 'local_urise')));
$ADMIN->add('local_urise', $settings);
if ($ADMIN->fulltree) {
$settings->add(
new admin_setting_heading('shortcodessetdefaultinstance',
get_string('shortcodessetdefaultinstance', 'local_urise'),
get_string('shortcodessetdefaultinstancedesc', 'local_urise')));
$allowedinstances = [];
$multiinstances = [];
if ($records = $DB->get_records_sql(
"SELECT cm.id cmid, b.id bookingid, b.name bookingname
FROM {course_modules} cm
LEFT JOIN {booking} b
ON b.id = cm.instance
WHERE cm.module IN (
SELECT id
FROM {modules} m
WHERE m.name = 'booking'
)"
)) {
foreach ($records as $record) {
$allowedinstances[$record->cmid] = "$record->bookingname (ID: $record->cmid)";
$multiinstances[$record->bookingid] = $record->bookingname;
$defaultcmid = $record->cmid; // Last cmid will be the default one.
}
}
if (empty($allowedinstances)) {
// If we have no instances, show an explanation text.
$settings->add(new admin_setting_description(
'shortcodesnobookinginstance',
get_string('shortcodesnobookinginstance', 'local_urise'),
get_string('shortcodesnobookinginstancedesc', 'local_urise')
));
} else {
// Show select for cmids of booking instances.
$settings->add(
new admin_setting_configselect('local_urise/shortcodessetinstance',
get_string('shortcodessetinstance', 'local_urise'),
get_string('shortcodessetinstancedesc', 'local_urise'),
$defaultcmid, $allowedinstances));
}
if (!empty($multiinstances)) {
// Booking default instances.
$componentname = 'local_urise';
$settings->add(new admin_setting_configmultiselect(
$componentname . '/multibookinginstances',
get_string('multibookinginstances', $componentname),
get_string('multibookinginstances_desc', $componentname),
[],
$multiinstances)
);
}
$settings->add(
new admin_setting_configtext('local_urise/shortcodesarchivecmids',
get_string('shortcodesarchivecmids', 'local_urise'),
get_string('shortcodesarchivecmids_desc', 'local_urise'), ''));
$settings->add(
new admin_setting_configtext('local_urise/excludecourselistindashboard',
get_string('excludecourselistindashboard', 'local_urise'),
get_string('excludecourselistindashboard_desc', 'local_urise'), ''));
// Shortcode lists.
$settings->add(
new admin_setting_heading('shortcodelists',
get_string('shortcodelists', 'local_urise'),
get_string('shortcodelists_desc', 'local_urise')));
$settings->add(
new admin_setting_configcheckbox('local_urise/shortcodelists_showdescriptions',
get_string('shortcodelists_showdescriptions', 'local_urise'), '', 0));
$settings->add(
new admin_setting_configcheckbox('local_urise/uriseshortcodesshowstart',
get_string('uriseshortcodes:showstart', 'local_urise'), '', 0));
$settings->add(
new admin_setting_configcheckbox('local_urise/uriseshortcodesshowend',
get_string('uriseshortcodes:showend', 'local_urise'), '', 0));
$settings->add(
new admin_setting_configcheckbox('local_urise/uriseshortcodesshowbookablefrom',
get_string('uriseshortcodes:showbookablefrom', 'local_urise'), '', 0));
$settings->add(
new admin_setting_configcheckbox('local_urise/uriseshortcodesshowbookableuntil',
get_string('uriseshortcodes:showbookableuntil', 'local_urise'), '', 0));
$showfiltercoursetimesetting = new admin_setting_configcheckbox('local_urise/uriseshortcodesshowfiltercoursetime',
get_string('uriseshortcodes:showfiltercoursetime', 'local_urise'), '', 0);
$showfiltercoursetimesetting->set_updatedcallback(function() {
cache_helper::purge_by_event('setbackoptionstable');
});
$settings->add($showfiltercoursetimesetting);
$showfilterbookingtimesetting = new admin_setting_configcheckbox('local_urise/uriseshortcodesshowfilterbookingtime',
get_string('uriseshortcodes:showfilterbookingtime', 'local_urise'), '', 0);
$showfilterbookingtimesetting->set_updatedcallback(function() {
cache_helper::purge_by_event('setbackoptionstable');
});
$settings->add($showfilterbookingtimesetting);
$collapsedescriptionoptions = [
0 => get_string('collapsedescriptionoff', 'local_urise'),
100 => "100",
125 => "125",
150 => "150",
175 => "175",
200 => "200",
300 => "300",
400 => "400",
500 => "500",
600 => "600",
700 => "700",
800 => "800",
900 => "900",
];
$settings->add(
new admin_setting_configselect(
'local_urise/collapsedescriptionmaxlength',
get_string('collapsedescriptionmaxlength', 'local_urise'),
get_string('collapsedescriptionmaxlength_desc', 'local_urise'),
300, $collapsedescriptionoptions));
$settings->add(new admin_setting_configtextarea(
'local_urise/organisationfilter',
get_string('organisationfilterdefinition', 'local_urise'),
get_string('organisationfilterdefinition_desc', 'local_urise'),
'',
PARAM_TEXT,
60,
10
));
$settings->add(new admin_setting_configtextarea(
'local_urise/extrashortcodeone',
get_string('extrashortcodeone', 'local_urise'),
get_string('extrashortcodeone_desc', 'local_urise'),
'',
PARAM_RAW,
60,
10
));
$settings->add(new admin_setting_configtextarea(
'local_urise/extrashortcodetwo',
get_string('extrashortcodetwo', 'local_urise'),
get_string('extrashortcodetwo_desc', 'local_urise'),
'',
PARAM_RAW,
60,
10
));
// CONTRACT MANAGEMENT.
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
/* $settings->add(
new admin_setting_heading('contractmanagement_heading',
get_string('contractmanagementsettings', 'local_urise'),
get_string('contractmanagementsettings_desc', 'local_urise')));
$settings->add(
new admin_setting_configtextarea('local_urise/contractformula',
get_string('contractformula', 'local_urise'),
get_string('contractformula_desc', 'local_urise'), '', PARAM_TEXT, 60, 10)); */
}
}