MDL-22019 fixed notices caused by deleting blocks without unisntalling
[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) {
ff4b9fcb 8 $ADMIN->add('modules', new admin_category('modsettings', get_string('activitymodules')));
220a90c5 9 $ADMIN->add('modsettings', new admin_page_managemods());
823e64a7 10 if ($modules = $DB->get_records('modules')) {
220a90c5 11 $modulebyname = array();
12
13 foreach ($modules as $module) {
14 $strmodulename = get_string('modulename', $module->name);
15 // Deal with modules which are lacking the language string
16 if ($strmodulename == '[[modulename]]') {
17 $textlib = textlib_get_instance();
18 $strmodulename = $textlib->strtotitle($module->name);
19 }
20 $modulebyname[$strmodulename] = $module;
21 }
22 ksort($modulebyname);
23
24 foreach ($modulebyname as $strmodulename=>$module) {
25 $modulename = $module->name;
c37415a0 26 if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php')) {
27 include($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php');
28 } else if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) {
220a90c5 29 // do not show disabled modules in tree, keep only settings link on manage page
30 $settings = new admin_settingpage('modsetting'.$modulename, $strmodulename, 'moodle/site:config', !$module->visible);
31 if ($ADMIN->fulltree) {
32 include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
33 }
34 $ADMIN->add('modsettings', $settings);
220a90c5 35 }
36 }
37 }
38
b032b490 39 // hidden script for converting journals to online assignments (or something like that) linked from elsewhere
40 $ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
220a90c5 41
42 $ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks')));
43 $ADMIN->add('blocksettings', new admin_page_manageblocks());
ab2eb65c 44 if ($blocks = $DB->get_records('block')) {
220a90c5 45 $blockbyname = array();
46
47 foreach ($blocks as $block) {
6682cf18
PS
48 if (!file_exists("$CFG->dirroot/blocks/$block->name")) {
49 continue;
50 }
01ca2df0 51 if(($blockobject = block_instance($block->name)) === false) {
52 // Failed to load
53 continue;
220a90c5 54 }
01ca2df0 55 $blockbyname[$blockobject->get_title()] = $block;
220a90c5 56 }
57 ksort($blockbyname);
58
59 foreach ($blockbyname as $strblockname=>$block) {
60 $blockname = $block->name;
61 if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
62 $settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
63 if ($ADMIN->fulltree) {
64 include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
65 }
66 $ADMIN->add('blocksettings', $settings);
67
68 } else if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/config_global.html')) {
69 $ADMIN->add('blocksettings', new admin_externalpage('blocksetting'.$blockname, $strblockname, "$CFG->wwwroot/$CFG->admin/block.php?block=$block->id", 'moodle/site:config', !$block->visible));
70 }
71 }
72 }
73
c5d2d0dd 74
a5747cf8 75/// Editor plugins
76 $ADMIN->add('modules', new admin_category('editorsettings', get_string('editors', 'editor')));
77 $temp = new admin_settingpage('manageeditors', get_string('editorsettings', 'editor'));
78 $temp->add(new admin_setting_manageeditors());
79 $ADMIN->add('editorsettings', $temp);
80
7a856a93
DC
81 $editors_available = get_available_editors();
82 $url = $CFG->wwwroot.'/'.$CFG->admin.'/editors.php?sesskey='.sesskey();
83 foreach ($editors_available as $editor=>$editorstr) {
84 if (file_exists($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php')) {
85 $editor_setting = new admin_externalpage('editorsettings'.$editor, $editorstr, $url.'&amp;action=edit&amp;editor='.$editor);
86 $ADMIN->add('editorsettings', $editor_setting);
87 }
88 }
1dce6261
DC
89/// License types
90 $ADMIN->add('modules', new admin_category('licensesettings', get_string('license')));
91 $temp = new admin_settingpage('managelicenses', get_string('license'));
92 $temp->add(new admin_setting_managelicenses());
93 $ADMIN->add('licensesettings', $temp);
a5747cf8 94
95/// Filter plugins
220a90c5 96 $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters')));
dcdf3b29 97
98 $ADMIN->add('filtersettings', new admin_page_managefilters());
99
220a90c5 100 // "filtersettings" settingpage
dcdf3b29 101 $temp = new admin_settingpage('commonfiltersettings', get_string('commonfiltersettings', 'admin'));
220a90c5 102 if ($ADMIN->fulltree) {
5b8fa09b 103 $cachetimes = array(
104 604800 => get_string('numdays','',7),
105 86400 => get_string('numdays','',1),
106 43200 => get_string('numhours','',12),
107 10800 => get_string('numhours','',3),
108 7200 => get_string('numhours','',2),
109 3600 => get_string('numhours','',1),
110 2700 => get_string('numminutes','',45),
111 1800 => get_string('numminutes','',30),
112 900 => get_string('numminutes','',15),
113 600 => get_string('numminutes','',10),
114 540 => get_string('numminutes','',9),
115 480 => get_string('numminutes','',8),
116 420 => get_string('numminutes','',7),
117 360 => get_string('numminutes','',6),
118 300 => get_string('numminutes','',5),
119 240 => get_string('numminutes','',4),
120 180 => get_string('numminutes','',3),
121 120 => get_string('numminutes','',2),
122 60 => get_string('numminutes','',1),
123 30 => get_string('numseconds','',30),
124 0 => get_string('no')
125 );
109e3cb2 126 $items = array();
5b8fa09b 127 $items[] = new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, $cachetimes);
128 $items[] = new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0,
129 array('0' => get_string('none'), '1' => get_string('allfiles'), '2' => get_string('htmlfilesonly')));
109e3cb2 130 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
131 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 132 foreach ($items as $item) {
133 $item->set_updatedcallback('reset_text_filters_cache');
134 $temp->add($item);
135 }
220a90c5 136 }
137 $ADMIN->add('filtersettings', $temp);
138
5b8fa09b 139 $activefilters = filter_get_globally_enabled();
b810a4d3 140 $filternames = filter_get_all_installed();
141 foreach ($filternames as $filterpath => $strfiltername) {
142 if (file_exists("$CFG->dirroot/$filterpath/filtersettings.php")) {
143 $settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterpath),
5b8fa09b 144 $strfiltername, 'moodle/site:config', !isset($activefilters[$filterpath]));
b810a4d3 145 if ($ADMIN->fulltree) {
146 include("$CFG->dirroot/$filterpath/filtersettings.php");
220a90c5 147 }
b810a4d3 148 $ADMIN->add('filtersettings', $settings);
220a90c5 149 }
150 }
67a87e7d 151
78946b9b
PS
152
153 //== Portfolio settings ==
154 require_once($CFG->libdir. '/portfoliolib.php');
b810a4d3 155 $catname = get_string('portfolios', 'portfolio');
67a87e7d 156 $manage = get_string('manageportfolios', 'portfolio');
157 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
158
90658eef 159 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 160
a50ef3d3 161 // jump through hoops to do what we want
162 $temp = new admin_settingpage('manageportfolios', get_string('manageportfolios', 'portfolio'));
bee4bce2 163 $temp->add(new admin_setting_heading('manageportfolios', get_string('activeportfolios', 'portfolio'), ''));
a50ef3d3 164 $temp->add(new admin_setting_manageportfolio());
bee4bce2 165 $temp->add(new admin_setting_heading('manageportfolioscommon', get_string('commonsettings', 'admin'), get_string('commonsettingsdesc', 'portfolio')));
166 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
167 $fileoptions = $fileinfo['options'];
168 $temp->add(new admin_setting_configselect(
169 'portfolio_moderate_filesize_threshold',
170 get_string('moderatefilesizethreshold', 'portfolio'),
171 get_string('moderatefilesizethresholddesc', 'portfolio'),
172 $fileinfo['moderate'], $fileoptions));
173 $temp->add(new admin_setting_configselect(
174 'portfolio_high_filesize_threshold',
175 get_string('highfilesizethreshold', 'portfolio'),
176 get_string('highfilesizethresholddesc', 'portfolio'),
177 $fileinfo['high'], $fileoptions));
178
179 $temp->add(new admin_setting_configtext(
180 'portfolio_moderate_db_threshold',
181 get_string('moderatedbsizethreshold', 'portfolio'),
182 get_string('moderatedbsizethresholddesc', 'portfolio'),
183 20, PARAM_INTEGER, 3));
184
185 $temp->add(new admin_setting_configtext(
186 'portfolio_high_db_threshold',
187 get_string('highdbsizethreshold', 'portfolio'),
188 get_string('highdbsizethresholddesc', 'portfolio'),
189 50, PARAM_INTEGER, 3));
a50ef3d3 190
191 $ADMIN->add('portfoliosettings', $temp);
192 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', get_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
193 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', get_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
194 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', get_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
195
08d5e18b 196 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 197 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 198 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 199 $ADMIN->add(
200 'portfoliosettings',
08d5e18b 201 new admin_externalpage(
202 'portfoliosettings' . $portfolio->get('id'),
658837bb 203 $portfolio->get('name'),
08d5e18b 204 $url . '?edit=' . $portfolio->get('id'),
205 'moodle/site:config',
206 !$portfolio->get('visible')
207 ),
a50ef3d3 208 $portfolio->get('name'),
209 $url . ' ?edit=' . $portfolio->get('id')
210 );
67a87e7d 211 }
4a65c39a 212
213 // repository setting
214 require_once("$CFG->dirroot/repository/lib.php");
215 $catname =get_string('repositories', 'repository');
04bd6d2d 216 $managerepo = get_string('manage', 'repository');
217 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 218 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
04bd6d2d 219 $temp = new admin_settingpage('managerepositories', $managerepo);
5a8ca187 220 $temp->add(new admin_setting_heading('managerepositories', get_string('activerepository', 'repository'), ''));
4a65c39a 221 $temp->add(new admin_setting_managerepository());
5a8ca187 222 $temp->add(new admin_setting_heading('managerepositoriescommonheading', get_string('commonsettings', 'admin'), ''));
5430f05b 223 $temp->add(new admin_setting_configtext('repositorycacheexpire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
99d52655 224 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', get_string('allowexternallinks', 'repository'), get_string('configallowexternallinks', 'repository'), 1));
4a65c39a 225 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 226 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
0d099914 227 get_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 228 '', $url);
229 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
230 get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
231 '', $url);
232 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
233 get_string('managerepositories', 'repository'), $url, 'moodle/site:config', true),
234 '', $url);
0d099914 235 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
236 get_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
237 '', $url);
238 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
239 get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
240 '', $url);
78946b9b 241 foreach (repository::get_types() as $repositorytype) {
edb50637 242 //display setup page for plugins with: general options or multiple instances (e.g. has instance config)
dbc01944 243 $typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
244 $instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
edb50637 245 if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
4a65c39a 246 $ADMIN->add('repositorysettings',
a6600395 247 new admin_externalpage('repositorysettings'.$repositorytype->get_typename(),
248 $repositorytype->get_readablename(),
249 $url . '?edit=' . $repositorytype->get_typename()),
4a65c39a 250 'moodle/site:config');
251 }
252 }
78946b9b 253}
bee4bce2 254
5ae9f539 255/// Web services
cc93c7da 256 $ADMIN->add('modules', new admin_category('webservicesettings', get_string('webservices', 'webservice')));
3e6161fb 257 /// overview page
258 $temp = new admin_settingpage('webservicesoverview', get_string('webservicesoverview', 'webservice'));
259 $temp->add(new admin_setting_webservicesoverview());
260 $ADMIN->add('webservicesettings', $temp);
261 /// manage service
cc93c7da 262 $temp = new admin_settingpage('externalservices', get_string('externalservices', 'webservice'));
8399c714 263 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', get_string('information', 'webservice'), get_string('servicehelpexplanation', 'webservice')));
cc93c7da 264 $temp->add(new admin_setting_manageexternalservices());
265 $ADMIN->add('webservicesettings', $temp);
72977b37 266 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', get_string('externalservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
267 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', get_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
268 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', get_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
5ae9f539 269 /// manage protocol page link
cc93c7da 270 $temp = new admin_settingpage('webserviceprotocols', get_string('manageprotocols', 'webservice'));
da124b5e 271 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 272 if (empty($CFG->enablewebservices)) {
273 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
274 }
4b4b53a7 275 $url = new moodle_url('/webservice/wsdoc.php');
276 $atag =html_writer::start_tag('a', array('href' => $url)).get_string('documentation', 'webservice').html_writer::end_tag('a');
277 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', get_string('enablewsdocumentation', 'admin'), get_string('configenablewsdocumentation', 'admin', $atag), false));
cc93c7da 278 $ADMIN->add('webservicesettings', $temp);
5ae9f539 279 /// links to protocol pages
cc93c7da 280 $webservices_available = get_plugin_list('webservice');
281 $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
282 foreach ($webservices_available as $webservice => $location) {
283 if (file_exists("$location/settings.php")) {
284 $name = get_string('pluginname', 'webservice_'.$webservice);
285 $settings = new admin_settingpage('webservicesetting'.$webservice, $name, 'moodle/site:config', !in_array($webservice, $active_webservices) or empty($CFG->enablewebservices));
286 if ($ADMIN->fulltree) {
287 include("$location/settings.php");
288 }
289 $ADMIN->add('webservicesettings', $settings);
290 }
291 }
5ae9f539 292 /// manage token page link
15e417fe 293 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', get_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
5ae9f539 294 $temp = new admin_settingpage('webservicetokens', get_string('managetokens', 'webservice'));
295 $temp->add(new admin_setting_managewebservicetokens());
296 if (empty($CFG->enablewebservices)) {
297 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
298 }
299 $ADMIN->add('webservicesettings', $temp);
300
cc93c7da 301
78946b9b 302if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
bee4bce2 303 // Question type settings.
304 $ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin')));
305 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
306 require_once($CFG->libdir . '/questionlib.php');
307 global $QTYPES;
308 foreach ($QTYPES as $qtype) {
309 $settingsfile = $qtype->plugin_dir() . '/settings.php';
310 if (file_exists($settingsfile)) {
311 $settings = new admin_settingpage('qtypesetting' . $qtype->name(),
312 $qtype->local_name(), 'moodle/question:config');
313 if ($ADMIN->fulltree) {
314 include($settingsfile);
315 }
316 $ADMIN->add('qtypesettings', $settings);
317 }
318 }
220a90c5 319}
b63a6a63 320
321
1bcb7eb5 322$ADMIN->add('reports', new admin_externalpage('comments', get_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 323/// Now add reports
324
17da2e6f 325foreach (get_plugin_list('report') as $plugin => $plugindir) {
326 $settings_path = "$plugindir/settings.php";
b63a6a63 327 if (file_exists($settings_path)) {
328 include($settings_path);
329 continue;
330 }
331
17da2e6f 332 $index_path = "$plugindir/index.php";
b63a6a63 333 if (!file_exists($index_path)) {
334 continue;
335 }
336 // old style 3rd party plugin without settings.php
17da2e6f 337 $www_path = "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php";
c5fce2fa 338 $reportname = get_string($plugin, 'report_' . $plugin);
339 $ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, $www_path, 'moodle/site:viewreports'));
b63a6a63 340}
341
17da2e6f 342
343/// Add all local plugins - must be always last!
1ed47309
DM
344if ($hassiteconfig) {
345 $ADMIN->add('modules', new admin_category('localplugins', get_string('localplugins')));
346 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', get_string('localpluginsmanage'),
347 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
348}
17da2e6f 349
350foreach (get_plugin_list('local') as $plugin => $plugindir) {
351 $settings_path = "$plugindir/settings.php";
352 if (file_exists($settings_path)) {
353 include($settings_path);
354 continue;
355 }
1bcb7eb5 356}