You are here

function spaces_preset_save in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \spaces_preset_save()
  2. 6.3 spaces.module \spaces_preset_save()
  3. 6.2 spaces_admin.inc \spaces_preset_save()
  4. 7.3 spaces.module \spaces_preset_save()
  5. 7 spaces.module \spaces_preset_save()

Saves a spaces preset.

Parameters

$type: The space type for this preset.

$id: The preset identifier string.

$values: An array of values that define the preset settings.

1 call to spaces_preset_save()
spaces_preset_form_submit in ./spaces_admin.inc
Submit handler for spaces preset form.

File

./spaces_admin.inc, line 355

Code

function spaces_preset_save($type, $id, $values) {
  $name = isset($values['name']) ? $values['name'] : '';
  $description = isset($values['description']) ? $values['description'] : '';
  unset($values['name']);
  unset($values['description']);
  $exists = db_result(db_query("SELECT count(id) FROM {spaces_presets} WHERE type = '%s' AND id = '%s'", $type, $id));
  $success = false;
  if ($exists) {
    $success = db_query("UPDATE {spaces_presets} SET name = '%s', description = '%s', value = '%s' WHERE type = '%s' AND id = '%s'", $name, $description, serialize($values), $type, $id);
  }
  else {
    $success = db_query("INSERT INTO {spaces_presets} (type, id, name, description, value) VALUES('%s', '%s', '%s', '%s', '%s')", $type, $id, $name, $description, serialize($values));
  }
  if ($success) {
    drupal_set_message(t('The preset !preset was saved successfully.', array(
      '!preset' => $id,
    )));
  }
  else {
    drupal_set_message(t('There was an error saving the preset !preset.', array(
      '!preset' => $id,
    )));
  }
}