| Project: | Administration |
| Version: | 4.6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I'm trying to centralize all module settings with administration module.
Right now, stuff is kind of all over the place:
Some modules configure settings under administer >> module name (ex: forums, localization, etc.)
Some modules configure settings under administer >> settings >> module name (ex: throttle, administration)
And others have stuff in both (aggregator, image, eventfinder)
So I'm trying to do the following:
1. Setup a menu item to sadmin/modules called "Configure module settings"
2. Make that link to a "jump-off" page, which displays an alphabetical list of all modules, with links to their settings pages (I think this is just a matter of adding a callback to the menu item)
3. Generates paths to each module's settings pages.. or, in the case of modules with more than one settings page,
4. Ideally, does not duplicate menu items which are already specified in other places in the .inc file (for example, admin/help, admin/node, admin/content)
5. I do _not_ want to hijack/break the default admin/settings path, which should take you to general site settings. Nor do I want all of the module links which would normally appear under the "settings" tree to appear under there, but rather under the "configure modules" link.
6. I'm not sure what to do about those "double-settings" modules; make a "configure" and a "settings" link separately?
Here's a very bare-bones mockup of how it might work 'in theory': http://testbed.webchick.net/module-mockup.bmp
Any pointers on where to start? I'm thinking that getting a list of settings paths shouldn't be too hard (I can loop through the menu array and pull these out), but am kind of stuck on some of the rest. :\
Comments
#1
Here's how far I've got so far:
1. In the sadmin/features section, added the item:
'sadmin/modules' => array('title' => 'configure modules',
'description' => "Configure my site's application (module) settings",
'callback' => '_administration_sub_dashboard_page',
'class' => 'dashboard-admin',
),
2. At the very bottom of the _administration_menu_config() function, right before returning $config, I've placed the following:
$config = move_modules($config);3. I've declared a move_modules function, as follows:
<?php
function move_modules($config) {
// Get a list of paths already covered by the $config array
$config_paths = array();
foreach ($config['section'] as $section_path => $section) {
if (is_array($section['items'])) {
foreach ($section['items'] as $path => $info) {
$config_paths[] = $path;
}
}
}
// Get the current menu
$menu = menu_get_menu();
// Array to store new paths for
$new_paths = array();
// Loop through each menu item, checking for admin/<module> or
// admin/settings/<module>
foreach ($menu['items'] as $item) {
$path = $item['path'];
// Check for a path like 'admin/something'
if (substr($path, 0, 6) == 'admin/' && $path != 'admin/settings') {
// Does this path already exist in $config? If so, skip
if (in_array($path, $config_paths)) {
continue;
}
// What is the final part of the path?
$target = substr($path, strrpos($path, '/') + 1);
// This bunch of stuff checks for whether:
// 1. The path starts with 'admin/settings/' and there are exactly 2 '/'s in the path
// 2. Or, there is only one '/' in the path
if ((substr($path, 0, 15) == 'admin/settings/' && substr_count($path, '/') == 2)
|| (substr_count($path, '/') == 1)) {
$new_paths["sadmin/modules/$target"] = array(
'title' => $item['title'],
);
}
}
}
ksort($new_paths);
$config['section']['sadmin/features']['items'] = array_merge($new_paths, $config['section']['sadmin/features']['items']);
return $config;
}
?>
This 'works', in that it's adding the paths to all the module settings pages to the right place. But doesn't work because no sub-menus show up when I click on the 'configure modules' item. :(
Any ideas?
#2
Here is a patch against the modules/zadministration/civcspace.inc file which adds in what i have figured out so far.
Problems:
1. sadmin/modules needs a "real" callback; I just put the current one there as a placeholder so that it would show up in the menu.
2. None of the menu items actually show up as child items under "configure modules" ;( I thought _administration_reparent_menu_item would do this for me, but it doesn't look like it is.
#3