You are here

function backup_migrate_ui_schedule_configure_form in Backup and Migrate 5.2

Get a form to configure the schedule.

2 string references to 'backup_migrate_ui_schedule_configure_form'
backup_migrate_ui_schedule_configure in includes/schedules.inc
Get a form to configure the schedule.
backup_migrate_ui_schedule_create in includes/schedules.inc
Get a form to create a new schedule.

File

includes/schedules.inc, line 196
All of the schedule handling code needed for Backup and Migrate.

Code

function backup_migrate_ui_schedule_configure_form($schedule) {
  if ($schedule) {
    require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/destinations.inc';
    require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/profiles.inc';
    $form = array();
    $form['schedule_id'] = array(
      "#type" => "value",
      "#default_value" => $schedule['schedule_id'],
    );
    $form['enabled'] = array(
      "#type" => "checkbox",
      "#title" => t("Enabled"),
      "#field_suffix" => t("Hour(s)"),
      "#default_value" => $schedule['enabled'],
    );
    $form['name'] = array(
      "#type" => "textfield",
      "#title" => t("Schedule Name"),
      "#default_value" => $schedule['name'],
    );
    $form['profile_id'] = array(
      "#type" => "select",
      "#title" => t("Settings Profile"),
      "#options" => _backup_migrate_get_profile_form_item_options(),
      "#default_value" => $schedule['profile_id'],
    );
    $form['profile_id']['#description'] .= ' ' . l(t("Create new profile..."), "admin/content/backup_migrate/profile/add");
    if (!$form['profile_id']['#options']) {
      $form['profile_id']['#options'] = array(
        '0' => t('-- None Available --'),
      );
    }
    $period_options = array();
    foreach (_backup_migrate_frequency_periods() as $type => $period) {
      $period_options[$type] = $period['title'];
    }
    $default_period = _backup_migrate_schedule_get_frequency_period($schedule['period']);
    $default_period_num = $schedule['period'] / $default_period['seconds'];
    $form['period'] = array(
      "#type" => "item",
      "#title" => t("Backup every"),
      "#prefix" => '<div class="container-inline">',
      "#suffix" => '</div>',
      "#tree" => TRUE,
    );
    $form['period']['number'] = array(
      "#type" => "textfield",
      "#size" => 6,
      "#default_value" => $default_period_num,
    );
    $form['period']['type'] = array(
      "#type" => "select",
      "#options" => $period_options,
      "#default_value" => $default_period['type'],
    );
    $form['keep'] = array(
      "#type" => "textfield",
      "#size" => 6,
      "#title" => t("Number of Backup files to keep"),
      "#description" => t("The number of backup files to keep before deleting old ones. Use 0 to never delete backups"),
      "#default_value" => $schedule['keep'],
    );
    $destination_options = _backup_migrate_get_destination_form_item_options('scheduled backup');
    $form['destination_id'] = array(
      "#type" => "select",
      "#title" => t("Destination"),
      "#description" => t("Choose where the backup file will be saved. Backup files contain sensitive data, so be careful where you save them."),
      "#options" => $destination_options,
      "#default_value" => $schedule['destination_id'],
    );
    $form['destination_id']['#description'] .= ' ' . l(t("Create new destination..."), "admin/content/backup_migrate/destination/add");
    $form['submit'] = array(
      '#type' => 'submit',
      '#weight' => 99,
      '#value' => t('Save Schedule'),
    );
    return $form;
  }
  return array();
}