summaryrefslogtreecommitdiff
path: root/includes/filetransfer
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-01 00:23:36 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-01 00:23:36 +0000
commit9f5cd5395a9bae17fbbacf11da5bb1e90fda82a6 (patch)
tree0961b4fd416bf22236517894b982bdbe017141db /includes/filetransfer
parent5c3fdc3ee1635b06a4136e7accc0a7f360840e92 (diff)
downloadbrdo-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 'includes/filetransfer')
-rw-r--r--includes/filetransfer/filetransfer.inc36
-rw-r--r--includes/filetransfer/ftp.inc11
-rw-r--r--includes/filetransfer/ssh.inc11
3 files changed, 58 insertions, 0 deletions
diff --git a/includes/filetransfer/filetransfer.inc b/includes/filetransfer/filetransfer.inc
index a917ff7cd..8d4271760 100644
--- a/includes/filetransfer/filetransfer.inc
+++ b/includes/filetransfer/filetransfer.inc
@@ -313,6 +313,42 @@ abstract class FileTransfer {
$this->chroot = $this->findChroot();
$this->jail = $this->fixRemotePath($this->jail);
}
+
+ /**
+ * Returns a form to collect connection settings credentials.
+ *
+ * Implementing classes can either extend this form with fields collecting the
+ * specific information they need, or override it entirely.
+ */
+ public function getSettingsForm() {
+ $form['username'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Username'),
+ );
+ $form['password'] = array(
+ '#type' => 'password',
+ '#title' => t('Password'),
+ '#description' => t('Your password is not saved in the database and is only used to establish a connection.'),
+ );
+ $form['advanced'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Advanced settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['advanced']['hostname'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Host'),
+ '#default_value' => 'localhost',
+ '#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'),
+ );
+ $form['advanced']['port'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Port'),
+ '#default_value' => NULL,
+ );
+ return $form;
+ }
}
/**
diff --git a/includes/filetransfer/ftp.inc b/includes/filetransfer/ftp.inc
index 74a15a451..3d4cc9f64 100644
--- a/includes/filetransfer/ftp.inc
+++ b/includes/filetransfer/ftp.inc
@@ -24,6 +24,8 @@ abstract class FileTransferFTP extends FileTransfer {
* options. If the FTP PHP extension is available, use it.
*/
static function factory($jail, $settings) {
+ $settings['username'] = empty($settings['username']) ? '' : $settings['username'];
+ $settings['password'] = empty($settings['password']) ? '' : $settings['password'];
$settings['hostname'] = empty($settings['hostname']) ? 'localhost' : $settings['hostname'];
$settings['port'] = empty($settings['port']) ? 21 : $settings['port'];
@@ -36,6 +38,15 @@ abstract class FileTransferFTP extends FileTransfer {
return new $class($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']);
}
+
+ /**
+ * Returns the form to configure the FileTransfer class for FTP.
+ */
+ public function getSettingsForm() {
+ $form = parent::getSettingsForm();
+ $form['advanced']['port']['#default_value'] = 21;
+ return $form;
+ }
}
class FileTransferFTPExtension extends FileTransferFTP implements FileTransferChmodInterface {
diff --git a/includes/filetransfer/ssh.inc b/includes/filetransfer/ssh.inc
index f0bae72d0..d47360f9c 100644
--- a/includes/filetransfer/ssh.inc
+++ b/includes/filetransfer/ssh.inc
@@ -25,6 +25,8 @@ class FileTransferSSH extends FileTransfer implements FileTransferChmodInterface
}
static function factory($jail, $settings) {
+ $settings['username'] = empty($settings['hostname']) ? '' : $settings['username'];
+ $settings['password'] = empty($settings['password']) ? '' : $settings['password'];
$settings['hostname'] = empty($settings['hostname']) ? 'localhost' : $settings['hostname'];
$settings['port'] = empty($settings['port']) ? 22 : $settings['port'];
return new FileTransferSSH($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']);
@@ -95,4 +97,13 @@ class FileTransferSSH extends FileTransfer implements FileTransferChmodInterface
throw new FileTransferException('Cannot change permissions of @path.', NULL, array('@path' => $path));
}
}
+
+ /**
+ * Returns the form to configure the FileTransfer class for SSH.
+ */
+ public function getSettingsForm() {
+ $form = parent::getSettingsForm();
+ $form['advanced']['port']['#default_value'] = 22;
+ return $form;
+ }
}