Index: plugin.php
===================================================================
RCS file: plugin.php
diff -N plugin.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugin.php	1 Sep 2009 09:46:30 -0000
@@ -0,0 +1,143 @@
+<?php
+// $Id$
+
+/**
+ * Root directory of Drupal installation.
+ */
+define('DRUPAL_ROOT', getcwd());
+
+/**
+ * @file
+ * Administrative page for handling updates from one Drupal version to another.
+ *
+ * Point your browser to "http://www.example.com/update.php" and follow the
+ * instructions.
+ *
+ * If you are not logged in as administrator, you will need to modify the access
+ * check statement inside your settings.php file. After finishing the upgrade,
+ * be sure to open settings.php again, and change it back to its original state!
+ */
+
+/**
+ * Global flag to identify update.php run, and so avoid various unwanted
+ * operations, such as hook_init() and hook_exit() invokes, css/js preprocessing
+ * and translation, and solve some theming issues. This flag is checked on several
+ * places in Drupal code (not just update.php).
+ */
+define('MAINTENANCE_MODE', 'update');
+
+require_once DRUPAL_ROOT . '/includes/plugin.inc';
+
+// Some unavoidable errors happen because the database is not yet up-to-date.
+// Our custom error handler is not yet installed, so we just suppress them.
+// ini_set('display_errors', FALSE);
+// JS: This is crazy.
+
+if (realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) {
+
+  // We prepare a minimal bootstrap for the update requirements check to avoid
+  // reaching the PHP memory limit.
+  require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+  require_once DRUPAL_ROOT . '/includes/update.inc';
+  include_once DRUPAL_ROOT . '/includes/install.inc';
+  include_once DRUPAL_ROOT . '/includes/batch.inc';
+  include_once DRUPAL_ROOT . '/modules/update/update.admin.inc';
+
+  // Determine if the current user has access to run update.php.
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+  drupal_set_title('Updating your site');
+  drupal_maintenance_theme();
+  
+  if (empty($update_free_access) && $user->uid != 1) {
+    print theme('update_page', $output, !$progress_page);
+    exit;
+  }
+  global $base_url;
+  
+  //module_list(TRUE, FALSE, $module_list);
+
+  // Turn error reporting back on. From now on, only fatal errors (which are
+  // not passed through the error handler) will cause a message to be printed.
+  ini_set('display_errors', TRUE);
+
+  
+  drupal_load_updates();
+
+  update_fix_d7_requirements();
+  update_fix_compatibility();
+  
+  if (isset($_SESSION['update_batch_results']) && $results = $_SESSION['update_batch_results']) {
+    // If this variable is set it means that the user entered FTP details because
+    // they needed to chmod the sites/default/* dirs.  We want to set them back.
+    if ($_SESSION['filetransfer_settings']) {
+      $filetransfer_settings = $_SESSION['filetransfer_settings'];
+
+      // This contains the user's sensative credentials, we have to make sure
+      // that it gets unset.
+      unset($_SESSION['filetransfer_settings']);
+      
+      $filetransfer_backend = variable_get('update_filetransfer_default', null);
+      $ft = update_get_filetransfer($filetransfer_backend, $filetransfer_settings);
+      // This sets the permissions to non-writable for everyone.
+      _plugin_manager_create_and_setup_directories($ft, 0755);
+    }
+
+    //Clear the session out;
+    unset($_SESSION['update_batch_results']);
+
+    //Add the update.php functions and css
+    include_once './includes/update.inc';
+    drupal_add_css('modules/system/maintenance.css');
+
+    if ($results['success']) {
+      variable_set('site_offline', FALSE);
+      drupal_set_message(t("Update was completed successfully!  Your site has been taken out of maintenance mode."));
+    } else {
+      drupal_set_message(t("Update failed! See the log below for more information. Your site is still in maintenance mode"), 'error');
+    }
+
+    $output = "";
+    $output .= get_plugin_report($results['messages']);
+    drupal_set_title('Update complete');
+
+
+    $links = array (
+      l('Administration pages', 'admin'),
+      l('Front page', '<front>'),
+    );
+    $output .= theme('item_list', $links);
+
+    print theme('update_page', $output);
+    return;
+  }
+  
+  if (empty($_SESSION['plugin_op'])) {
+    $output = t("It appears you have reached this page in error.");
+    print theme('update_page', $output);
+    return;
+  }
+  else {
+    if (_plugin_manager_writable_dir()) {
+      drupal_set_title('Installing updates');
+      // Go ahead, process the batch.
+      // I just process the batch, because everything is set-up.
+      // I chown'd god.
+      $batch = $_SESSION['plugin_op'];
+      unset($_SESSION['plugin_op']);
+      batch_set($batch);
+      batch_process(url($base_url . '/plugin.php', array('absolute' => TRUE)));
+    }
+    else {
+      // Still needs to be refactored, big time.
+      $output = drupal_render(drupal_get_form('plugin_filetransfer_form'));
+      // Then when it comes back, we need to:
+      // Set the modules directory to be writable - is this good enough?
+    }
+  }
+
+  if (!empty($output)) {
+    // We defer the display of messages until all updates are done.
+    $progress_page = ($batch = batch_get()) && isset($batch['running']);
+    print theme('update_page', $output, !$progress_page);
+  }
+}
\ No newline at end of file
Index: includes/plugin.inc
===================================================================
RCS file: includes/plugin.inc
diff -N includes/plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/plugin.inc	1 Sep 2009 09:46:32 -0000
@@ -0,0 +1,303 @@
+<?php
+
+/**
+ * Have to explicitly include because the registry is not available to us.
+ */
+require_once DRUPAL_ROOT . '/includes/filetransfer/filetransfer.inc';
+require_once DRUPAL_ROOT . '/includes/filetransfer/ftp.inc';
+require_once DRUPAL_ROOT . '/includes/filetransfer/ssh.inc';
+
+function plugin_filetransfer_form($form_state) {
+  global $base_url;
+  $form = array();
+  $form['#action'] = url($base_url . '/plugin.php', array('absolute' => TRUE));
+
+  $form['#attached_css'][] = drupal_get_path('module', 'update') . '/update.css';
+  $form['#attached_js'][] = drupal_get_path('module', 'update') . '/update.js';
+  // Get all the available ways to transfer files.
+  $available_backends = module_invoke_all('filetransfer_backends');
+  if (!count($available_backends)) {
+    // @TODO: Clean up this error handling
+    drupal_set_message(t('Unable to continue, not available methods of file transfer'), 'error');
+    return array();
+  }
+
+  uasort($available_backends, 'drupal_sort_weight');
+
+  // Decide on a default backend.
+  if (isset($form_state['values']['connection_settings']['update_filetransfer_default'])) {
+    $update_filetransfer_default = $form_state['values']['connection_settings']['update_filetransfer_default'];
+  }
+  elseif ($update_filetransfer_default = variable_get('update_filetransfer_default', NULL));
+  else {
+    $update_filetransfer_default = key($available_backends);
+  }
+
+  $form['information']['main_header'] = array(
+    '#prefix' => '<h3>',
+    '#markup' => t('Please provide your server connection details'),
+    '#suffix' => '</h3>',
+  );
+
+  $form['connection_settings']['#tree'] = TRUE;
+  $form['connection_settings']['update_filetransfer_default'] = array(
+    '#type' => 'select',
+    '#title' => t('Connection method'),
+    '#default_value' => $update_filetransfer_default,
+    '#weight' => -10,
+  );
+
+  /**
+     * Here we create two submit buttons.  For a JS enabled client,
+     * they will only ever see submit_process.
+     *
+     * However, if a client doesn't have JS enabled, they will see submit_connection
+     * on the first form (whden picking what filetranfer type to use, and
+     * submit_process on the second one (which leads to the actual operation)
+     *
+     */
+    $form['submit_connection'] = array(
+      '#prefix' => "<br style='clear:both'/>",
+      '#name' => 'enter_connection_settings', // This is later changed in JS.
+      '#type' => 'submit',
+      '#value' => t('Enter connetion settings'), // As is this.  @see update.js.
+      '#weight' => 100,
+    );
+
+    $form['submit_process'] = array(
+      '#name' => 'process_updates', // This is later changed in JS.
+      '#type' => 'submit',
+      '#value' => t('Process Updates'), // As is this.  @see update.js
+      '#weight' => 100,
+      '#attributes' => array('style' => 'display:none'),
+    );
+
+  // Build a hidden fieldset for each one.
+  foreach ($available_backends as $name => $backend) {
+    $form['connection_settings']['update_filetransfer_default']['#options'][$name] = $backend['title'];
+    $form['connection_settings'][$name] = array (
+      '#type' => 'fieldset',
+      '#attributes' => array('class' => "filetransfer-$name filetransfer"),
+      '#title' => t('@backend connection settings', array('@backend' => $backend['title'])),
+    );
+
+    $current_settings = variable_get("update_filetransfer_connection_settings_" . $name, array());
+    $form['connection_settings'][$name] += system_get_filetransfer_settings_form($name, $current_settings);
+
+    // Start non-JS code.
+    if (isset($form_state['values']['connection_settings']['update_filetransfer_default']) && $form_state['values']['connection_settings']['update_filetransfer_default'] == $name) {
+      /**
+       * This means the form has been submitted by a non-JS user, and they have
+       * choosen a transfer type.
+       */
+
+      // If the user switches from JS to non-JS, Drupal (and Batch API) will barf.
+      // This is a known bug: http://drupal.org/node/229825.
+      setcookie('has_js', '', time() - 3600, '/');
+      unset($_COOKIE['has_js']);
+
+      // Change the submit button to the submit_process one.
+      $form['submit_process']['#attributes'] = array();
+      unset($form['submit_connection']);
+      //
+      // Active the proper filetransfer settings form.
+      $form['connection_settings'][$name]['#attributes']['style'] = 'display:block';
+      // Disable the select box.
+      $form['connection_settings']['update_filetransfer_default']['#disabled'] = TRUE;
+
+      // Create a button for changing the type of connection.
+      $form['connection_settings']['change_connection_type'] = array (
+        '#name' => 'change_connection_type',
+        '#type' => 'submit',
+        '#value' => t('Change connection type'),
+        '#weight' => -5,
+        '#attributes' => array('class' => 'filetransfer-change-connection-type'),
+      );
+    }
+    //End non-JS code
+  }
+  return $form;
+}
+
+/**
+ * Validate function for the main update form.
+ *
+ * @see update_update_form
+ */
+function plugin_filetransfer_form_validate($form, &$form_state) {
+  if ($form_state['clicked_button']['#name'] == 'process_updates') {
+    if (isset($form_state['values']['connection_settings'])) {
+      $backend = $form_state['values']['connection_settings']['update_filetransfer_default'];
+      $filetransfer = update_get_filetransfer($backend, $form_state['values']['connection_settings'][$backend]);
+      try {
+        if (!$filetransfer) {
+          throw new Exception($backend . " error, this type of connection protocol doesn't exist.");
+        }
+        $filetransfer->connect();
+      }
+      catch(Exception $e) {
+        form_set_error('connection_settings', $e->getMessage());
+      }
+    }
+  }
+}
+
+
+
+/**
+ * Submit function for the main update form.
+ *
+ * @see update_update_form
+ */
+function plugin_filetransfer_form_submit($form, &$form_state) {
+  global $base_url;
+  switch ($form_state['clicked_button']['#name']) {
+    case 'process_updates':
+
+      // Save the connection settings to the DB.
+      $filetransfer_backend = $form_state['values']['connection_settings']['update_filetransfer_default'];
+
+      // If the database is available then try to save our settings.  We have to make sure it is available
+      // since this code could potentially (will likely) be called during the installation process, before
+      // the database is setup.
+      if (db_is_active()) {
+        $connection_settings = array();
+        foreach ($form_state['values']['connection_settings'][$filetransfer_backend] as $key => $value) {
+          if (!isset($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save']) ||
+            $form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save']) {
+            $connection_settings[$key] = $value;
+          }
+        }
+        // Set this one as the default update method.
+        variable_set('update_filetransfer_default', $filetransfer_backend);
+        // Save the connection settings minus the password.
+        variable_set("update_filetransfer_connection_settings_" . $filetransfer_backend, $connection_settings);
+
+        // chmod the modules directory to 755
+        $ft = update_get_filetransfer($filetransfer_backend, $form_state['values']['connection_settings'][$filetransfer_backend]);
+
+        // I don't like doing this, but I don't know how else to store this information but in the session.
+        // See plugin.php for the consumption and deletion of this dangerous variable.
+        // Should also have some sort of forced clearing I suppose.
+
+        $_SESSION['filetransfer_settings'] = $form_state['values']['connection_settings'][$filetransfer_backend];
+
+        _plugin_manager_create_and_setup_directories($ft, 0777);
+        drupal_goto(url($base_url . '/plugin.php', array('absolute' => TRUE)));
+      }
+      break;
+
+    case 'enter_connection_settings':
+      $form_state['rebuild'] = TRUE;
+      break;
+
+    case 'change_connection_type':
+      $form_state['rebuild'] = TRUE;
+      unset($form_state['values']['connection_settings']['update_filetransfer_default']);
+      break;
+  }
+}
+
+function _plugin_manager_create_and_setup_directories($filetransfer, $mode = 0755) {
+  
+  $theme_dir = _plugin_get_theme_dir();
+  $module_dir = _plugin_get_module_dir();
+  // If there are no module or theme directories create them.
+  if (!is_dir($theme_dir) || !is_dir($module_dir)) {
+    if (!is_writable(DRUPAL_ROOT . '/' . conf_path())) {
+      $filetransfer->chmod(DRUPAL_ROOT . '/' . conf_path(), $mode, FALSE);
+    }
+    _plugin_manager_create_dirs();
+  }
+
+  $filetransfer->chmod($theme_dir, $mode, TRUE);
+  $filetransfer->chmod($module_dir, $mode, TRUE);
+}
+
+function _plugin_manager_create_dirs() {
+  $theme_dir = _plugin_get_theme_dir();
+  $module_dir = _plugin_get_module_dir();
+  
+  if (!is_dir($theme_dir)) {
+    mkdir($theme_dir);
+  }
+  if (!is_dir($module_dir)) {
+    mkdir($module_dir);
+  }
+}
+
+/**
+ * Determines if the modules or themes directories are writable.
+ *
+ *
+ * @param string $type Which type of plugin to check for. (Currently not implemented)
+ * @return boolean
+ */
+function _plugin_manager_writable_dir($type = 'both') {
+  switch ($type) {
+    case 'both':
+      $test[] = conf_path() . '/modules';
+      $test[] = conf_path() . '/themes';
+      break;
+    case 'module':
+      $test[] = conf_path() . '/modules';
+      break;
+    case 'theme':
+      $test[] = conf_path() . '/themes';
+      break;
+  }
+
+  foreach($test as $path) {
+    if (!is_writable($path)) {
+      return FALSE;
+    }
+  }
+  return TRUE;
+}
+
+function _plugin_get_module_dir() {
+  return DRUPAL_ROOT . '/' . conf_path() . '/modules';
+}
+
+function _plugin_get_theme_dir() {
+  return DRUPAL_ROOT . '/' . conf_path() . '/themes';
+}
+
+/**
+ * Blantantly (and shamefully) ripped from update.php.
+ *
+ * Interim measure, this code is not very clear.
+ * @param array $messages
+ * @return string Report similar to update.php
+ */
+function get_plugin_report($messages) {
+  $output = "";
+  // Output a list of queries executed
+  if (!empty($messages)) {
+    $output .= '<div id="update-results">';
+    $output .= '<h2>The following actions were executed</h2>';
+    foreach ($messages as $module => $updates) {
+      $output .= '<h3>' . $module . '</h3>';
+      foreach ($updates as $number => $queries) {
+        if ($number != '#abort') {
+          $output .= '<h4>Update #' . $number . '</h4>';
+          $output .= '<ul>';
+          foreach ($queries as $query) {
+            if ($query['success']) {
+              $output .= '<li class="success">' . $query['query'] . '</li>';
+            }
+            else {
+              $output .= '<li class="failure"><strong>Failed:</strong> ' . $query['query'] . '</li>';
+            }
+          }
+          if (!count($queries)) {
+            $output .= '<li class="none">No queries</li>';
+          }
+        }
+        $output .= '</ul>';
+      }
+    }
+    $output .= '</div>';
+  }
+  return $output;
+}
\ No newline at end of file
Index: modules/update/update.admin.inc
===================================================================
RCS file: modules/update/update.admin.inc
diff -N modules/update/update.admin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/update/update.admin.inc	1 Sep 2009 09:46:34 -0000
@@ -0,0 +1,752 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Administrative screens and processing functions for adding new projects
+ * (modules and themes) or updating existing ones.
+ */
+ 
+/**
+ * Menu callback; main updates form.
+ */
+function update_update_form($form_state = array()) {
+  $form = array();
+  
+  if (!isset($form_state['values'])) {
+    // This is the first page of the update process.
+    $form = _update_update_form_update_table();
+  }
+  elseif (is_array($form_state['values']) && (array_filter($form_state['storage']['projects']) || array_filter($form_state['values']['projects']))) {
+    // This is the second page of the update process.
+    $form =  _update_update_form_display_steps();
+    $form['submit'] = array(
+      '#type' => 'submit',
+      '#name' => 'process_updates',
+      '#value' => t('Install these updates'),
+      '#weight' => 100,
+    );
+    //$form += _update_update_form_backend_chooser($form_state);
+  }
+  return $form;
+}
+
+/**
+ * The first page of the update form.
+ * This displays available updates in the form of a table.
+ */
+function _update_update_form_update_table() {
+  drupal_add_css('misc/ui/ui.all.css');
+  drupal_add_css('misc/ui/ui.dialog.css');
+  drupal_add_js('misc/ui/ui.core.js', array('weight' => JS_LIBRARY + 5));
+  drupal_add_js('misc/ui/ui.dialog.js', array('weight' => JS_LIBRARY + 6));
+  $form['#attached_js'][] = DRUPAL_ROOT . '/misc/plugin.js';
+
+  $form['#theme'] = 'update_available_updates_form';
+  $form['projects'] = array();
+  // First step.
+  $options = array();
+  $available = update_get_available(TRUE);
+  if ($available) {
+    module_load_include('inc', 'update', 'update.compare');
+    $project_data = update_calculate_project_data($available);
+    foreach ($project_data as $name => $project) {
+      // Filter out projects which are dev versions, updated or core
+      if (($project['install_type'] == 'dev') || ($project['project_type'] == 'core') || $project['status'] == UPDATE_CURRENT) {
+        continue;
+      }
+      $options[$name]['title'] = l($project['title'], $project['link']);
+      if ($project['project_type'] == 'theme') {
+        $options[$name]['title'] .= ' ' . t('(Theme)');
+      }
+      $options[$name]['installed_version'] = $project['existing_version'];
+      $recommended_version = $project['releases'][$project['recommended']];
+      $options[$name]['recommended_version'] = $recommended_version['version'] . ' ' . l(t('(Release notes)'), $recommended_version['release_link'], array('attributes' => array('title' => t('Release notes for @project_name', array('@project_name' => $project['title'])))));
+      if ($recommended_version['version_major'] != $project['existing_major']) {
+        $options[$name]['recommended_version'] .= '<div title="Major upgrade warning" class="update-major-version-warning">' . t('This update is a major version update which means that it may not be backwards compatible with your currently running version.  It is recommended that you read the release notes and proceed at your own risk.') . '</div>';
+      }
+
+      switch ($project['status']) {
+        case UPDATE_NOT_SECURE:
+        case UPDATE_REVOKED:
+          $options[$name]['title'] .= ' ' . t('(Security Update)');
+          $options[$name]['#weight'] = -2;
+          $type = 'security';
+          break;
+        case UPDATE_NOT_SUPPORTED:
+          $type = 'unsupported';
+          $options[$name]['title'] .= ' ' . t('(Unsupported)');
+          $options[$name]['#weight'] = -1;
+          break;
+        case UPDATE_UNKNOWN:
+        case UPDATE_NOT_FETCHED:
+        case UPDATE_NOT_CHECKED:
+        case UPDATE_NOT_CURRENT:
+          $type = 'recommended';
+          break;
+        default:
+          // Continues out of the switch and then out of the foreach.
+          continue 2;
+      }
+    $options[$name]['#attributes'] = array('class' => array('update-' . $type));
+    }
+  }
+  else {
+    $form['message'] = array(
+      '#markup' => t('There was a problem getting update information.  Please try again later.'),
+    );
+    return $form;
+  }
+
+  if (!count($options)) {
+    $form['message'] = array(
+      '#markup' => t('All of your projects are up to date.'),
+    );
+    return $form;
+  }
+  $form['projects'] = array(
+    '#type' => 'tableselect',
+    '#options' => $options,
+    '#header' => array('title' => array('data' => t('Name'), 'class' => array('update-project-name')), 'installed_version' => t('Installed version'), 'recommended_version' => t('Recommended version')),
+  );
+
+  $form['#attached_css'][] = drupal_get_path('module', 'update') . '/update.css';
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Install these updates'),
+    '#weight' => 100,
+  );
+
+  return $form;
+}
+
+function _update_update_form_display_steps() {
+  $form['information']['#weight'] = -100;
+  $form['information']['backup_header'] = array(
+    '#prefix' => '<h3>',
+    '#markup' => t('Step 1: Backup your site'),
+    '#suffix' => '</h3>',
+  );
+
+  $form['information']['backup_message'] = array(
+    '#prefix' => '<p>',
+    '#markup' => t('We do not currently have a web based backup tool. <a href="@backup_url">Learn more about how to take a backup</a>.', array('@backup_url' => url('http://drupal.org/node/22281'))),
+    '#suffix' => '</p>',
+  );
+
+  $form['information']['maint_header'] = array(
+    '#prefix' => '<h3>',
+    '#markup' => t('Step 2: Enter maintenance mode'),
+    '#suffix' => '</h3>',
+  );
+
+  $form['information']['maint_message'] = array(
+    '#prefix' => '<p>',
+    '#markup' => t('It is strongly recommended that you put your site into maintenance mode while performing an update.'),
+    '#suffix' => '</p>',
+  );
+
+  $form['information']['site_offline'] = array(
+    '#title' => t('Perform updates with site in maintenance mode'),
+    '#type' => 'checkbox',
+    '#default_value' => TRUE,
+  );
+
+  return $form;
+}
+
+
+/**
+ * Submit function for the main update form.
+ *
+ * @see update_update_form
+ */
+function update_update_form_submit($form, &$form_state) {
+  global $base_url;
+  switch ($form_state['clicked_button']['#name']) {
+    case 'process_updates':
+      
+      $operations = array();
+      foreach ($form_state['storage']['projects'] as $project) {
+        // Put this in the begining (download everything first)
+        $operations[] = array('update_batch_get_project', array($project));
+        $latest_version = _update_get_recommended_version($project);
+        // This is the .tar.gz from d.o.
+        $url = $latest_version['download_link'];
+        
+        // Put these on the end
+        $operations[] = array(
+          'update_batch_copy_project',
+          array(
+            $project,
+            $url,
+          ),
+        );
+        $operations[] = array('update_batch_update_project', array($project));
+      }
+
+      $batch = array(
+        'title' => t('Installing updates'),
+        'init_message' => t('Preparing update operation'),
+        'operations' => $operations,
+        'finished' => 'update_batch_finished',
+        'file' => drupal_get_path('module', 'update') . '/update.admin.inc',
+      );
+
+      $_SESSION['plugin_op'] = $batch;
+      drupal_goto(url($base_url . '/plugin.php', array('absolute' => TRUE)));
+      return;
+      
+      break;
+    
+    default:
+    // This is the first page, and store the list of selected projects
+      $form_state['storage']['projects'] = array_keys(array_filter($form_state['values']['projects']));
+    break;
+  }
+}
+
+
+function update_install_form(&$form_state) {
+  $form = array();
+
+  $form['project_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('URL'),
+    '#description' => t('Paste the url to a Drupal module or theme archive (.tar.gz) here to install it.'),
+  );
+
+  $form['information'] = array(
+    '#prefix' => '<strong>',
+    '#markup' => 'Or',
+    '#suffix' => '</strong>',
+  );
+
+  $form['project_upload'] = array(
+    '#type' => 'file',
+    '#title' => t('Upload a module or theme'),
+    '#description' => t('Upload a Drupal module or theme (in .tar.gz format) to install it.'),
+  );
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Install'),
+  );
+
+  return $form;
+}
+
+function update_install_form_validate($form, &$form_state) {
+  if (!($form_state['values']['project_url'] XOR !empty($_FILES['files']['name']['project_upload']))) {
+    form_set_error('project_url', t('Unable to continue, please provide a url or upload a module / theme'));
+    return;
+    //$data = drupal_http_request($form_state['values']['url']);
+  }
+}
+
+function update_install_form_submit($form, &$form_state) {
+  global $base_url;
+  
+  if ($form_state['values']['project_url']) {
+    $field = 'project_url';
+    $local_cache = update_get_file($form_state['values']['project_url']);
+    if (!$local_cache) {
+      form_set_error($field, t('Unable to retreive Drupal project from %url', array('%url' => $form_state['values']['project_url'])));
+      return;
+    }
+  }
+  elseif ($_FILES['files']['name']['project_upload']) {
+    $field = 'project_upload';
+    // @todo: add some validators here.
+    $finfo = file_save_upload($field, array(), NULL, FILE_EXISTS_REPLACE);
+    // @todo: find out if the module is already instealled, if so, throw an error.
+    $local_cache = $finfo->uri;
+  }
+
+  watchdog('update', 'Un-tarring ' . drupal_realpath($local_cache));
+
+  $a = new Archive_Tar(drupal_realpath($local_cache));
+  $files = $a->listContent();
+  if (!$files) {
+    form_set_error($field, t('Provided URL is not a .tar.gz archive', array('%url' => $form_state['values']['url'])));
+    return;
+  }
+  
+  $project = substr($files[0]['filename'], 0, -1); // Remove the trailing slash.
+
+  // We want to make sure that the project is not already installed.
+  // Currently, there is no way to do this :(  Bummer.
+  if (drupal_get_path('module', $project)) {
+    form_set_error($field, t('%project is already installed', array('%project' => $project)));
+    return;
+  }
+
+  $operations = array();
+  
+  $operations[] = array(
+    'update_batch_copy_project',
+    array(
+      $project,
+      $local_cache,
+    ),
+  );
+  // @todo: Finish this.
+  //$operations[] = array('update_batch_enable_project', array($project));
+
+  $batch = array(
+    'title' => t('Installing %project', array('%project' => $project)),
+    'init_message' => t('Preparing update operation'),
+    'operations' => $operations,
+    'finished' => 'update_batch_finished',
+    'file' => drupal_get_path('module', 'update') . '/update.admin.inc',
+  );
+
+  $_SESSION['plugin_op'] = $batch;
+  drupal_goto(url($base_url . '/plugin.php', array('absolute' => TRUE)));
+  return;
+}
+
+/**
+ * Batch operations related to installing / updating projects
+ *
+ **/
+
+
+/**
+ * Batch operation: download a project and put it in a temporary cache.
+ *
+ * @param string $project name of the project being installed
+ * @param array &$context BatchAPI storage
+ *
+ * @return void;
+ */
+function update_batch_get_project($project, &$context) {
+  if (!isset($context['results'][$project])) {
+    $context['results'][$project] = array();
+  }
+  if (!isset($context['sandbox']['started'])) {
+    $context['sandbox']['started'] = TRUE;
+    $context['message'] = t('Downloading %project', array('%project' => $project));
+    $context['finished'] = 0;
+    return;
+  }
+  $latest_version = _update_get_recommended_version($project);
+  if ($local_cache = update_get_file($latest_version['download_link'])) {
+    watchdog('update', 'Downloaded %project to %local_cache', array('%project' => $project, '%local_cache' => $local_cache));
+  }
+  else {
+    $context['success'] = FALSE;
+    $content['results'][$project][] = t('Failed to download %project', array('%project' => $project));
+  }
+}
+
+/**
+ * Batch operation: copy a project to it's proper place.
+ * For updates, will locate the current project and replace it.
+ * For new installs, will download and try to determine the type from the info file
+ * and then place it variable_get(update_default_{$type}_location) i.e. update_default_module_location().
+ *
+ * @todo Fix the $project param (refactor)
+ * @param string $project Either name of the project being installed or a
+ * @param string $url Location of a tarball to install if recommended version of $project not required
+ * @param array &$context BatchAPI storage
+ *
+ * @return void
+ */
+function update_batch_copy_project($project, $url, &$context) {
+  if (!isset($context['results'][$project])) {
+    $context['results'][$project] = array();
+  }
+  if (!empty($context['results'][$project]['#abort'])) {
+    $context['#finished'] = 1;
+    return;
+  }
+
+  watchdog('update', $url);
+  $local_cache = update_get_file($url);
+  watchdog('update', $local_cache);
+  //this extracts the file into the standard place.
+  try {
+    update_untar($local_cache);
+  } catch (Exception $e) {
+    _update_batch_create_message($context['results'][$project], $e->getMessage(), FALSE);
+    $context['results'][$project]['#abort'] = TRUE;
+    return;
+  }
+
+  $project_source_dir = DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-extraction/' . $project;
+  // Now check the dependencies.
+  _update_check_dependencies($project_source_dir . "/$project.info");
+
+
+  if ($project_info = _update_get_project_type_and_location($project)) {
+    // This is an update
+    $is_install = FALSE;
+    $location = $project_info['location'];
+  }
+  else {
+    //This is a fresh install, not an update
+    $type = _update_get_project_type($project_location . '/' . $project . '.info');
+    if (!$type) {
+      _update_batch_create_message($context['results'][$project], t("Unable to determine project type for %name", array("%name" => $project)), FALSE);
+      $context['results'][$project]['#abort'] = TRUE;
+      return;
+    }
+
+    $default_locations = array(
+      'module' => conf_path() . '/modules',
+      'theme' => conf_path() . '/themes',
+      'theme_engine' => conf_path() . '/themes/engines'
+    );
+
+    $location = variable_get("update_default_{$type}_location", $default_locations[$type]) . '/' . $project;
+    $is_install = TRUE;
+  }
+
+  $project_destination_dir = DRUPAL_ROOT . '/' . $location;
+  
+  try {
+
+    if (!$is_install) {
+      _update_remove_directory($project_destination_dir);
+    }
+    _update_copy_directory($project_source_dir, $project_destination_dir);
+  }
+  catch (Exception $e) {
+    _update_batch_create_message($context['results'][$project], t("Error installing / updating)"), FALSE);
+    $context['results'][$project]['#abort'] = TRUE;
+    return;
+  }
+  _update_batch_create_message($context['results'][$project], t('Installed %project_name successfully', array('%project_name' => $project)));
+  $context['finished'] = 1;
+}
+
+/**
+ * Set the batch to run the update functions.
+ */
+function update_batch_update_project($project, &$context) {
+  if (!empty($context['results'][$project]['#abort'])) {
+    $context['#finished'] = 1;
+    return;
+  }
+  $project_info = _update_get_project_type_and_location($project);
+  if ($project_info['type'] != 'module') {
+    $context['finished'] = 1;
+    return;
+  }
+  $operations = array();
+  require_once './includes/update.inc';
+
+  foreach (_update_get_schema_updates($project) as $update) {
+    update_do_one($project, $update, $context);
+  }
+}
+
+/**
+ * Batch callback for when the batch is finished.
+ */
+function update_batch_finished($success, $results) {
+  foreach ($results as $module => $messages) {
+    if (!empty($messages['#abort'])) {
+      $success = FALSE;
+    }
+  }
+  $_SESSION['update_batch_results']['success'] = $success;
+  $_SESSION['update_batch_results']['messages'] = $results;
+}
+
+/**
+ *
+ * Very stupid function to provide compatibility with update.php's
+ * silly functions
+ * Some better error handling is needed, but batch API doesn't seem to support any.
+ *
+ * @param array $project_results
+ * @param string $message
+ * @param bool $success
+ */
+function _update_batch_create_message(&$project_results, $message, $success = TRUE) {
+  $next_number = count($project_results) + 1;
+  $project_results[$next_number] = array(array('query' => $message, 'success' => $success));
+}
+
+/**
+ * Theme main updates page.
+ *
+ * @ingroup themeable
+ */
+function theme_update_available_updates_form($form) {
+  $last = variable_get('update_last_check', 0);
+  $output = '<div class="update checked">' . ($last ? t('Last checked: @time ago', array('@time' => format_interval(REQUEST_TIME - $last))) : t('Last checked: never'));
+  $output .= ' <span class="check-manually">(' . l(t('Check manually'), 'admin/reports/updates/check') . ')</span>';
+  $output .= "</div>\n";
+  $output .= drupal_render_children($form);
+  return $output;
+}
+
+/**
+
+ * Previously update.module
+ *
+ */
+
+
+/**
+ * Untar a file, using the Archive_Tar class.
+ *
+ * @param string $file the filename you wish to extract
+ *
+ * @return void
+ * @throws Exception on failure.
+ */
+function update_untar($file) {
+  $extraction_dir = DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-extraction';
+  if (!file_exists($extraction_dir)) {
+    mkdir($extraction_dir);
+  }
+  $archive_tar = new Archive_Tar($file);
+  if (!$archive_tar->extract($extraction_dir)) {
+    throw new Exception(t('Unable to extact %file', array('%file' => $file)));
+  }
+}
+
+/**
+ * Get a filetransfer class.
+ *
+ * @param $method
+ *   The filetransfer method to get the class for.
+ * @param $overrides
+ *   A set of overrides over the defaults.
+ */
+function update_get_filetransfer($method, $overrides = array()) {
+  // Fire up the connection class
+  $settings = variable_get("update_filetransfer_connection_settings_" . $method, array());
+  $settings = array_merge($settings, $overrides);
+  $available_backends = module_invoke_all('filetransfer_backends');
+  $filetransfer = call_user_func_array($available_backends[$method]['class'] . '::factory', array(DRUPAL_ROOT, $settings));
+  return $filetransfer;
+}
+
+
+/**
+ * Helper function, returns a an associative array of a project's type and
+ * location returns false on failure.
+ */
+function _update_get_project_type_and_location($name) {
+  foreach (array('module', 'theme') as $type) {
+    if ($dir = drupal_get_path($type, $name)) {
+      return array('type' => $type, 'location' => $dir);
+    }
+  }
+  return FALSE;
+}
+
+/**
+ * Get's the latest release of a project
+ *
+ * @param string $name Name of the project
+ * @return array An array of information about the latest recommended
+ * release of the project
+ */
+function _update_get_latest_version($name) {
+  if ($available = update_get_available(FALSE)) {
+    module_load_include('inc', 'update', 'update.compare');
+    $project_data = update_calculate_project_data($available);
+    $project = $project_data[$name];
+    return $project['releases'][$project['latest_version']];
+  }
+}
+
+/**
+ * Returns the available updates for a given module in an array
+ *
+ * @param $project
+ *  The name of the module.
+ */
+function _update_get_schema_updates($project) {
+  require_once './includes/install.inc';
+  require_once './includes/update.inc';
+  $module_info = _update_get_project_type_and_location($project);
+  if ($module_info['type'] != 'module') {
+    return array();
+  }
+  module_load_include('install', $project);
+
+  if (!$updates = drupal_get_schema_versions($project)) {
+    return array();
+  }
+  $updates_to_run = array();
+  $modules_with_updates = update_get_update_list();
+  //@JS: This is broken
+  if ($updates = $modules_with_updates[$project]) {
+    if ($updates['start']) {
+      return $updates['pending'];
+    }
+  }
+  return array();
+}
+
+/**
+ * Helper function, given an info file, will determine what type of project it is
+ *
+ * @param string $info_file path to info file
+ *
+ * @return string project type, could be theme or module.
+ */
+function _update_get_project_type($info_file) {
+  $info = drupal_parse_info_file($info_file);
+  if ($info['engine']) {
+    return 'theme';
+    //we can assume this is a theme
+  }
+  return 'module';
+}
+
+
+/**
+ * Get a file from the server, or if it was already downloaded, get the local
+ * path to the file.
+ *
+ * @param $url
+ *   The URL of the file on the server.
+ *
+ * @return string Path to local file
+ */
+function update_get_file($url) {
+  $parsed_url = parse_url($url);
+  $remote_schemes = array('http', 'https', 'ftp', 'ftps', 'smb', 'nfs');
+  if (!in_array($parsed_url['scheme'], $remote_schemes)) {
+    // This is a local file, just return the path.
+    return drupal_realpath($url);
+  }
+
+  // Check the cache and download the file if needed.
+  $local = DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-cache/' . basename($parsed_url['path']);
+  if (!file_exists(DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-cache/')) {
+    mkdir(DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-cache/');
+  }
+  
+  system_retrieve_file($url);
+  
+  if (!file_exists($local)) {
+    return system_retrieve_file($url, $local);
+  }
+  else {
+    return $local;
+  }
+}
+
+
+/**
+ * Get's the latest recommended release of a project.  This function will
+ * prioritize updates on the same branch as the current version.
+ *
+ * @param string $name Name of the project
+ * @return array An array of information about the latest recommended
+ * release of the project
+ */
+function _update_get_recommended_version($name) {
+  if ($available = update_get_available(FALSE)) {
+    module_load_include('inc', 'update', 'update.compare');
+    $project_data = update_calculate_project_data($available);
+    $project = $project_data[$name];
+    return $project['releases'][$project['recommended']];
+  }
+}
+
+/**
+ * Can read an info file and check if it has any unmet dependencies.
+ *
+ * @param string $info_file Pathname of info file to check.
+ */
+function _update_check_dependencies($info_file) {
+  $files = system_get_module_data();
+
+  // Remove hidden modules from display list.
+  foreach ($files as $filename => $file) {
+    if (!empty($file->info['hidden']) || !empty($file->info['required'])) {
+      unset($files[$filename]);
+    }
+  }
+
+  $info = drupal_parse_info_file(($info_file));
+
+  $errors = array();
+  if (!is_array($info['dependencies'])) {
+      return array();
+  }
+  foreach ($info['dependencies'] as $module) {
+    if (!isset($files[$module])) {
+      $errors[$module] = t('@module (<span class="admin-missing">missing</span>)', array('@module' => drupal_ucfirst($module)));
+    }
+  }
+  return $errors;
+}
+
+
+/**
+ * Recursively coppies a directory.
+ *
+ * @todo: Should use RecursiveDirectoryIterator.
+ *
+ * @param string $src
+ * @param string $dest
+ * @param array $exclude_patterns
+ */
+function _update_copy_directory($src, $dest) {
+  if (!file_exists($dest)) {
+    mkdir($dest);
+  }
+  foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
+    $relative_path = substr($filename, strlen($src));
+    if ($file->isDir()) {
+      mkdir($dest . '/' . $relative_path);
+    }
+    else {
+      copy($filename, $dest . '/' . $relative_path);
+    }
+  }
+}
+
+/**
+ * Duh. rm -Rf
+ *
+ * @param string $src The directory you want to zap.
+ * @param string $jail An optional jail to make sure you don't wipe /.
+ */
+function _update_remove_directory($src, $jail = DRUPAL_ROOT) {
+  foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src), RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
+    if (strpos($filename, $jail) != 0) {
+      throw new Exception("Tried to delete $filename, but it is outside of the jail: $jail");
+    }
+    if ($file->isDir()) {
+      rmdir($file->getPathName());
+    }
+    else {
+      unlink($file->getPathName());
+    }
+  }
+  rmdir($src);
+}
+
+/**
+ *
+ * Should enable a theme or a module with the same name as the project.
+ * In the future, project-wise info files are recommended which could specify
+ * the modules to install by default inside the project
+ *
+ * @TODO: This is not implemented yet.  Just a stub
+ * @param <type> $project
+ * @return <type>
+ */
+function update_batch_enable_project($project) {
+  return;
+
+  if (_update_get_project_type() == 'theme') {
+    // @todo: Enable the theme.  Would be ideal to prompt post install
+    // if it should be default as well.
+  }
+  else {
+    module_enable($project);
+  }
+}
\ No newline at end of file
Index: modules/update/update.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/update/update.css,v
retrieving revision 1.5
diff -u -r1.5 update.css
--- modules/update/update.css	29 Apr 2009 03:57:21 -0000	1.5
+++ modules/update/update.css	1 Sep 2009 09:46:45 -0000
@@ -1,4 +1,4 @@
-/* $Id: update.css,v 1.5 2009/04/29 03:57:21 webchick Exp $ */
+/* $Id$ */
 
 .update .project {
   font-weight: bold;
@@ -108,3 +108,34 @@
 .update .check-manually {
   padding-left: 1em; /* LTR */
 }
+
+
+table tbody tr.update-security,
+table tbody tr.update-unsupported {
+  background: #fcc;
+}
+
+th.update-project-name {
+  width: 50%;
+}
+
+.connection-settings-update-filetransfer-default-wrapper {
+  float:left;
+}
+
+#edit-submit-connection {
+  clear: both;
+}
+
+.filetransfer {
+  display:none;
+  clear:both;
+}
+
+#edit-connection-settings-change-connection-type {
+  margin: 2.6em 0.5em 0em 1em;
+}
+
+.update-major-version-warning {
+  color:#ff0000;
+}
\ No newline at end of file
Index: modules/update/update.info
===================================================================
RCS file: /cvs/drupal/drupal/modules/update/update.info,v
retrieving revision 1.5
diff -u -r1.5 update.info
--- modules/update/update.info	11 Oct 2008 02:33:12 -0000	1.5
+++ modules/update/update.info	1 Sep 2009 09:46:45 -0000
@@ -7,6 +7,8 @@
 files[] = update.module
 files[] = update.compare.inc
 files[] = update.fetch.inc
+files[] = update.admin.inc
 files[] = update.report.inc
 files[] = update.settings.inc
 files[] = update.install
+files[] = update.js
Index: modules/update/update.js
===================================================================
RCS file: modules/update/update.js
diff -N modules/update/update.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/update/update.js	1 Sep 2009 09:46:45 -0000
@@ -0,0 +1,38 @@
+// $Id$
+(function ($) {
+
+Drupal.behaviors.updateFileTransferForm = {
+  attach: function(context) {
+    $('#edit-connection-settings-update-filetransfer-default').change(function() {
+      $('.filetransfer').hide().filter('.filetransfer-' + $(this).val()).show();
+    });
+    $('.filetransfer').hide().filter('.filetransfer-' + $('#edit-connection-settings-update-filetransfer-default').val()).show();
+
+    // Hide any major version warnings, make a jquery UI dialog when checked.
+
+    $('.update-major-version-warning').each(function (elem) {
+      that = $(this);
+      $(this).hide();
+      $(":checkbox", $(this).parent().parent()).bind('change', function(e) {
+        if (this.checked) {
+          that.dialog("open");
+          var buttons = {}
+          buttons[Drupal.t("Ok")] = function() { $(this).dialog("close"); };
+          buttons[Drupal.t("Cancel")] = function() { alert('cancel'); $(this).dialog("close"); };
+          that.dialog({'buttons': buttons});
+        }
+      });
+    });
+    
+    // Removes the float on the select box (used for non-JS interface)
+    if($('.connection-settings-update-filetransfer-default-wrapper').length > 0) {
+      console.log($('.connection-settings-update-filetransfer-default-wrapper'));
+      $('.connection-settings-update-filetransfer-default-wrapper').css('float', 'none');
+    }
+    // Hides the submit button for non-js users
+    $('#edit-submit-connection').hide();
+    $('#edit-submit-process').show();
+  }
+}
+
+})(jQuery);
Index: modules/update/update.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/update/update.module,v
retrieving revision 1.46
diff -u -r1.46 update.module
--- modules/update/update.module	29 Aug 2009 14:08:36 -0000	1.46
+++ modules/update/update.module	1 Sep 2009 09:46:47 -0000
@@ -67,10 +67,22 @@
 function update_help($path, $arg) {
   switch ($path) {
     case 'admin/reports/updates':
+    case 'admin/reports/full':
       global $base_url;
       $output = '<p>' . t('Here you can find information about available updates for your installed modules and themes. Note that each module or theme is part of a "project", which may or may not have the same name, and might include multiple modules or themes within it.') . '</p>';
-      $output .= '<p>' . t('To extend the functionality or to change the look of your site, a number of contributed <a href="@modules">modules</a> and <a href="@themes">themes</a> are available.', array('@modules' => 'http://drupal.org/project/modules', '@themes' => 'http://drupal.org/project/themes')) . '</p>';
-      $output .= '<p>' . t('Each time Drupal core or a contributed module or theme is updated, it is important that <a href="@update-php">update.php</a> is run.', array('@update-php' => url($base_url . '/update.php', array('external' => TRUE)))) . '</p>';
+
+      return $output;
+
+    case 'admin/reports/updates/install':
+      global $base_url;
+      $help = <<<EOF
+      To install a new module or theme, either upload the .tar.gz file that you
+have downloaded, or paste the URL of a .tar.gz you wish to install. You can find
+ <a href="@module_url">modules</a> and <a href="@theme_url">themes</a> at
+<a href="http://drupal.org">http://drupal.org</a>.
+EOF;
+      $output = '<p>' . t($help, array('@module_url' => 'http://drupal.org/project/modules', '@theme_url' => 'http://drupal.org/project/themes')) . '</p>';
+
       return $output;
     case 'admin/appearance':
     case 'admin/config/modules':
@@ -127,18 +139,63 @@
   $items = array();
 
   $items['admin/reports/updates'] = array(
-    'title' => 'Available updates',
-    'description' => 'Get a status report about available updates for your installed modules and themes.',
-    'page callback' => 'update_status',
+    'title' => 'Updates and Add-ons',
+    'description' => 'Keep your installed modules and themes up to date and install new ones.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('update_update_form'),
     'access arguments' => array('administer site configuration'),
     'weight' => 10,
-    'file' => 'update.report.inc',
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'update.admin.inc',
   );
-  $items['admin/reports/updates/list'] = array(
-    'title' => 'List',
+
+  $items['admin/reports/updates/updater'] = array(
+    'title' => 'Update',
+    'description' => 'Update your installed modules and themes',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('update_update_form'),
     'access arguments' => array('administer site configuration'),
+    'weight' => 10,
     'type' => MENU_DEFAULT_LOCAL_TASK,
+    'file' => 'update.admin.inc',
+  );
+
+  /**
+   * JS: This is kinda stupid, MENU_LOCAL_TASK requires the path to be the same...
+   * Isn't really a report
+   */
+  $items['admin/reports/updates/install'] = array(
+    'title' => 'Add-ons',
+    'description' => 'Install new modules and themes',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('update_install_form'),
+    'access arguments' => array('administer site configuration'),
+    'weight' => 20,
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'update.admin.inc',
+  );
+
+  $items['admin/reports/updates/full'] = array(
+    'title' => 'Update status report',
+    'description' => 'A comprehensive list of all modules installed on your system and their status.',
+    'page callback' => 'update_status',
+    'access arguments' => array('administer site configuration'),
+    'weight' => 30,
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'update.report.inc',
+  );
+
+  $items['admin/update'] = array(
+    'title' => 'Updating your site',
+    'description' => 'Second step of site update / new project install',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('update_update_form'),
+    'access arguments' => array('administer site configuration'),
+    'weight' => 10,
+    'type' => MENU_CALLBACK,
+    'file' => 'update.admin.inc',
   );
+  
   $items['admin/reports/updates/settings'] = array(
     'title' => 'Settings',
     'page callback' => 'drupal_get_form',
@@ -146,7 +203,9 @@
     'access arguments' => array('administer site configuration'),
     'file' => 'update.settings.inc',
     'type' => MENU_LOCAL_TASK,
+    'weight' => 50,
   );
+  
   $items['admin/reports/updates/check'] = array(
     'title' => 'Manual update check',
     'page callback' => 'update_manual_status',
@@ -163,8 +222,9 @@
  */
 function update_theme() {
   return array(
-    'update_settings' => array(
+    'update_available_updates_form' => array(
       'arguments' => array('form' => NULL),
+      'file' => 'update.admin.inc',
     ),
     'update_report' => array(
       'arguments' => array('data' => NULL),
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.783
diff -u -r1.783 system.module
--- modules/system/system.module	31 Aug 2009 17:06:10 -0000	1.783
+++ modules/system/system.module	1 Sep 2009 09:46:50 -0000
@@ -1420,28 +1420,29 @@
  */
 function _system_filetransfer_backend_form_common() {
   $form = array();
-
-  $form['hostname'] = array (
+  
+  $form['hostname'] = array(
     '#type' => 'textfield',
     '#title' => t('Host'),
     '#default_value' => 'localhost',
   );
-
-  $form['port'] = array (
+  
+  $form['port'] = array(
     '#type' => 'textfield',
     '#title' => t('Port'),
     '#default_value' => NULL,
   );
 
-  $form['username'] = array (
+  $form['username'] = array(
     '#type' => 'textfield',
     '#title' => t('Username'),
   );
 
-  $form['password'] = array (
+  $form['password'] = array(
     '#type' => 'password',
     '#title' => t('Password'),
     '#description' => t('This is not saved in the database and is only used to test the connection'),
+    '#filetransfer_save' => FALSE,
   );
 
   return $form;
