You are here

function backup_migrate_schedule::edit_form in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 8.2 includes/schedules.inc \backup_migrate_schedule::edit_form()
  2. 6.3 includes/schedules.inc \backup_migrate_schedule::edit_form()
  3. 6.2 includes/schedules.inc \backup_migrate_schedule::edit_form()
  4. 7.3 includes/schedules.inc \backup_migrate_schedule::edit_form()
  5. 7.2 includes/schedules.inc \backup_migrate_schedule::edit_form()

Get the edit form.

Overrides backup_migrate_item::edit_form

File

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

Class

backup_migrate_schedule
A schedule class for crud operations.

Code

function edit_form() {
  $form = parent::edit_form();
  backup_migrate_include('destinations', 'sources', 'profiles');
  $form['name'] = array(
    "#type" => "textfield",
    "#title" => t("Schedule Name"),
    "#default_value" => $this
      ->get('name'),
  );
  $form += _backup_migrate_get_source_form($this
    ->get('source_id'));
  $form['profile_id'] = array(
    "#type" => "select",
    "#title" => t("Settings Profile"),
    "#options" => _backup_migrate_get_profile_form_item_options(),
    "#default_value" => $this
      ->get('profile_id'),
  );
  $form['profile_id']['#description'] = ' ' . l(t('Create new profile'), BACKUP_MIGRATE_MENU_PATH . '/settings/profile/add');
  if (!$form['profile_id']['#options']) {
    $form['profile_id']['#options'] = array(
      '0' => t('-- None Available --'),
    );
  }
  $period_options = array();
  foreach ($this
    ->frequency_periods() as $type => $period) {
    $period_options[$type] = $period['title'];
  }
  $default_period = $this
    ->get_frequency_period();
  $default_period_num = $this
    ->get('period') / $default_period['seconds'];
  $form['enabled'] = array(
    '#type' => "checkbox",
    '#title' => t('Enabled'),
    '#default_value' => $this
      ->get('enabled'),
  );
  $form['cron_settings'] = array(
    '#type' => 'backup_migrate_dependent',
    '#dependencies' => array(
      'enabled' => TRUE,
    ),
  );
  $cron = $this
    ->get('cron');
  $form['cron_settings']['cron_builtin'] = array(
    "#type" => "radio",
    "#title" => t('Run using Drupal\'s cron'),
    '#return_value' => BACKUP_MIGRATE_CRON_BUILTIN,
    "#description" => t('Run this schedule when !cron runs.', array(
      '!cron' => l(t('your cron task'), 'http://drupal.org/cron'),
    )),
    "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
    '#parents' => array(
      'cron',
    ),
  );
  $form['cron_settings']['period_settings'] = array(
    '#type' => 'backup_migrate_dependent',
    '#dependencies' => array(
      'cron' => BACKUP_MIGRATE_CRON_BUILTIN,
    ),
  );
  $form['cron_settings']['period_settings']['period'] = array(
    "#type" => "item",
    "#title" => t("Backup every"),
    "#prefix" => '<div class="container-inline">',
    "#suffix" => '</div>',
    "#tree" => TRUE,
    '#parents' => array(
      'period',
    ),
  );
  $form['cron_settings']['period_settings']['period']['number'] = array(
    "#type" => "textfield",
    "#size" => 6,
    "#default_value" => $default_period_num,
    '#parents' => array(
      'period',
      'number',
    ),
  );
  $form['cron_settings']['period_settings']['period']['type'] = array(
    "#type" => "select",
    "#options" => $period_options,
    "#default_value" => $default_period['type'],
    '#parents' => array(
      'period',
      'type',
    ),
  );
  $form['cron_settings']['cron_elysia'] = array(
    "#type" => "radio",
    "#title" => t('Run using Elysia cron'),
    '#return_value' => BACKUP_MIGRATE_CRON_ELYSIA,
    "#description" => t('You can specify exactly when this schedule should run using !elysia.', array(
      '!elysia' => l(t('the Elysia Cron module'), 'http://drupal.org/project/elysia_cron'),
    )),
    "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
    '#parents' => array(
      'cron',
    ),
  );
  if (!module_exists('elysia_cron')) {
    $form['cron_settings']['cron_elysia']['#disabled'] = TRUE;
    $form['cron_settings']['cron_elysia']['#description'] .= ' ' . t('Install !elysia to enable this option.', array(
      '!elysia' => l(t('Elysia Cron'), 'http://drupal.org/project/elysia_cron'),
    ));
  }
  $form['cron_settings']['cron_schedule_settings'] = array(
    '#type' => 'backup_migrate_dependent',
    '#dependencies' => array(
      'cron' => BACKUP_MIGRATE_CRON_ELYSIA,
    ),
  );
  $form['cron_settings']['cron_schedule_settings']['cron_schedule'] = array(
    "#type" => "textfield",
    "#title" => t('Cron Schedule'),
    '#length' => 10,
    "#description" => t('Specify the frequecy of the schedule using standard cron notation. For more information see the !elysiareadme.', array(
      '!elysiareadme' => l(t('the Elysia Cron README'), 'http://drupalcode.org/project/elysia_cron.git/blob/refs/heads/7.x-1.x:/README.txt'),
    )),
    "#default_value" => $this
      ->get('cron_schedule'),
    '#parents' => array(
      'cron_schedule',
    ),
  );
  $form['cron_settings']['cron_none'] = array(
    "#type" => "radio",
    "#title" => t('Do not run automatically'),
    '#return_value' => 'none',
    "#description" => t('Do not run this schedule automatically. You can still run it using !drush.', array(
      '!drush' => l(t('Drush'), 'http://drupal.org/project/drush'),
    )),
    "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
    '#parents' => array(
      'cron',
    ),
  );
  $keep = $this
    ->get('keep');
  $form['delete'] = array(
    '#type' => 'checkbox',
    '#default_value' => $keep != 0,
    '#title' => t('Automatically delete old backups'),
  );
  $form['delete_settings'] = array(
    '#type' => 'backup_migrate_dependent',
    '#dependencies' => array(
      'delete' => TRUE,
    ),
  );
  $keep_hourly = variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY);
  $keep_daily = variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY);
  $keep_weekly = variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY);
  $form['delete_settings']['smartdelete'] = array(
    "#type" => "radio",
    "#title" => t('Smart Delete'),
    '#return_value' => BACKUP_MIGRATE_SMART_DELETE,
    "#description" => t('Keep !keep. <strong>Recommended</strong>', array(
      '!keep' => $this
        ->generate_keep_description(BACKUP_MIGRATE_SMART_DELETE, FALSE),
    )),
    "#default_value" => $keep ? $keep : BACKUP_MIGRATE_SMART_DELETE,
    '#parents' => array(
      'deletetype',
    ),
  );
  $form['delete_settings']['standarddelete'] = array(
    "#type" => "radio",
    "#title" => t('Simple Delete'),
    '#return_value' => BACKUP_MIGRATE_STANDARD_DELETE,
    "#description" => t("Keep a specified number of files deleting the oldest ones first."),
    "#default_value" => $keep > 0 ? BACKUP_MIGRATE_STANDARD_DELETE : 0,
    '#parents' => array(
      'deletetype',
    ),
  );
  $form['delete_settings']['keep-settings'] = array(
    '#type' => 'backup_migrate_dependent',
    '#dependencies' => array(
      'deletetype' => BACKUP_MIGRATE_STANDARD_DELETE,
    ),
  );
  $form['delete_settings']['keep-settings']['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."),
    "#default_value" => $keep > 0 ? $keep : BACKUP_MIGRATE_KEEP_DEFAULT,
  );
  $form['destination'] = _backup_migrate_get_destination_pulldown('scheduled backup', $this
    ->get('destination_id'), $this
    ->get('copy_destination_id'));
  return $form;
}