function backup_migrate_destination_dropbox::edit_form in Backup and Migrate Dropbox 7.2
Same name and namespace in other branches
- 6.2 destinations.dropbox.inc \backup_migrate_destination_dropbox::edit_form()
- 6 destinations.dropbox.inc \backup_migrate_destination_dropbox::edit_form()
- 7.3 destinations.dropbox.inc \backup_migrate_destination_dropbox::edit_form()
- 7 destinations.dropbox.inc \backup_migrate_destination_dropbox::edit_form()
Get the form for the settings for this filter.
File
- ./
destinations.dropbox.inc, line 156 - destinations.dropbox.inc
Class
- backup_migrate_destination_dropbox
- A destination for sending database backups to a Dropbox account.
Code
function edit_form() {
$form = parent::edit_form();
$summary = t('Defining a Dropbox destination ...');
$dropboxHeader = t('Dropbox part:');
$dropboxList = t('<ol><li>Create or Login to your Dropbox account.</li>
<li>Go to <a href="https://www.dropbox.com/developers" target="_blank">https://www.dropbox.com/developers</a>.</li>
<li>Click on the “Create apps” button.</li>
<li>Select “Dropbox API”.</li>
<li>Select “App folder”. This will protect the rest of your Dropbox in case your site is compromised.</li>
<li>Enter an app name and create it. Note that the app name must be globally unique, so you may have to retry it a few times. Using your website name may help.</li>
<li>Set “Allow implicit grant” to “Disallow”.</li>
<li>Click op “Generate” below “Generated access token”.</li>
<li>Copy the token to your clipboard.</li>
</ol>');
$drupalHeader = t('Drupal part:');
$drupalList = t('<ol><li>Go to “Configuration - System - Backup and Migrate - Settings - Destinations - Add destination” (this page).</li>
<li>Select “Dropbox” from the off-site destinations list.</li>
<li>Fill in a “Destination name”.</li>
<li>Optionally fill in the name of a subdirectory to place the backups to this destination in. E.g. use this if you have multiple destinations for this site (daily, weekly, ...) or multiple sites that backup to this app (mysite1, mysite2/daily, mysite2/weekly, ...). Upon saving, the module will create the subdirectory in your Dropbox folder.</li>
<li>Paste the token into the “Dropbox Access Token” field.</li>
<li>Click on “Save destination”.</li>
<li>Test if everything works fine by doing a manual backup to the newly created destination.</li>
</ol>');
$form['description'] = array(
'#type' => 'markup',
'#weight' => -999,
'#markup' => "<details open style='border:1px solid #ccc;border-top-color:#999;padding:0.3em;margin-bottom:1em;'><summary style='font-size:larger;font-weight:bold;cursor:pointer;'>{$summary}</summary>\n<h3>{$dropboxHeader}</h3>\n{$dropboxList}\n<h3>{$drupalHeader}</h3>\n{$drupalList}</details>",
);
$form['name']['#description'] = t('Enter a "friendly" name for this destination. Only appears as a descriptor in the Backup and Migrate administration screens.');
$form['scheme'] = array(
'#type' => 'value',
'#value' => 'https',
);
$form['host'] = array(
'#type' => 'value',
'#value' => 'www.dropbox.com',
);
$form['path']['#description'] = t('A relative folder inside your Dropbox App folder. Upon saving, the module will create the path in your Dropbox App folder. You should not use slashes before or after the path. For example, you can use this if you have multiple destinations for this site (daily, weekly, ...) or multiple sites that backup to this account (mysite1, mysite2/daily, mysite2/weekly, ...).');
$form['path']['#required'] = FALSE;
$form['user'] = array(
'#type' => 'value',
'#value' => '',
);
$form['old_password'] = array(
'#type' => 'value',
'#value' => '',
);
$form['pass'] = array(
'#type' => 'value',
'#value' => '',
);
$form['settings']['token'] = array(
'#type' => 'textfield',
'#title' => 'Dropbox Access Token',
'#description' => 'Generated access token from your app. <b>Do not</b> use the secret key.',
'#required' => TRUE,
"#default_value" => $this
->settings('token'),
);
// How can we list the complete path to the Dropbox folder
// (https://www.dropbox.com/home/Apps/{App name}/path) on the destinations
// overview page? See
// https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/dropbox-programmatically-get-quot-app-folder-quot-path/td-p/201627
// Conclusion: only when we let the user fill in the App name, as we cannot
// retrieve it ourselves.
$destinations = url($this
->get_settings_path());
$form['settings']['app_name'] = array(
'#type' => 'textfield',
'#title' => 'Dropbox App name (optional)',
'#description' => "The name of the app. This is only used to show you a link to your Dropbox folder on the <a href='{$destinations}'>Backup and Migrate destinations list</a> page.",
'#required' => FALSE,
"#default_value" => $this
->settings('app_name'),
);
// Position the settings part on the form.
$form['settings']['#weight'] = 60;
return $form;
}