You are here

function backup_migrate_ui_manual_backup_form in Backup and Migrate 7.3

Same name and namespace in other branches
  1. 8.2 backup_migrate.module \backup_migrate_ui_manual_backup_form()
  2. 8.3 backup_migrate.module \backup_migrate_ui_manual_backup_form()
  3. 5.2 backup_migrate.module \backup_migrate_ui_manual_backup_form()
  4. 6.3 backup_migrate.module \backup_migrate_ui_manual_backup_form()
  5. 6.2 backup_migrate.module \backup_migrate_ui_manual_backup_form()
  6. 7.2 backup_migrate.module \backup_migrate_ui_manual_backup_form()

The backup/export form.

1 string reference to 'backup_migrate_ui_manual_backup_form'
backup_migrate_ui_manual_backup_advanced in ./backup_migrate.module
The menu callback for advanced manual backups.

File

./backup_migrate.module, line 1071
Backup and restore databases for Drupal.

Code

function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
  drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js', array(
    'type' => 'module',
    'scope' => 'footer',
  ));
  $form = array();
  $form += _backup_migrate_get_source_form('db');
  $form_state['profile'] = $profile;
  $form['machine_name'] = array(
    "#type" => "value",
    '#default_value' => $profile
      ->get_id(),
  );
  $form['storage'] = array(
    "#type" => "value",
    '#default_value' => $profile->storage,
  );
  $form['destination'] = array(
    "#type" => "fieldset",
    "#title" => t("Backup Destination"),
    "#collapsible" => TRUE,
    "#collapsed" => FALSE,
    "#tree" => FALSE,
    "#description" => t("Choose where the backup file will be saved. Backup files contain sensitive data, so be careful where you save them. Select 'Download' to download the file to your desktop."),
  );
  $form['destination']['destination'] = _backup_migrate_get_destination_pulldown('manual backup', variable_get('backup_migrate_destination_id', 'download'));
  $form += _backup_migrate_ui_backup_settings_form($profile);

  // Make the source settings dependent on the source selected. Except don't
  // because it looks super weird.
  // @code
  // foreach (element_children($form['sources']) as $source) {
  //   $form['sources'][$source] = array(
  //     '#type' => 'backup_migrate_dependent',
  //     '#dependencies' => array(
  //       'source_id' => $source,
  //     ),
  //     'settings' => $form['sources'][$source]
  //   );
  // }
  // @endcode
  if (user_access('administer backup and migrate')) {
    $form['save_settings'] = array(
      "#type" => "checkbox",
      "#title" => t('Save these settings.'),
      "#default_value" => FALSE,
      '#weight' => 80,
    );
    $form['save_options'] = array(
      '#type' => 'backup_migrate_dependent',
      '#dependencies' => array(
        'save_settings' => TRUE,
      ),
      '#weight' => 90,
    );
    $name = array(
      '#default_value' => $profile
        ->get('name'),
      '#type' => 'textfield',
      '#title' => t('Save the settings as'),
    );
    if ($profile
      ->get_id()) {
      $form['save_options']['create_new'] = array(
        '#default_value' => $profile
          ->get('name'),
        '#type' => 'radios',
        '#default_value' => 0,
        '#options' => array(
          0 => t("Replace the '%profile' profile", array(
            '%profile' => $profile
              ->get('name'),
          )),
          1 => t('Create new profile'),
        ),
      );
      $name["#title"] = t('Profile name');
      $name["#description"] = t("This will be the name of your new profile if you select 'Create new profile' otherwise it will become the name of the '%profile' profile.", array(
        '%profile' => $profile
          ->get('name'),
      ));
    }
    else {
      $name["#title"] = t('Save the settings as');
      $name["#description"] = t('Pick a name for the settings. Your settings will be saved as a profile and will appear in the <a href="!url">Profiles Tab</a>.', array(
        '!url' => url(BACKUP_MIGRATE_MENU_PATH . '/profile'),
      ));
      $name["#default_value"] = t('Untitled Profile');
    }
    $form['save_options']['name'] = $name;
    $form['save_options'][] = array(
      '#type' => 'submit',
      '#value' => t('Save Without Backing Up'),
    );
  }
  $form['#validate'][] = 'backup_migrate_ui_manual_quick_backup_form_validate';
  $form['#submit'][] = 'backup_migrate_ui_manual_backup_form_submit';
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Backup now'),
    '#weight' => 100,
  );
  return _backup_migrate_ui_action_form($form, $form_state, 'backup');
}