'. l(t('Set collapsed state'), 'admin/settings/util/sysmods') .'
'; case 'admin/settings/util/sysmods': return l(t('Go to modules admin page'), 'admin/build/modules'); } } function system_module_menu() { $menu['admin/settings/util/sysmods'] = array( 'title' => 'Modules Settings', 'description' => 'Customize System Modules fieldsets.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_module_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, ); return $menu; } function system_module_settings() { global $user; drupal_add_css(drupal_get_path('module', 'system_module') .'/system_module.css'); // Get all available packages. $modules = module_rebuild_cache(); $packages = $includes = array(); foreach ($modules as $module) { if (!isset($module->info['package']) || !$module->info['package']) { $module->info['package'] = t('Other'); } $pkg = $module->info['package']; $packages[$pkg] = $pkg; $includes[$pkg][] = $module->info['name']; } ksort($packages); ksort($includes); // Build settings form $result = db_fetch_array(db_query("SELECT data FROM {system_module_users} WHERE uid = %d}", $user->uid)); $result = unserialize($result['data']); $form['system_module_collapse_all'] = array( '#type' => 'radios', '#title' => t('Collapse all by default'), '#description' => t('If you collapse all by default, new packages will be collapsed automatically unless you select them below.'), '#default_value' => variable_get('system_module_collapse_all', 0), '#options' => array(t('Expand all by default'), t('Collapse all by default')), ); $form['list'] = array( '#type' => 'fieldset', '#title' => t('Available module packages'), '#description' => t('Check the box to reverse the default collapsed state above.'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['list']['system_module_cfg'] = array( '#type' => 'checkboxes', '#default_value' => (isset($result) && is_array($result) ? array_keys($result) : array()), '#options' => $packages, ); $form['dir'] = array( '#type' => 'fieldset', '#title' => t('Directory of package contents'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $rows = array(); $header = array(t('Package'), t('Includes')); foreach ($includes as $pkg => $modules) { $pkg_id = _system_modules_make_pkgid($pkg); $rows[] = array( l($pkg, 'admin/build/modules', array('fragment' => "package_$pkg_id", 'query' => 'expand="'. $pkg .'"')), implode(', ', $modules), ); } $form['dir']['list'] = array( '#type' => 'markup', '#value' => theme('table', $header, $rows), ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Save configuration', ); return $form; } function system_module_settings_submit($form, &$form_state) { global $user; variable_set('system_module_collapse_all', $form_state['values']['system_module_collapse_all']); foreach ($form_state['values']['system_module_cfg'] as $index => $value) { if ($value === 0) { unset($form_state['values']['system_module_cfg'][$index]); } } // Must replace this with drupal_write_record at a later date (once i figure out how to use it correctly!) db_query("REPLACE INTO {system_module_users} SET uid = %d, data = '%s'", $user->uid, serialize($form_state['values']['system_module_cfg'])); // Save user settings user_save($user, array('system_module_cfg' => $form_state['values']['system_module_cfg'])); drupal_set_message(t('Configuration saved')); } // The theme registry function system_module_theme() { return array( 'system_modules_theme' => array( 'arguments' => array('form' => NULL), ), ); } function system_module_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { case 'system_modules': // A neat idea to allow access to the important module settings directly from the modules page, // saves page loads from navigting to site configuration etc. $form['#theme'] = 'system_modules_theme'; $form['description']['system_module']['#value'] = l($form['description']['system_module']['#value'], 'admin/settings/util/sysmods'); break; } } // @TODO: Doesn't the system already do this? function system_module_disable() { drupal_rebuild_theme_registry(); } // Most of this function was copied from system.module. function theme_system_modules_theme($form) { global $user; //needed to enable if (isset($form['confirm'])) { return drupal_render($form); } // Individual table headers. $header = array(t('Enabled')); if (module_exists('throttle')) { $header[] = t('Throttle'); } $header[] = t('Name'); $header[] = t('Version'); $header[] = t('Description'); // Pull package information from module list and start grouping modules. $mods = $form['validation_modules']['#value']; $packages = array(); foreach ($mods as $module) { if (!isset($module->info['package']) || !$module->info['package']) { $module->info['package'] = t('Other'); } $packages[$module->info['package']][$module->name] = $module->info; $project[$module->info['name']] = $module->info['project']; } ksort($packages); // Display packages. $output = ''; $collapse_all = variable_get('system_module_collapse_all', 0); $throttle_available = module_exists('throttle'); $status_error_php = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP')); $status_error_core = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core')); $incompat_core = '