? update_advanced.install Index: update_advanced.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/update_advanced/update_advanced.module,v retrieving revision 1.3 diff -u -p -r1.3 update_advanced.module --- update_advanced.module 14 Aug 2008 18:23:00 -0000 1.3 +++ update_advanced.module 1 Jul 2009 22:39:36 -0000 @@ -26,6 +26,83 @@ function update_advanced_theme() { } /** + * Implementation of hook_form_FORM_ID_alter(). + */ +function update_advanced_form_update_settings_alter(&$form, $form_state) { + $path = drupal_get_path('module', 'update_advanced'); + module_load_include('inc', 'update_advanced', 'update_advanced.settings'); + _update_advanced_alter_settings($form, $form_state); +} + +/** + * Duplicate function of _update_process_info_list for disabled projects. + */ +function _update_advanced_process_disabled_info_list(&$projects, $list, $project_type) { + foreach ($list as $file) { + if (!empty($file->status)) { + // Skip enabled modules or themes. + continue; + } + + // Skip if the .info file is broken. + if (empty($file->info)) { + continue; + } + + // If the .info doesn't define the 'project', try to figure it out. + if (!isset($file->info['project'])) { + $file->info['project'] = update_get_project_name($file); + } + + // If we still don't know the 'project', give up. + if (empty($file->info['project'])) { + continue; + } + + // If we don't already know it, grab the change time on the .info file + // itself. Note: we need to use the ctime, not the mtime (modification + // time) since many (all?) tar implementations will go out of their way to + // set the mtime on the files it creates to the timestamps recorded in the + // tarball. We want to see the last time the file was changed on disk, + // which is left alone by tar and correctly set to the time the .info file + // was unpacked. + if (!isset($file->info['_info_file_ctime'])) { + $info_filename = dirname($file->filename) .'/'. $file->name .'.info'; + $file->info['_info_file_ctime'] = filectime($info_filename); + } + + $project_name = $file->info['project']; + if (!isset($projects[$project_name])) { + // Only process this if we haven't done this project, since a single + // project can have multiple modules or themes. + $projects[$project_name] = array( + 'name' => $project_name, + 'info' => $file->info, + 'datestamp' => isset($file->info['datestamp']) ? $file->info['datestamp'] : 0, + 'includes' => array($file->name => $file->info['name']), + // Core can't be disabled, there's no reason to special-case it here. + 'project_type' => $project_type, + ); + } + // Only record include data for disabled projects. + elseif ($projects[$project_name]['project_type'] == $project_type) { + $projects[$project_name]['includes'][$file->name] = $file->info['name']; + $projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']); + } + } +} + +/** + * Implementation of hook_update_projects_alter(). + */ +function update_advanced_update_projects_alter(&$projects) { + if (variable_get('update_advanced_check_disabled', FALSE)) { + _update_advanced_process_disabled_info_list($projects, module_rebuild_cache(), 'disabled-module'); + _update_advanced_process_disabled_info_list($projects, system_theme_data(), 'disabled-theme'); + } +} + +/** * Implementation of hook_form_alter(). */ function update_advanced_form_alter(&$form, $form_state, $form_id) { Index: update_advanced.settings.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/update_advanced/update_advanced.settings.inc,v retrieving revision 1.2 diff -u -p -r1.2 update_advanced.settings.inc --- update_advanced.settings.inc 13 Jun 2009 04:29:25 -0000 1.2 +++ update_advanced.settings.inc 1 Jul 2009 22:39:36 -0000 @@ -11,6 +11,12 @@ * Alters the update_settings form to add advanced, per-project settings. */ function _update_advanced_alter_settings(&$form, $form_state) { + $form['update_advanced_check_disabled'] = array( + '#type' => 'checkbox', + '#title' => t('Check for updates of disabled modules and themes'), + '#default_value' => variable_get('update_advanced_check_disabled', FALSE), + ); + if ($available = update_get_available(TRUE)) { $path = drupal_get_path('module', 'update_advanced'); drupal_add_css($path .'/update_advanced.css'); @@ -78,6 +84,7 @@ function theme_update_advanced_settings( $output .= drupal_render($form['update_notify_emails']); $output .= drupal_render($form['update_check_frequency']); $output .= drupal_render($form['update_notification_threshold']); + $output .= drupal_render($form['update_advanced_check_disabled']); $header = array( array('data' => t('Project'), 'class' => 'update-advanced-project'), @@ -118,6 +125,8 @@ function theme_update_advanced_settings( 'core' => t('Drupal core'), 'module' => t('Modules'), 'theme' => t('Themes'), + 'disabled-module' => t('Disabled modules'), + 'disabled-theme' => t('Disabled themes'), ); foreach ($project_types as $type_name => $type_label) { if (!empty($rows[$type_name])) { @@ -150,10 +159,26 @@ function theme_update_advanced_settings( * actually saved into the {variables} table, then invokes the true submit * handler for the settings form to save or reset all the values. * + * Also invalidates the cache of available updates if the "Check for updates + * of disabled modules and themes" setting is being changed. Both the advanced + * settings table and the available updates report need to refetch available + * update data after this setting changes or they're going to show misleading + * things (for example, listing all of the disabled projects on the site with + * the "No available releases found" warning). + * * @see update_settings_submit() */ function update_advanced_settings_submit($form, &$form_state) { unset($form_state['values']['data']); unset($form_state['values']['available']); + + // See if the update_advanced_check_disabled setting is being changed, and + // if so, invalidate all cached update status data. + $check_disabled = variable_get('update_advanced_check_disabled', FALSE); + if ($form_state['values']['update_advanced_check_disabled'] != $check_disabled) { + drupal_set_message(t('The %update_advanced_check_disabled setting has been changed, attempted to refetch available update data.', array('%update_advanced_check_disabled' => t('Check for updates of disabled modules and themes')))); + update_invalidate_cache(); + } + return update_settings_submit($form, $form_state); }