diff --git modules/update/update.manager.inc modules/update/update.manager.inc index efc2d28..4523576 100644 --- modules/update/update.manager.inc +++ modules/update/update.manager.inc @@ -351,6 +351,23 @@ function update_manager_download_batch_finished($success, $results) { * file transfer credentials and attempt to complete the update. */ function update_manager_update_ready_form($form, &$form_state) { + $form['available_backends'] = array( + '#prefix' => '

', + '#suffix' => '

', + ); + + // Do a preliminary check to see if file transfers will be performed locally. + // See update_manager_update_ready_form_submit(). + $local_transfers_allowed = fileowner(drupal_tempnam('temporary://', 'update_')) == fileowner(conf_path()); + + $available_backends = module_invoke_all('filetransfer_backends'); + if (!$local_transfers_allowed && empty($available_backends)) { + $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this administrative interface. You can instead update modules and themes by uploading the new versions directly to the server, as described in the handbook.', array('@handbook_url' => 'http://drupal.org/getting-started/install-contrib')); + return $form; + } + + $form['available_backends'] += _update_manager_backends_form($available_backends); + $form['backup'] = array( '#prefix' => '', '#markup' => t('Back up your database and site before you continue. Learn how.', array('@backup_url' => url('http://drupal.org/node/22281'))), @@ -455,11 +472,31 @@ function update_manager_update_ready_form_submit($form, &$form_state) { * The form array for selecting which project to install. */ function update_manager_install_form($form, &$form_state, $context) { - $form = array(); + $form['available_backends'] = array( + '#prefix' => '

', + '#suffix' => '

', + ); + + // Do a preliminary check to see if file transfers will be performed locally. + // See update_manager_install_form_submit(). + $local_transfers_allowed = fileowner(drupal_tempnam('temporary://', 'update_')) == fileowner(conf_path()); + + $available_backends = module_invoke_all('filetransfer_backends'); + if (!$local_transfers_allowed && empty($available_backends)) { + $form['available_backends']['#markup'] = t('Your server does not support installing modules and themes from this administrative interface. You can instead install modules and themes by uploading them directly to the server, as described in the handbook.', array('@handbook_url' => 'http://drupal.org/getting-started/install-contrib')); + return $form; + } + + $form['available_backends'] += _update_manager_backends_form($available_backends); $form['help_text'] = array( '#prefix' => '

', - '#markup' => t('To install a new module or theme, either enter the URL of an archive file you wish to install, or upload the archive file that you have downloaded. You can find modules and themes at http://drupal.org.
The following archive extensions are supported: %extensions.', array('@module_url' => 'http://drupal.org/project/modules', '@theme_url' => 'http://drupal.org/project/themes', '@drupal_org_url' => 'http://drupal.org', '%extensions' => archiver_get_extensions())), + '#markup' => t('You can find modules and themes on drupal.org. The following file extensions are supported: %extensions.', array( + '@module_url' => 'http://drupal.org/project/modules', + '@theme_url' => 'http://drupal.org/project/themes', + '@drupal_org_url' => 'http://drupal.org', + '%extensions' => archiver_get_extensions(), + )), '#suffix' => '

', ); @@ -491,6 +528,34 @@ function update_manager_install_form($form, &$form_state, $context) { } /** + * Generates a form fragment describing the specified file transfer backends. + * + * @param array $available_backends + * An array of available database backend definitions. + * @return + * The appropriate form fragment for the specified backends. + */ +function _update_manager_backends_form($available_backends) { + $backend_names = array(); + foreach ($available_backends as $backend) { + $backend_names[] = $backend['title']; + } + $form['#markup'] = format_plural( + count($available_backends), + 'Note: Installing or updating modules and themes from this administrative interface will require @backends access to your server. See the handbook for other installation methods.', + 'Note: Installing or updating modules and themes from this administrative interface will require access to your server via one of the following methods: @backends. See the handbook for other installation methods.', + array( + '@backends' => implode(', ', $backend_names), + '@handbook_url' => 'http://drupal.org/getting-started/install-contrib', + )); + // If file transfers will be performed locally, we do not need to display the + // above note. + $form['#access'] = !$local_transfers_allowed; + + return $form; +} + +/** * Validate the form for installing a new project via the update manager. */ function update_manager_install_form_validate($form, &$form_state) {