You are here

function backup_migrate_schedule_save_schedule in Backup and Migrate 5.2

Update an existing schedule or create a new one.

2 calls to backup_migrate_schedule_save_schedule()
backup_migrate_ui_schedule_configure_form_submit in includes/schedules.inc
Submit the schedule configuration form.
_backup_migrate_setup_databaase_defaults in ./backup_migrate.install

File

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

Code

function backup_migrate_schedule_save_schedule(&$schedule) {

  // Calculate the period in seconds
  $periods = _backup_migrate_frequency_periods();
  $period = $periods[$schedule['period']['type']];
  $schedule['period'] = $schedule['period']['number'] * $period['seconds'];
  if ($schedule['schedule_id']) {
    db_query("UPDATE {backup_migrate_schedules} \n                 SET  name = '%s',\n                      destination_id = '%s',\n                      profile_id = %d,\n                      keep = %d,\n                      period = %d,\n                      enabled = %d\n               WHERE schedule_id = %d", $schedule['name'], $schedule['destination_id'], $schedule['profile_id'], $schedule['keep'], $schedule['period'], $schedule['enabled'], $schedule['schedule_id']);
  }
  else {
    $schedule['schedule_id'] = db_next_id('{backup_migrate_schedules}_schedule_id');
    db_query("INSERT INTO {backup_migrate_schedules} (schedule_id, name, destination_id, profile_id, keep, period, enabled) VALUES (%d, '%s', '%s', %d, %d, %d, %d)", $schedule['schedule_id'], $schedule['name'], $schedule['destination_id'], $schedule['profile_id'], $schedule['keep'], $schedule['period'], $schedule['enabled']);
  }
}