You are here

function backup_migrate_destination_save_destination in Backup and Migrate 5.2

Save an existing destination, or create a new one with the given values.

1 call to backup_migrate_destination_save_destination()
backup_migrate_ui_destination_configure_form_submit in includes/destinations.inc
Submit the destination configuration form.

File

includes/destinations.inc, line 274
All of the destination handling code needed for Backup and Migrate.

Code

function backup_migrate_destination_save_destination(&$destination) {

  // Any extra settings get serialized into the settings variable.
  $settings = serialize($destination['settings']);
  if ($destination['destination_id']) {
    db_query("UPDATE {backup_migrate_destinations}\n                 SET  name = '%s',\n                      type = '%s',\n                      location = '%s',\n                      username = '%s',\n                      password = '%s',\n                      settings = '%s'\n               WHERE destination_id = %d", $destination['name'], $destination['type'], $destination['location'], $destination['username'], $destination['password'], $settings, $destination['destination_id']);
    _backup_migrate_message('Backup destination updated: %dest', array(
      '%dest' => $destination['name'],
    ));
  }
  else {
    $destination['destination_id'] = db_next_id('{backup_migrate_destinations}_destination_id');
    db_query("INSERT INTO {backup_migrate_destinations} (name, type , location, username, password, settings, destination_id) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %d)", $destination['name'], $destination['type'], $destination['location'], $destination['username'], $destination['password'], $settings, $destination['destination_id']);
    _backup_migrate_message('Backup destination created: %dest', array(
      '%dest' => $destination['name'],
    ));
  }
}