Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.476 diff -u -F^f -r1.476 common.inc --- includes/common.inc 31 Aug 2005 18:37:30 -0000 1.476 +++ includes/common.inc 8 Sep 2005 22:46:46 -0000 @@ -854,25 +854,30 @@ function format_rss_item($title, $link, * The string for the plural case. Please make sure it is clear this is plural, * to ease translation. Use %count in place of the item count, as in "%count * new comments". + * @param $args + * An associative array of replacements to make after translation. Incidences + * of any key in this array are replaced with the corresponding value. * @return * A translated string. */ -function format_plural($count, $singular, $plural) { - if ($count == 1) return t($singular, array("%count" => $count)); +function format_plural($count, $singular, $plural, $args = array()) { + $args['%count'] = $count; + if ($count == 1) return t($singular, $args); // get the plural index through the gettext formula $index = (function_exists('locale_get_plural')) ? locale_get_plural($count) : -1; if ($index < 0) { // backward compatibility - return t($plural, array("%count" => $count)); + return t($plural, $args); } else { switch ($index) { case "0": - return t($singular, array("%count" => $count)); + return t($singular, $args); case "1": - return t($plural, array("%count" => $count)); + return t($plural, $args); default: - return t(strtr($plural, array("%count" => '%count['. $index .']')), array('%count['. $index .']' => $count)); + $args['%count['. $index .']'] = $count; + return t(strtr($plural, array("%count" => '%count['. $index .']')), $args); } } } Index: modules/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum.module,v retrieving revision 1.269 diff -u -F^f -r1.269 forum.module --- modules/forum.module 8 Sep 2005 19:22:28 -0000 1.269 +++ modules/forum.module 8 Sep 2005 22:46:46 -0000 @@ -34,6 +34,14 @@ function forum_node_info() { } /** + * Implementation of hook_info(). + */ +function forum_info($key) { + $info['depends'] = array('comment', 'node', 'taxonomy'); + return $info[$key]; +} + +/** * Implementation of hook_access(). */ function forum_access($op, $node) { Index: modules/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system.module,v retrieving revision 1.233 diff -u -F^f -r1.233 system.module --- modules/system.module 8 Sep 2005 20:25:08 -0000 1.233 +++ modules/system.module 8 Sep 2005 22:46:47 -0000 @@ -551,11 +551,51 @@ function system_module_listing() { return $output; } +/** + * Resolve dependencies between modules. + */ +function system_module_dependencies(&$edit) { + do { + $new_module = FALSE; + foreach ($edit['status'] as $module => $status) { + if ($status) { + drupal_load('module', $module); + $enabled = array(); + $requirements = module_invoke($module, 'info', 'depends'); + if (is_array($requirements)) { + foreach ($requirements as $required) { + if (isset($edit['status'][$required])) { + if (!$edit['status'][$required]) { + $edit['status'][$required] = 1; + $enabled[] = $required; + } + } + else { + drupal_set_message(t('%module needs %required to work but %required is not installed.', array('%module' => theme('placeholder', $module), '%required' => $required)), 'error'); + return; + } + } + } + if (!empty($enabled)) { + $new_module = TRUE; + drupal_set_message(format_plural(count($enabled), + '%enabled module has been enabled for you because %module needs it to work properly. Please read the documentation of %enabled module about its proper installation (for eg. database tables, permissions and settings).', + '%enabled modules has been enabled for you because %module needs them to work properly. Please read the appropriate documentation of %enabled modules for proper installation (for eg. database tables, permissions and settings).', + array ('%module' => theme('placeholder', $module), '%enabled' => theme ('placeholder', implode(', ', $enabled))))); + } + } + } + } while ($new_module); +} + function system_listing_save($edit = array()) { $op = $_POST['op']; $edit = $_POST['edit']; if ($op == t('Save configuration')) { + if ($edit['type'] == 'module') { + system_module_dependencies($edit); + } db_query("UPDATE {system} SET status = 0 WHERE type = '%s'", $edit['type']); foreach ($edit['status'] as $name => $status) { // Make certain that the default theme is enabled to avoid user error