diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-01 00:23:36 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-01 00:23:36 +0000 |
commit | 9f5cd5395a9bae17fbbacf11da5bb1e90fda82a6 (patch) | |
tree | 0961b4fd416bf22236517894b982bdbe017141db /modules/system/system.api.php | |
parent | 5c3fdc3ee1635b06a4136e7accc0a7f360840e92 (diff) | |
download | brdo-9f5cd5395a9bae17fbbacf11da5bb1e90fda82a6.tar.gz brdo-9f5cd5395a9bae17fbbacf11da5bb1e90fda82a6.tar.bz2 |
#609772 by dww, JacobSingh, ksenzee: Fixed Impossible to extend the FileTransfer class system in contrib
Diffstat (limited to 'modules/system/system.api.php')
-rw-r--r-- | modules/system/system.api.php | 109 |
1 files changed, 63 insertions, 46 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php index be46d5d10..259c608a4 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -4279,52 +4279,6 @@ function hook_countries_alter(&$countries) { } /** - * Provide information on available file transfer backends. - * - * File transfer backends are used by modules to transfer files from remote - * locations to Drupal sites. For instance, update.module uses a file transfer - * backend to download new versions of modules and themes from drupal.org. - * - * @return - * An associative array of information about the file transfer backend(s). - * being provided. This array can contain the following keys: - * - title: Title of the backend to be shown to the end user. - * - class: Name of the PHP class which implements this backend. - * - settings_form: An optional callback function that provides additional - * configuration information required by this backend (for instance a port - * number.) - * - weight: Controls what order the backends are presented to the user. - * - * @see authorize.php - * @see FileTransfer - */ -function hook_filetransfer_backends() { - $backends = array(); - - // This is the default, will be available on most systems. - if (function_exists('ftp_connect')) { - $backends['ftp'] = array( - 'title' => t('FTP'), - 'class' => 'FileTransferFTP', - 'settings_form' => 'system_filetransfer_backend_form_ftp', - 'weight' => 0, - ); - } - - // SSH2 lib connection is only available if the proper PHP extension is - // installed. - if (function_exists('ssh2_connect')) { - $backends['ssh'] = array( - 'title' => t('SSH'), - 'class' => 'FileTransferSSH', - 'settings_form' => 'system_filetransfer_backend_form_ssh', - 'weight' => 20, - ); - } - return $backends; -} - -/** * Control site status before menu dispatching. * * The hook is called after checking whether the site is offline but before @@ -4350,5 +4304,68 @@ function hook_menu_site_status_alter(&$menu_site_status, $path) { } /** + * Register information about FileTransfer classes provided by a module. + * + * The FileTransfer class allows transfering files over a specific type of + * connection. Core provides classes for FTP and SSH. Contributed modules are + * free to extend the FileTransfer base class to add other connection types, + * and if these classes are registered via hook_filetransfer_info(), those + * connection types will be available to site administrators using the Update + * manager when they are redirected to the authorize.php script to authorize + * the file operations. + * + * @return array + * Nested array of information about FileTransfer classes. Each key is a + * FileTransfer type (not human readable, used for form elements and + * variable names, etc), and the values are subarrays that define properties + * of that type. The keys in each subarray are: + * - 'title': Required. The human-readable name of the connection type. + * - 'class': Required. The name of the FileTransfer class. The constructor + * will always be passed the full path to the root of the site that should + * be used to restrict where file transfer operations can occur (the $jail) + * and an array of settings values returned by the settings form. + * - 'file': Required. The include file containing the FileTransfer class. + * This should be a separate .inc file, not just the .module file, so that + * the minimum possible code is loaded when authorize.php is running. + * - 'file path': Optional. The directory (relative to the Drupal root) + * where the include file lives. If not defined, defaults to the base + * directory of the module implementing the hook. + * - 'weight': Optional. Integer weight used for sorting connection types on + * the authorize.php form. + * + * @see FileTransfer + * @see authorize.php + * @see hook_filetransfer_info_alter() + * @see drupal_get_filetransfer_info() + */ +function hook_filetransfer_info() { + $info['sftp'] = array( + 'title' => t('SFTP (Secure FTP)'), + 'file' => 'sftp.filetransfer.inc', + 'class' => 'FileTransferSFTP', + 'weight' => 10, + ); + return $info; +} + +/** + * Alter the FileTransfer class registry. + * + * @param array $filetransfer_info + * Reference to a nested array containing information about the FileTransfer + * class registry. + * + * @see hook_filetransfer_info() + */ +function hook_filetransfer_info_alter(&$filetransfer_info) { + if (variable_get('paranoia', FALSE)) { + // Remove the FTP option entirely. + unset($filetransfer_info['ftp']); + // Make sure the SSH option is listed first. + $filetransfer_info['ssh']['weight'] = -10; + } +} + +/** * @} End of "addtogroup hooks". */ |