You are here

function backup_migrate_destination_s3_compatible::edit_form in Backup and Migrate S3 7

Get the form for the settings for this filter.

File

./destinations.s3.inc, line 337
Functions to handle the dropbox backup destination.

Class

backup_migrate_destination_s3_compatible
A destination for sending database backups to a Dropbox account.

Code

function edit_form() {
  $form = parent::edit_form();
  $form['scheme']['#type'] = 'value';
  $form['scheme']['#value'] = 'https';
  $form['host']['#default_value'] = $form['host']['#default_value'] == 'localhost' ? '' : $form['host']['#default_value'];
  $form['host']['#description'] = t('Enter the S3 compatible host, i.e. s3.amazonaws.com, objects.dreamhost.com, etc.');
  $form['path']['#title'] = 'S3 Bucket';

  //$form['path']['#default_value'] = $this->get_bucket();
  $form['path']['#description'] = 'This bucket must already exist. It will not be created for you.';
  $form['user']['#title'] = 'Access Key ID';
  $form['pass']['#title'] = 'Secret Access Key';
  $form['pass']['#required'] = empty($this->dest_url);
  $form['file_directory'] = array(
    '#type' => 'textfield',
    '#title' => t('File directory'),
    '#default_value' => $this->settings['file_directory'],
    '#description' => t('Optional subdirectory within the s3 bucket where files will be stored. Do not include preceding or trailing slashes.'),
    '#element_validate' => array(
      array(
        $this,
        'file_directory_validate',
      ),
    ),
    '#weight' => 25,
  );
  $form['s3_advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 50,
  );
  $form['s3_advanced']['s3_timeout'] = array(
    '#type' => 'textfield',
    '#title' => t('Timeout'),
    '#default_value' => $this->settings['s3_timeout'],
    '#description' => t('Optional timeout for S3 requests, useful if you are getting timeout exceptions. If empty, the internal default is used, which is normally PHP configuration <em>default_socket_timeout</em>, which is currently set to %value seconds.', array(
      '%value' => ini_get('default_socket_timeout'),
    )),
    '#element_validate' => array(
      array(
        $this,
        'numeric_validate',
      ),
    ),
  );
  $form['s3_advanced']['s3_min_part_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum part size'),
    '#default_value' => $this->settings['s3_min_part_size'],
    '#description' => t('Minimum size to allow for each uploaded part when performing a multipart upload, in MegaBytes.'),
    '#element_validate' => array(
      array(
        $this,
        'numeric_validate',
      ),
    ),
  );
  $form['s3_advanced']['s3_proxy'] = array(
    '#type' => 'textfield',
    '#title' => t('Proxy'),
    '#default_value' => $this->settings['s3_proxy'],
    '#description' => t('Optional proxy to pass through to the S3 Client library. It should be specified in the <em><b>HOST:PORT</b></em> format.'),
  );
  $class = new ReflectionClass("Aws\\Common\\Enum\\ClientOptions");
  if (!$class
    ->hasConstant('BACKOFF_RETRIES')) {
    $s3_retries_description = t('<b>The aws-sdk-php library needs to be modified as per <a href="!github">!github</a></b>. A patch is included in the module.', array(
      '!github' => 'https://github.com/aws/aws-sdk-php/pull/1012',
    ));
    $s3_retries_disabled = TRUE;
  }
  else {
    $s3_retries_description = t('<b>The aws-sdk-php library seems properly modified as per <a href="!github">!github</a></b>.', array(
      '!github' => 'https://github.com/aws/aws-sdk-php/pull/1012',
    ));
    $s3_retries_disabled = FALSE;
  }
  $form['s3_advanced']['s3_retries'] = array(
    '#type' => 'textfield',
    '#title' => t('Max retries'),
    '#default_value' => $this->settings['s3_retries'],
    '#description' => t('Optional maximum retries to perform on certain AWS errors. ' . $s3_retries_description),
    "#disabled" => $s3_retries_disabled,
  );
  $form['s3_advanced']['s3_debug'] = array(
    '#type' => 'checkbox',
    '#title' => t('Debug'),
    '#default_value' => $this->settings['s3_debug'],
    '#description' => t('If checked, a temporary debug log will be store in %path containing all http requests/responses with its data, prefixed with "backup_migrate_s3_". <b>Use with caution, sensitive data could be saved.</b>', array(
      '%path' => drupal_realpath('temporary://'),
    )),
  );
  return $form;
}