MDL-16348 Reorganise admin tree:
[moodle.git] / admin / settings / plugins.php
1 <?php  //$Id$
3 if ($hassiteconfig) {
5     $ADMIN->add('modules', new admin_category('modsettings', get_string('activitymodules')));
6     $ADMIN->add('modsettings', new admin_page_managemods());
7     if ($modules = $DB->get_records('modules')) {
8         $modulebyname = array();
10         foreach ($modules as $module) {
11             $strmodulename = get_string('modulename', $module->name);
12             // Deal with modules which are lacking the language string
13             if ($strmodulename == '[[modulename]]') {
14                 $textlib = textlib_get_instance();
15                 $strmodulename = $textlib->strtotitle($module->name);
16             }
17             $modulebyname[$strmodulename] = $module;
18         }
19         ksort($modulebyname);
21         foreach ($modulebyname as $strmodulename=>$module) {
22             $modulename = $module->name;
23             if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php')) {
24                 include($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php');
25             } else if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) {
26                 // do not show disabled modules in tree, keep only settings link on manage page
27                 $settings = new admin_settingpage('modsetting'.$modulename, $strmodulename, 'moodle/site:config', !$module->visible);
28                 if ($ADMIN->fulltree) {
29                     include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
30                 }
31                 $ADMIN->add('modsettings', $settings);
32             }
33         }
34     }
36     // hidden script for converting journals to online assignments (or something like that) linked from elsewhere
37     $ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
39     $ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks')));
40     $ADMIN->add('blocksettings', new admin_page_manageblocks());
41     $ADMIN->add('blocksettings', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php"));
42     if (!empty($CFG->blocks_version) and $blocks = $DB->get_records('block')) {
43         $blockbyname = array();
45         foreach ($blocks as $block) {
46             if(($blockobject = block_instance($block->name)) === false) {
47                 // Failed to load
48                 continue;
49             }
50             $blockbyname[$blockobject->get_title()] = $block;
51         }
52         ksort($blockbyname);
54         foreach ($blockbyname as $strblockname=>$block) {
55             $blockname = $block->name;
56             if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
57                 $settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
58                 if ($ADMIN->fulltree) {
59                     include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
60                 }
61                 $ADMIN->add('blocksettings', $settings);
63             } else if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/config_global.html')) {
64                 $ADMIN->add('blocksettings', new admin_externalpage('blocksetting'.$blockname, $strblockname, "$CFG->wwwroot/$CFG->admin/block.php?block=$block->id", 'moodle/site:config', !$block->visible));
65             }
66         }
67     }
70     $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters')));
71     // "filtersettings" settingpage
72     $temp = new admin_settingpage('managefilters', get_string('filtersettings', 'admin'));
73     if ($ADMIN->fulltree) {
74         $items = array();
75         $items[] = new admin_setting_managefilters();
76         $items[] = new admin_setting_heading('managefilterscommonheading', get_string('commonsettings', 'admin'), '');
77         $items[] = new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, array(604800 => get_string('numdays','',7),
78                                                                                                                                                86400 => get_string('numdays','',1),
79                                                                                                                                                43200 => get_string('numhours','',12),
80                                                                                                                                                10800 => get_string('numhours','',3),
81                                                                                                                                                7200 => get_string('numhours','',2),
82                                                                                                                                                3600 => get_string('numhours','',1),
83                                                                                                                                                2700 => get_string('numminutes','',45),
84                                                                                                                                                1800 => get_string('numminutes','',30),
85                                                                                                                                                900 => get_string('numminutes','',15),
86                                                                                                                                                600 => get_string('numminutes','',10),
87                                                                                                                                                540 => get_string('numminutes','',9),
88                                                                                                                                                480 => get_string('numminutes','',8),
89                                                                                                                                                420 => get_string('numminutes','',7),
90                                                                                                                                                360 => get_string('numminutes','',6),
91                                                                                                                                                300 => get_string('numminutes','',5),
92                                                                                                                                                240 => get_string('numminutes','',4),
93                                                                                                                                                180 => get_string('numminutes','',3),
94                                                                                                                                                120 => get_string('numminutes','',2),
95                                                                                                                                                60 => get_string('numminutes','',1),
96                                                                                                                                                30 => get_string('numseconds','',30),
97                                                                                                                                                0 => get_string('no')));
98         $items[] = new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0, array('0' => get_string('none'),
99                                                                                                                                                                                 '1' => get_string('allfiles'),
100                                                                                                                                                                                 '2' => get_string('htmlfilesonly')));
101         $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
102         $items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0);
103         $items[] = new admin_setting_configcheckbox('filterall', get_string('filterall', 'admin'), get_string('configfilterall', 'admin'), 0);
104         foreach ($items as $item) {
105             $item->set_updatedcallback('reset_text_filters_cache');
106             $temp->add($item);
107         }
108     }
109     $ADMIN->add('filtersettings', $temp);
111     if (empty($CFG->textfilters)) {
112         $activefilters = array();
113     } else {
114         $activefilters = explode(',', $CFG->textfilters);
115     }
116     $filterlocations = array('mod','filter');
117     foreach ($filterlocations as $filterlocation) {
118         $filters = get_list_of_plugins($filterlocation);
120         $filterbyname = array();
122         foreach ($filters as $filter) {
123             $strfiltername = get_string('filtername', $filter);
124             // Deal with filters which are lacking the language string
125             if ($strfiltername == '[[filtername]]') {
126                 $textlib = textlib_get_instance();
127                 $strfiltername = $textlib->strtotitle($filter);
128             }
129             $filterbyname[$strfiltername] = "$filterlocation/$filter";
130         }
131         ksort($filterbyname);
133         foreach ($filterbyname as $strfiltername=>$filterfull) {
134             if (file_exists("$CFG->dirroot/$filterfull/filtersettings.php")) {
135                 $settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterfull), $strfiltername, 'moodle/site:config', !in_array($filterfull, $activefilters));
136                 if ($ADMIN->fulltree) {
137                     include("$CFG->dirroot/$filterfull/filtersettings.php");
138                 }
139                 $ADMIN->add('filtersettings', $settings);
141             } else if (file_exists("$CFG->dirroot/$filterfull/filterconfig.html")) {
142                 $ADMIN->add('filtersettings', new admin_externalpage('filtersetting'.str_replace('/', '', $filterfull), $strfiltername, "$CFG->wwwroot/$CFG->admin/filter.php?filter=$filterfull", !in_array($filterfull, $activefilters)));
143             }
144         }
145     }
147     require_once($CFG->libdir. '/portfoliolib.php');
149     $catname =get_string('portfolios', 'portfolio');
150     $manage = get_string('manageportfolios', 'portfolio');
151     $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
153     $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
155     // jump through hoops to do what we want
156     $temp = new admin_settingpage('manageportfolios', get_string('manageportfolios', 'portfolio'));
157     $temp->add(new admin_setting_manageportfolio());
159     $ADMIN->add('portfoliosettings', $temp);
160     $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', get_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
161     $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', get_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
162     $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', get_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
164     foreach (portfolio_instances(false, false) as $portfolio) {
165         require_once($CFG->dirroot . '/portfolio/type/' . $portfolio->get('plugin') . '/lib.php');
166         $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
167         $ADMIN->add(
168             'portfoliosettings',
169             new admin_externalpage(
170                 'portfoliosettings' . $portfolio->get('id'),
171                 get_string('configure', 'portfolio') . ' ' . $portfolio->get('name'),
172                 $url . '?edit=' . $portfolio->get('id'),
173                 'moodle/site:config',
174                 !$portfolio->get('visible')
175             ),
176             $portfolio->get('name'),
177             $url . ' ?edit=' . $portfolio->get('id')
178         );
179     }
181     // repository setting
182     require_once("$CFG->dirroot/repository/lib.php");
183     $catname =get_string('repositories', 'repository');
184     $managerepo = get_string('manage', 'repository');
185     $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
186     $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
187     $temp = new admin_settingpage('managerepositories', $managerepo);
188     $temp->add(new admin_setting_heading('managerepositories', get_string('activerepository', 'repository'), ''));
189     $temp->add(new admin_setting_managerepository());
190     $temp->add(new admin_setting_heading('managerepositoriescommonheading', get_string('commonsettings', 'admin'), ''));
191     $temp->add(new admin_setting_configtext('repository_cache_expire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
192     $ADMIN->add('repositorysettings', $temp);
193     $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
194         get_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
195         '', $url);
196     $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
197         get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
198         '', $url);
199     $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
200         get_string('managerepositories', 'repository'), $url, 'moodle/site:config', true),
201         '', $url);
202     $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
203         get_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
204         '', $url);
205     $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
206         get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
207         '', $url);
208     foreach (repository_get_types()
209         as $repositorytype)
210     {
211       //display setup page for plugins with: general options or instance options or multiple instances
212       if (repository_static_function($repositorytype->get_typename(), 'has_admin_config')
213           || repository_static_function($repositorytype->get_typename(), 'has_instance_config')
214           || repository_static_function($repositorytype->get_typename(), 'has_multiple_instances')) {
215             $ADMIN->add('repositorysettings',
216                 new admin_externalpage('repositorysettings'.$repositorytype->get_typename(),
217                         $repositorytype->get_readablename(),
218                         $url . '?edit=' . $repositorytype->get_typename()),
219                         'moodle/site:config');
220         }
221     }