#P drupal_test_7 Index: modules/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.40 diff -u -p -r1.40 comment.install --- modules/comment/comment.install 1 Jul 2009 12:06:21 -0000 1.40 +++ modules/comment/comment.install 25 Jul 2009 03:29:16 -0000 @@ -284,3 +284,26 @@ function comment_schema() { return $schema; } + +/** + * Implementation of hook_usage(). +*/ +function comment_usage() { + $aspects = array(); + + // The Comment module is 'in use' if: + // - there are rows in {comment} + // (i.e., comments have actually been submitted, regardless of moderation) + // - or there are rows in {node} for which the comment field is COMMENT_NODE_OPEN + // (i.e., nodes exist upon which comments could be submitted) + + $comments = db_query('SELECT COUNT(*) FROM {comment}')->fetchField(); + $aspects['comments']['description'] = format_plural($comments,'1 comment','@count comments'); + $aspects['comments']['usage'] = $comments ? USAGE_USED : USAGE_UNUSED; + + $comments_allowed_on_nodes = db_query('SELECT COUNT(*) FROM {node} WHERE comment = :open', array(':open' => COMMENT_NODE_OPEN))->fetchField(); + $aspects['comments_allowed_on_nodes']['description'] = format_plural($comments_allowed_on_nodes,'1 commentable node','@count commentable nodes'); + $aspects['comments_allowed_on_nodes']['usage'] = $comments_allowed_on_nodes ? USAGE_USED : USAGE_UNUSED; + + return $aspects; +} Index: modules/system/admin.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/admin.css,v retrieving revision 1.20 diff -u -p -r1.20 admin.css --- modules/system/admin.css 14 Jan 2009 12:18:37 -0000 1.20 +++ modules/system/admin.css 25 Jul 2009 03:29:32 -0000 @@ -51,6 +51,15 @@ div.admin-requirements, div.admin-requir font-size: 0.9em; color: #444; } +div.admin-usage { + font-size: 0.9em; + color: #939; +} +div.admin-usage ul { + padding: 0 0 0 1em; + margin: 0 0 0 1em; + line-height: 95%; +} span.admin-disabled { color: #800; } Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.163 diff -u -p -r1.163 system.admin.inc --- modules/system/system.admin.inc 20 Jul 2009 18:51:34 -0000 1.163 +++ modules/system/system.admin.inc 25 Jul 2009 03:29:32 -0000 @@ -593,6 +593,9 @@ function system_modules($form_state = ar // Iterate through each of the modules. foreach ($files as $filename => $module) { $extra = array(); + if ($usage = module_invoke($filename, 'usage')) { + $extra['usage_aspects'] = $usage; + } $extra['enabled'] = (bool) $module->status; // If this module requires other modules, add them to the array. foreach ($module->requires as $requires => $v) { @@ -670,6 +673,7 @@ function system_sort_modules_by_info_nam function _system_modules_build_row($info, $extra) { // Add in the defaults. $extra += array( + 'usage_aspects' => array(), 'requires' => array(), 'required_by' => array(), 'disabled' => FALSE, @@ -739,6 +743,25 @@ function _system_modules_build_row($info '#markup' => $extra['help'], ); } + + // Summarize module usage information. + if (count($extra['usage_aspects'])) { + $usage_verdict = USAGE_UNUSED; + foreach($extra['usage_aspects'] as $aspect) { + if ($aspect['usage'] === USAGE_USED) { + $usage_verdict = USAGE_USED; + } + } + $form['usage'] = array( + '#usage_aspects' => $extra['usage_aspects'], + '#usage_verdict' => $usage_verdict, + ); + } + else { + // If there's no usage information, play it safe. + $form['usage'] = array('#usage_verdict' => USAGE_USED); + } + return $form; } @@ -2045,7 +2068,10 @@ function theme_system_modules_fieldset($ if (isset($module['enable']['#id'])) { $label .= ' for="' . $module['enable']['#id'] . '"'; } - $row[] = $label . '>' . drupal_render($module['name']) . ''; + if ($module['enable']['#default_value'] && $module['usage']['#usage_verdict'] === USAGE_USED) { + $label .= ' style="font-weight: bold"'; + } + $row[] = $label . '>' . drupal_render($module['name']) . ''; $row[] = drupal_render($module['version']); $description = ''; // If we have help, it becomes the first part @@ -2061,6 +2087,23 @@ function theme_system_modules_fieldset($ if ($module['#required_by']) { $description .= '