MDL-27171 messages: add message outputs management interface page
[moodle.git] / admin / settings / plugins.php
CommitLineData
11b749ca 1<?php
220a90c5 2
b63a6a63 3/*
4 * Please note that is file is always loaded last - it means that you can inject entries into other categories too.
5 */
6
78946b9b 7if ($hassiteconfig) {
b9934a17 8 $ADMIN->add('modules', new admin_page_pluginsoverview());
ff4b9fcb 9 $ADMIN->add('modules', new admin_category('modsettings', get_string('activitymodules')));
220a90c5 10 $ADMIN->add('modsettings', new admin_page_managemods());
73d0160f
PS
11 $modules = $DB->get_records('modules', array(), "name ASC");
12 foreach ($modules as $module) {
13 $modulename = $module->name;
14 if (!file_exists("$CFG->dirroot/mod/$modulename/lib.php")) {
15 continue;
220a90c5 16 }
73d0160f 17 $strmodulename = get_string('modulename', 'mod_'.$modulename);
dbf9e4ba 18 if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) {
73d0160f
PS
19 // do not show disabled modules in tree, keep only settings link on manage page
20 $settings = new admin_settingpage('modsetting'.$modulename, $strmodulename, 'moodle/site:config', !$module->visible);
dbf9e4ba
PS
21 include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
22 if ($settings) {
23 $ADMIN->add('modsettings', $settings);
220a90c5 24 }
25 }
26 }
27
b032b490 28 // hidden script for converting journals to online assignments (or something like that) linked from elsewhere
29 $ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
220a90c5 30
31 $ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks')));
32 $ADMIN->add('blocksettings', new admin_page_manageblocks());
73d0160f
PS
33 $blocks = $DB->get_records('block', array(), "name ASC");
34 foreach ($blocks as $block) {
35 $blockname = $block->name;
36 if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
37 continue;
220a90c5 38 }
73d0160f
PS
39 $strblockname = get_string('pluginname', 'block_'.$blockname);
40 if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
41 $settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
dbf9e4ba
PS
42 include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
43 if ($settings) {
44 $ADMIN->add('blocksettings', $settings);
220a90c5 45 }
46 }
47 }
48
75c34c23
RK
49 // message outputs
50 $ADMIN->add('modules', new admin_category('messageoutputs', get_string('messageoutputs', 'message')));
51 $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
52
53
df997f84
PS
54 // authentication plugins
55 $ADMIN->add('modules', new admin_category('authsettings', get_string('authentication', 'admin')));
56
57 $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin'));
58 $temp->add(new admin_setting_manageauths());
59 $temp->add(new admin_setting_heading('manageauthscommonheading', get_string('commonsettings', 'admin'), ''));
60 $temp->add(new admin_setting_special_registerauth());
61 $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'),
62 get_string('showguestlogin', 'auth'), '1', array('0'=>get_string('hide'), '1'=>get_string('show'))));
63 $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'),
64 get_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
65 $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'),
66 get_string('forgottenpassword', 'auth'), ''));
67 $temp->add(new admin_setting_confightmleditor('auth_instructions', get_string('instructions', 'auth'),
68 get_string('authinstructions', 'auth'), ''));
69 $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
70 $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
71 $temp->add(new admin_setting_configcheckbox('verifychangedemail', get_string('verifychangedemail', 'admin'), get_string('configverifychangedemail', 'admin'), 1));
72
73 $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
74 $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
75 $ADMIN->add('authsettings', $temp);
76
77
dbf9e4ba
PS
78 $auths = get_plugin_list('auth');
79 $authsenabled = get_enabled_auth_plugins();
80 foreach ($auths as $authname => $authdir) {
81 $strauthname = get_string('pluginname', "auth_{$authname}");
82 // do not show disabled auths in tree, keep only settings link on manage page
83 $enabled = in_array($authname, $authsenabled);
84 if (file_exists($authdir.'/settings.php')) {
85 // TODO: finish implementation of common settings - locking, etc.
86 $settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !$enabled);
87 include($authdir.'/settings.php');
88 if ($settings) {
df997f84 89 $ADMIN->add('authsettings', $settings);
df997f84 90 }
dbf9e4ba
PS
91
92 } else {
93 $ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !$enabled));
df997f84
PS
94 }
95 }
96
97
98 // Enrolment plugins
99 $ADMIN->add('modules', new admin_category('enrolments', get_string('enrolments', 'enrol')));
100 $temp = new admin_settingpage('manageenrols', get_string('manageenrols', 'enrol'));
101 $temp->add(new admin_setting_manageenrols());
102 if (empty($CFG->enrol_plugins_enabled)) {
103 $enabled = array();
104 } else {
105 $enabled = explode(',', $CFG->enrol_plugins_enabled);
106 }
107 $enrols = get_plugin_list('enrol');
108 $ADMIN->add('enrolments', $temp);
109 foreach($enrols as $enrol=>$enrolpath) {
110 if (!file_exists("$enrolpath/settings.php")) {
111 continue;
112 }
113
114 $settings = new admin_settingpage('enrolsettings'.$enrol, get_string('pluginname', 'enrol_'.$enrol), 'moodle/site:config', !in_array($enrol, $enabled));
115 // settings.php may create a subcategory or unset the settings completely
116 include("$enrolpath/settings.php");
117 if ($settings) {
118 $ADMIN->add('enrolments', $settings);
119 }
120
121 }
122 unset($enabled);
123 unset($enrols);
124
c5d2d0dd 125
a5747cf8 126/// Editor plugins
127 $ADMIN->add('modules', new admin_category('editorsettings', get_string('editors', 'editor')));
128 $temp = new admin_settingpage('manageeditors', get_string('editorsettings', 'editor'));
129 $temp->add(new admin_setting_manageeditors());
20e5da7d 130 $htmleditors = editors_get_available();
a5747cf8 131 $ADMIN->add('editorsettings', $temp);
132
20e5da7d 133 $editors_available = editors_get_available();
7a856a93
DC
134 foreach ($editors_available as $editor=>$editorstr) {
135 if (file_exists($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php')) {
6fc67fce
PS
136 $settings = new admin_settingpage('editorsettings'.$editor, get_string('pluginname', 'editor_'.$editor), 'moodle/site:config');
137 // settings.php may create a subcategory or unset the settings completely
138 include($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php');
139 if ($settings) {
140 $ADMIN->add('editorsettings', $settings);
141 }
df997f84 142 }
7a856a93 143 }
6fc67fce 144
1dce6261 145/// License types
7936470a 146 $ADMIN->add('modules', new admin_category('licensesettings', get_string('licenses')));
47576a5e 147 $temp = new admin_settingpage('managelicenses', get_string('managelicenses', 'admin'));
ba74f517
DC
148
149 require_once($CFG->libdir . '/licenselib.php');
150 $licenses = array();
151 $array = explode(',', $CFG->licenses);
152 foreach ($array as $value) {
153 $licenses[$value] = get_string($value, 'license');
154 }
155 $temp->add(new admin_setting_configselect('sitedefaultlicense', get_string('configsitedefaultlicense','admin'), get_string('configsitedefaultlicensehelp','admin'), 'allrightsreserved', $licenses));
1dce6261
DC
156 $temp->add(new admin_setting_managelicenses());
157 $ADMIN->add('licensesettings', $temp);
a5747cf8 158
159/// Filter plugins
220a90c5 160 $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters')));
dcdf3b29 161
162 $ADMIN->add('filtersettings', new admin_page_managefilters());
163
220a90c5 164 // "filtersettings" settingpage
dcdf3b29 165 $temp = new admin_settingpage('commonfiltersettings', get_string('commonfiltersettings', 'admin'));
220a90c5 166 if ($ADMIN->fulltree) {
5b8fa09b 167 $cachetimes = array(
168 604800 => get_string('numdays','',7),
169 86400 => get_string('numdays','',1),
170 43200 => get_string('numhours','',12),
171 10800 => get_string('numhours','',3),
172 7200 => get_string('numhours','',2),
173 3600 => get_string('numhours','',1),
174 2700 => get_string('numminutes','',45),
175 1800 => get_string('numminutes','',30),
176 900 => get_string('numminutes','',15),
177 600 => get_string('numminutes','',10),
178 540 => get_string('numminutes','',9),
179 480 => get_string('numminutes','',8),
180 420 => get_string('numminutes','',7),
181 360 => get_string('numminutes','',6),
182 300 => get_string('numminutes','',5),
183 240 => get_string('numminutes','',4),
184 180 => get_string('numminutes','',3),
185 120 => get_string('numminutes','',2),
186 60 => get_string('numminutes','',1),
187 30 => get_string('numseconds','',30),
188 0 => get_string('no')
189 );
109e3cb2 190 $items = array();
5b8fa09b 191 $items[] = new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, $cachetimes);
192 $items[] = new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0,
193 array('0' => get_string('none'), '1' => get_string('allfiles'), '2' => get_string('htmlfilesonly')));
109e3cb2 194 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
195 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 196 foreach ($items as $item) {
197 $item->set_updatedcallback('reset_text_filters_cache');
198 $temp->add($item);
199 }
220a90c5 200 }
201 $ADMIN->add('filtersettings', $temp);
202
5b8fa09b 203 $activefilters = filter_get_globally_enabled();
b810a4d3 204 $filternames = filter_get_all_installed();
205 foreach ($filternames as $filterpath => $strfiltername) {
206 if (file_exists("$CFG->dirroot/$filterpath/filtersettings.php")) {
207 $settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterpath),
5b8fa09b 208 $strfiltername, 'moodle/site:config', !isset($activefilters[$filterpath]));
dbf9e4ba
PS
209 include("$CFG->dirroot/$filterpath/filtersettings.php");
210 if ($settings) {
211 $ADMIN->add('filtersettings', $settings);
220a90c5 212 }
213 }
214 }
67a87e7d 215
78946b9b
PS
216
217 //== Portfolio settings ==
218 require_once($CFG->libdir. '/portfoliolib.php');
b810a4d3 219 $catname = get_string('portfolios', 'portfolio');
67a87e7d 220 $manage = get_string('manageportfolios', 'portfolio');
221 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
222
90658eef 223 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 224
9d81733d
SM
225 // Add manage page (with table)
226 $temp = new admin_page_manageportfolios();
227 $ADMIN->add('portfoliosettings', $temp);
228
229 // Add common settings page
230 $temp = new admin_settingpage('manageportfolioscommon', get_string('commonportfoliosettings', 'portfolio'));
231 $temp->add(new admin_setting_heading('manageportfolioscommon', '', get_string('commonsettingsdesc', 'portfolio')));
bee4bce2 232 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
233 $fileoptions = $fileinfo['options'];
234 $temp->add(new admin_setting_configselect(
235 'portfolio_moderate_filesize_threshold',
236 get_string('moderatefilesizethreshold', 'portfolio'),
237 get_string('moderatefilesizethresholddesc', 'portfolio'),
238 $fileinfo['moderate'], $fileoptions));
239 $temp->add(new admin_setting_configselect(
240 'portfolio_high_filesize_threshold',
241 get_string('highfilesizethreshold', 'portfolio'),
242 get_string('highfilesizethresholddesc', 'portfolio'),
243 $fileinfo['high'], $fileoptions));
244
245 $temp->add(new admin_setting_configtext(
246 'portfolio_moderate_db_threshold',
247 get_string('moderatedbsizethreshold', 'portfolio'),
248 get_string('moderatedbsizethresholddesc', 'portfolio'),
249 20, PARAM_INTEGER, 3));
250
251 $temp->add(new admin_setting_configtext(
252 'portfolio_high_db_threshold',
253 get_string('highdbsizethreshold', 'portfolio'),
254 get_string('highdbsizethresholddesc', 'portfolio'),
255 50, PARAM_INTEGER, 3));
a50ef3d3 256
257 $ADMIN->add('portfoliosettings', $temp);
258 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', get_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
259 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', get_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
260 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', get_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
261
08d5e18b 262 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 263 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 264 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 265 $ADMIN->add(
266 'portfoliosettings',
08d5e18b 267 new admin_externalpage(
268 'portfoliosettings' . $portfolio->get('id'),
658837bb 269 $portfolio->get('name'),
6010eda2
MD
270 $url . '?action=edit&pf=' . $portfolio->get('id'),
271 'moodle/site:config'
08d5e18b 272 ),
a50ef3d3 273 $portfolio->get('name'),
6010eda2 274 $url . '?action=edit&pf=' . $portfolio->get('id')
a50ef3d3 275 );
67a87e7d 276 }
4a65c39a 277
278 // repository setting
279 require_once("$CFG->dirroot/repository/lib.php");
280 $catname =get_string('repositories', 'repository');
04bd6d2d 281 $managerepo = get_string('manage', 'repository');
282 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 283 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
9d81733d
SM
284
285 // Add main page (with table)
286 $temp = new admin_page_managerepositories();
287 $ADMIN->add('repositorysettings', $temp);
288
289 // Add common settings page
290 $temp = new admin_settingpage('managerepositoriescommon', get_string('commonrepositorysettings', 'repository'));
5430f05b 291 $temp->add(new admin_setting_configtext('repositorycacheexpire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
99d52655 292 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', get_string('allowexternallinks', 'repository'), get_string('configallowexternallinks', 'repository'), 1));
95dbbf3a 293 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', get_string('legacyfilesinnewcourses', 'admin'), get_string('legacyfilesinnewcourses_help', 'admin'), 0));
4a65c39a 294 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 295 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
0d099914 296 get_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 297 '', $url);
298 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
299 get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
300 '', $url);
301 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
fe9d7318 302 get_string('manage', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 303 '', $url);
0d099914 304 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
305 get_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
306 '', $url);
307 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
308 get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
309 '', $url);
78946b9b 310 foreach (repository::get_types() as $repositorytype) {
edb50637 311 //display setup page for plugins with: general options or multiple instances (e.g. has instance config)
dbc01944 312 $typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
313 $instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
edb50637 314 if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
4a65c39a 315 $ADMIN->add('repositorysettings',
a6600395 316 new admin_externalpage('repositorysettings'.$repositorytype->get_typename(),
317 $repositorytype->get_readablename(),
79698344 318 $url . '?action=edit&repos=' . $repositorytype->get_typename()),
4a65c39a 319 'moodle/site:config');
320 }
321 }
78946b9b 322}
bee4bce2 323
5ae9f539 324/// Web services
cc93c7da 325 $ADMIN->add('modules', new admin_category('webservicesettings', get_string('webservices', 'webservice')));
3e6161fb 326 /// overview page
327 $temp = new admin_settingpage('webservicesoverview', get_string('webservicesoverview', 'webservice'));
328 $temp->add(new admin_setting_webservicesoverview());
329 $ADMIN->add('webservicesettings', $temp);
330 /// manage service
cc93c7da 331 $temp = new admin_settingpage('externalservices', get_string('externalservices', 'webservice'));
8399c714 332 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', get_string('information', 'webservice'), get_string('servicehelpexplanation', 'webservice')));
cc93c7da 333 $temp->add(new admin_setting_manageexternalservices());
334 $ADMIN->add('webservicesettings', $temp);
c25662b0 335 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', get_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
72977b37 336 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', get_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
337 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', get_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
86dcc6f0 338 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusersettings', get_string('serviceusersettings', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_user_settings.php", 'moodle/site:config', true));
5ae9f539 339 /// manage protocol page link
cc93c7da 340 $temp = new admin_settingpage('webserviceprotocols', get_string('manageprotocols', 'webservice'));
da124b5e 341 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 342 if (empty($CFG->enablewebservices)) {
343 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
344 }
b4c91012
SH
345
346 // We cannot use $OUTPUT this early, doing so means that we lose the ability
347 // to set the page layout on all admin pages.
348 // $wsdoclink = $OUTPUT->doc_link('How_to_get_a_security_key');
349 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
350 $wsdoclink = html_writer::tag('a', get_string('supplyinfo'),array('href'=>$url));
9ef728d6 351 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', get_string('enablewsdocumentation',
352 'admin'), get_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
cc93c7da 353 $ADMIN->add('webservicesettings', $temp);
5ae9f539 354 /// links to protocol pages
cc93c7da 355 $webservices_available = get_plugin_list('webservice');
356 $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
357 foreach ($webservices_available as $webservice => $location) {
358 if (file_exists("$location/settings.php")) {
359 $name = get_string('pluginname', 'webservice_'.$webservice);
360 $settings = new admin_settingpage('webservicesetting'.$webservice, $name, 'moodle/site:config', !in_array($webservice, $active_webservices) or empty($CFG->enablewebservices));
dbf9e4ba
PS
361 include("$location/settings.php");
362 if ($settings) {
363 $ADMIN->add('webservicesettings', $settings);
cc93c7da 364 }
cc93c7da 365 }
366 }
5ae9f539 367 /// manage token page link
15e417fe 368 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', get_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
5ae9f539 369 $temp = new admin_settingpage('webservicetokens', get_string('managetokens', 'webservice'));
370 $temp->add(new admin_setting_managewebservicetokens());
371 if (empty($CFG->enablewebservices)) {
372 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
373 }
374 $ADMIN->add('webservicesettings', $temp);
df997f84 375
b6eb984a 376// Question type settings
78946b9b 377if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
bee4bce2 378 // Question type settings.
379 $ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin')));
380 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
63b5318e
TH
381 $qtypes = get_plugin_list('qtype');
382 foreach ($qtypes as $qtype => $path) {
383 $settingsfile = $path . '/settings.php';
bee4bce2 384 if (file_exists($settingsfile)) {
63b5318e
TH
385 $settings = new admin_settingpage('qtypesetting' . $qtype,
386 get_string('pluginname', 'qtype_' . $qtype), 'moodle/question:config');
dbf9e4ba
PS
387 include($settingsfile);
388 if ($settings) {
389 $ADMIN->add('qtypesettings', $settings);
bee4bce2 390 }
bee4bce2 391 }
392 }
220a90c5 393}
b6eb984a
TH
394
395// Plagiarism plugin settings
bce59524
DM
396if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
397 $ADMIN->add('modules', new admin_category('plagiarism', get_string('plagiarism', 'plagiarism')));
398 $temp = new admin_settingpage('plagiarismsettings', get_string('plagiarismsettings', 'plagiarism'));
399 $temp->add(new admin_setting_manageplagiarism());
400 $ADMIN->add('plagiarism', $temp);
401 foreach (get_plugin_list('plagiarism') as $plugin => $plugindir) {
402 if (file_exists($plugindir.'/settings.php')) {
403 $ADMIN->add('plagiarism', new admin_externalpage('plagiarism'.$plugin, get_string($plugin, 'plagiarism_'.$plugin), "$CFG->wwwroot/plagiarism/$plugin/settings.php", 'moodle/site:config'));
404 }
405 }
406}
1bcb7eb5 407$ADMIN->add('reports', new admin_externalpage('comments', get_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 408
b6eb984a
TH
409// Course reports settings
410if ($hassiteconfig) {
411 $pages = array();
412 foreach (get_plugin_list('coursereport') as $report => $path) {
413 $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
414 if (file_exists($file)) {
415 $settings = new admin_settingpage('coursereport' . $report,
416 get_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
417 // settings.php may create a subcategory or unset the settings completely
418 include($file);
419 if ($settings) {
420 $pages[] = $settings;
421 }
422 }
423 }
424 if (!empty($pages)) {
425 $ADMIN->add('modules', new admin_category('coursereports', get_string('coursereports')));
426 foreach ($pages as $page) {
427 $ADMIN->add('coursereports', $page);
428 }
429 }
430}
431
432// Now add reports
17da2e6f 433foreach (get_plugin_list('report') as $plugin => $plugindir) {
434 $settings_path = "$plugindir/settings.php";
b63a6a63 435 if (file_exists($settings_path)) {
436 include($settings_path);
437 continue;
438 }
439
17da2e6f 440 $index_path = "$plugindir/index.php";
b63a6a63 441 if (!file_exists($index_path)) {
442 continue;
443 }
444 // old style 3rd party plugin without settings.php
17da2e6f 445 $www_path = "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php";
c5fce2fa 446 $reportname = get_string($plugin, 'report_' . $plugin);
447 $ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, $www_path, 'moodle/site:viewreports'));
b63a6a63 448}
449
17da2e6f 450
451/// Add all local plugins - must be always last!
1ed47309
DM
452if ($hassiteconfig) {
453 $ADMIN->add('modules', new admin_category('localplugins', get_string('localplugins')));
454 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', get_string('localpluginsmanage'),
455 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
456}
17da2e6f 457
458foreach (get_plugin_list('local') as $plugin => $plugindir) {
459 $settings_path = "$plugindir/settings.php";
460 if (file_exists($settings_path)) {
461 include($settings_path);
462 continue;
463 }
1bcb7eb5 464}