MDL-20949 printing out password policy requirements on signup, change password and...
[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) {
01ca2df0 48 if(($blockobject = block_instance($block->name)) === false) {
49 // Failed to load
50 continue;
220a90c5 51 }
01ca2df0 52 $blockbyname[$blockobject->get_title()] = $block;
220a90c5 53 }
54 ksort($blockbyname);
55
56 foreach ($blockbyname as $strblockname=>$block) {
57 $blockname = $block->name;
58 if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
59 $settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
60 if ($ADMIN->fulltree) {
61 include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
62 }
63 $ADMIN->add('blocksettings', $settings);
64
65 } else if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/config_global.html')) {
66 $ADMIN->add('blocksettings', new admin_externalpage('blocksetting'.$blockname, $strblockname, "$CFG->wwwroot/$CFG->admin/block.php?block=$block->id", 'moodle/site:config', !$block->visible));
67 }
68 }
69 }
70
c5d2d0dd 71
a5747cf8 72/// Editor plugins
73 $ADMIN->add('modules', new admin_category('editorsettings', get_string('editors', 'editor')));
74 $temp = new admin_settingpage('manageeditors', get_string('editorsettings', 'editor'));
75 $temp->add(new admin_setting_manageeditors());
76 $ADMIN->add('editorsettings', $temp);
77
78
79/// Filter plugins
220a90c5 80 $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters')));
dcdf3b29 81
82 $ADMIN->add('filtersettings', new admin_page_managefilters());
83
220a90c5 84 // "filtersettings" settingpage
dcdf3b29 85 $temp = new admin_settingpage('commonfiltersettings', get_string('commonfiltersettings', 'admin'));
220a90c5 86 if ($ADMIN->fulltree) {
5b8fa09b 87 $cachetimes = array(
88 604800 => get_string('numdays','',7),
89 86400 => get_string('numdays','',1),
90 43200 => get_string('numhours','',12),
91 10800 => get_string('numhours','',3),
92 7200 => get_string('numhours','',2),
93 3600 => get_string('numhours','',1),
94 2700 => get_string('numminutes','',45),
95 1800 => get_string('numminutes','',30),
96 900 => get_string('numminutes','',15),
97 600 => get_string('numminutes','',10),
98 540 => get_string('numminutes','',9),
99 480 => get_string('numminutes','',8),
100 420 => get_string('numminutes','',7),
101 360 => get_string('numminutes','',6),
102 300 => get_string('numminutes','',5),
103 240 => get_string('numminutes','',4),
104 180 => get_string('numminutes','',3),
105 120 => get_string('numminutes','',2),
106 60 => get_string('numminutes','',1),
107 30 => get_string('numseconds','',30),
108 0 => get_string('no')
109 );
109e3cb2 110 $items = array();
5b8fa09b 111 $items[] = new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, $cachetimes);
112 $items[] = new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0,
113 array('0' => get_string('none'), '1' => get_string('allfiles'), '2' => get_string('htmlfilesonly')));
109e3cb2 114 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
115 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 116 foreach ($items as $item) {
117 $item->set_updatedcallback('reset_text_filters_cache');
118 $temp->add($item);
119 }
220a90c5 120 }
121 $ADMIN->add('filtersettings', $temp);
122
5b8fa09b 123 $activefilters = filter_get_globally_enabled();
b810a4d3 124 $filternames = filter_get_all_installed();
125 foreach ($filternames as $filterpath => $strfiltername) {
126 if (file_exists("$CFG->dirroot/$filterpath/filtersettings.php")) {
127 $settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterpath),
5b8fa09b 128 $strfiltername, 'moodle/site:config', !isset($activefilters[$filterpath]));
b810a4d3 129 if ($ADMIN->fulltree) {
130 include("$CFG->dirroot/$filterpath/filtersettings.php");
220a90c5 131 }
b810a4d3 132 $ADMIN->add('filtersettings', $settings);
220a90c5 133 }
134 }
67a87e7d 135
78946b9b
PS
136
137 //== Portfolio settings ==
138 require_once($CFG->libdir. '/portfoliolib.php');
b810a4d3 139 $catname = get_string('portfolios', 'portfolio');
67a87e7d 140 $manage = get_string('manageportfolios', 'portfolio');
141 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
142
90658eef 143 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 144
a50ef3d3 145 // jump through hoops to do what we want
146 $temp = new admin_settingpage('manageportfolios', get_string('manageportfolios', 'portfolio'));
bee4bce2 147 $temp->add(new admin_setting_heading('manageportfolios', get_string('activeportfolios', 'portfolio'), ''));
a50ef3d3 148 $temp->add(new admin_setting_manageportfolio());
bee4bce2 149 $temp->add(new admin_setting_heading('manageportfolioscommon', get_string('commonsettings', 'admin'), get_string('commonsettingsdesc', 'portfolio')));
150 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
151 $fileoptions = $fileinfo['options'];
152 $temp->add(new admin_setting_configselect(
153 'portfolio_moderate_filesize_threshold',
154 get_string('moderatefilesizethreshold', 'portfolio'),
155 get_string('moderatefilesizethresholddesc', 'portfolio'),
156 $fileinfo['moderate'], $fileoptions));
157 $temp->add(new admin_setting_configselect(
158 'portfolio_high_filesize_threshold',
159 get_string('highfilesizethreshold', 'portfolio'),
160 get_string('highfilesizethresholddesc', 'portfolio'),
161 $fileinfo['high'], $fileoptions));
162
163 $temp->add(new admin_setting_configtext(
164 'portfolio_moderate_db_threshold',
165 get_string('moderatedbsizethreshold', 'portfolio'),
166 get_string('moderatedbsizethresholddesc', 'portfolio'),
167 20, PARAM_INTEGER, 3));
168
169 $temp->add(new admin_setting_configtext(
170 'portfolio_high_db_threshold',
171 get_string('highdbsizethreshold', 'portfolio'),
172 get_string('highdbsizethresholddesc', 'portfolio'),
173 50, PARAM_INTEGER, 3));
a50ef3d3 174
175 $ADMIN->add('portfoliosettings', $temp);
176 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', get_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
177 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', get_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
178 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', get_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
179
08d5e18b 180 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 181 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 182 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 183 $ADMIN->add(
184 'portfoliosettings',
08d5e18b 185 new admin_externalpage(
186 'portfoliosettings' . $portfolio->get('id'),
658837bb 187 $portfolio->get('name'),
08d5e18b 188 $url . '?edit=' . $portfolio->get('id'),
189 'moodle/site:config',
190 !$portfolio->get('visible')
191 ),
a50ef3d3 192 $portfolio->get('name'),
193 $url . ' ?edit=' . $portfolio->get('id')
194 );
67a87e7d 195 }
4a65c39a 196
197 // repository setting
198 require_once("$CFG->dirroot/repository/lib.php");
199 $catname =get_string('repositories', 'repository');
04bd6d2d 200 $managerepo = get_string('manage', 'repository');
201 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 202 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
04bd6d2d 203 $temp = new admin_settingpage('managerepositories', $managerepo);
5a8ca187 204 $temp->add(new admin_setting_heading('managerepositories', get_string('activerepository', 'repository'), ''));
4a65c39a 205 $temp->add(new admin_setting_managerepository());
5a8ca187 206 $temp->add(new admin_setting_heading('managerepositoriescommonheading', get_string('commonsettings', 'admin'), ''));
5430f05b 207 $temp->add(new admin_setting_configtext('repositorycacheexpire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
99d52655 208 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', get_string('allowexternallinks', 'repository'), get_string('configallowexternallinks', 'repository'), 1));
4a65c39a 209 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 210 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
0d099914 211 get_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 212 '', $url);
213 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
214 get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
215 '', $url);
216 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
217 get_string('managerepositories', 'repository'), $url, 'moodle/site:config', true),
218 '', $url);
0d099914 219 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
220 get_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
221 '', $url);
222 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
223 get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
224 '', $url);
78946b9b 225 foreach (repository::get_types() as $repositorytype) {
edb50637 226 //display setup page for plugins with: general options or multiple instances (e.g. has instance config)
dbc01944 227 $typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
228 $instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
edb50637 229 if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
4a65c39a 230 $ADMIN->add('repositorysettings',
a6600395 231 new admin_externalpage('repositorysettings'.$repositorytype->get_typename(),
232 $repositorytype->get_readablename(),
233 $url . '?edit=' . $repositorytype->get_typename()),
4a65c39a 234 'moodle/site:config');
235 }
236 }
78946b9b 237}
bee4bce2 238
cc93c7da 239 // Web services
240 $ADMIN->add('modules', new admin_category('webservicesettings', get_string('webservices', 'webservice')));
241 $temp = new admin_settingpage('externalservices', get_string('externalservices', 'webservice'));
242 $temp->add(new admin_setting_manageexternalservices());
243 $ADMIN->add('webservicesettings', $temp);
72977b37 244 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', get_string('externalservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
245 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', get_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
246 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', get_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
cc93c7da 247 $temp = new admin_settingpage('webserviceprotocols', get_string('manageprotocols', 'webservice'));
da124b5e 248 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 249 if (empty($CFG->enablewebservices)) {
250 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
251 }
7886efc4 252 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', get_string('enablewsdocumentation', 'admin'), get_string('configenablewsdocumentation', 'admin'), false));
cc93c7da 253 $ADMIN->add('webservicesettings', $temp);
254 $webservices_available = get_plugin_list('webservice');
255 $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
256 foreach ($webservices_available as $webservice => $location) {
257 if (file_exists("$location/settings.php")) {
258 $name = get_string('pluginname', 'webservice_'.$webservice);
259 $settings = new admin_settingpage('webservicesetting'.$webservice, $name, 'moodle/site:config', !in_array($webservice, $active_webservices) or empty($CFG->enablewebservices));
260 if ($ADMIN->fulltree) {
261 include("$location/settings.php");
262 }
263 $ADMIN->add('webservicesettings', $settings);
264 }
265 }
266
78946b9b 267if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
bee4bce2 268 // Question type settings.
269 $ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin')));
270 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
271 require_once($CFG->libdir . '/questionlib.php');
272 global $QTYPES;
273 foreach ($QTYPES as $qtype) {
274 $settingsfile = $qtype->plugin_dir() . '/settings.php';
275 if (file_exists($settingsfile)) {
276 $settings = new admin_settingpage('qtypesetting' . $qtype->name(),
277 $qtype->local_name(), 'moodle/question:config');
278 if ($ADMIN->fulltree) {
279 include($settingsfile);
280 }
281 $ADMIN->add('qtypesettings', $settings);
282 }
283 }
220a90c5 284}
b63a6a63 285
286
1bcb7eb5 287$ADMIN->add('reports', new admin_externalpage('comments', get_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 288/// Now add reports
289
17da2e6f 290foreach (get_plugin_list('report') as $plugin => $plugindir) {
291 $settings_path = "$plugindir/settings.php";
b63a6a63 292 if (file_exists($settings_path)) {
293 include($settings_path);
294 continue;
295 }
296
17da2e6f 297 $index_path = "$plugindir/index.php";
b63a6a63 298 if (!file_exists($index_path)) {
299 continue;
300 }
301 // old style 3rd party plugin without settings.php
17da2e6f 302 $www_path = "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php";
c5fce2fa 303 $reportname = get_string($plugin, 'report_' . $plugin);
304 $ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, $www_path, 'moodle/site:viewreports'));
b63a6a63 305}
306
17da2e6f 307
308/// Add all local plugins - must be always last!
309
310foreach (get_plugin_list('local') as $plugin => $plugindir) {
311 $settings_path = "$plugindir/settings.php";
312 if (file_exists($settings_path)) {
313 include($settings_path);
314 continue;
315 }
1bcb7eb5 316}