You are here

public function backup_migrate_schedule::edit_form_validate in Backup and Migrate 7.3

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

Submit the edit form.

Overrides backup_migrate_item::edit_form_validate

File

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

Class

backup_migrate_schedule
A schedule class for crud operations.

Code

public function edit_form_validate($form, &$form_state) {
  if (!is_numeric($form_state['values']['period']['number']) || $form_state['values']['period']['number'] <= 0) {
    form_set_error('period][number', t('Backup period must be a number greater than 0.'));
  }
  if (!$form_state['values']['delete']) {
    $form_state['values']['keep'] = 0;
  }
  elseif ($form_state['values']['deletetype'] == BACKUP_MIGRATE_SMART_DELETE) {
    $form_state['values']['keep'] = BACKUP_MIGRATE_SMART_DELETE;
    if (!is_numeric($form_state['values']['keep_hourly']) || $form_state['values']['keep_hourly'] < 0) {
      form_set_error('keep_hourly', t('Number to keep hourly must be an integer greater than or equal to 0.'));
    }
    elseif (!is_numeric($form_state['values']['keep_daily']) || $form_state['values']['keep_daily'] < 0) {
      form_set_error('keep_daily', t('Number to keep daily must be an integer greater than or equal to 0.'));
    }
    elseif (!is_numeric($form_state['values']['keep_weekly']) || $form_state['values']['keep_weekly'] < 0) {
      form_set_error('keep_weekly', t('Number to keep weekly must be an integer greater than or equal to 0.'));
    }
  }
  elseif (!is_numeric($form_state['values']['keep']) || $form_state['values']['keep'] <= 0) {
    form_set_error('keep', t('Number to keep must be a number greater than 0.'));
  }
  parent::edit_form_validate($form, $form_state);
}