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