You are here

function mail_edit_trans_save in Mail Editor 6

1 string reference to 'mail_edit_trans_save'
mail_edit_trans in ./mail_edit.admin.inc

File

./mail_edit.admin.inc, line 457
Administrative interface for the Mail Editor module.

Code

function mail_edit_trans_save($form, &$form_state) {
  $update = $form_state['values']['update'];
  if ($update) {

    // Do update.
    $query = "\n      UPDATE {mail_edit} SET\n        description = '%s',\n        subject     = '%s',\n        body        = '%s'\n      WHERE\n        id     = '%s' AND\n        language    = '%s'\n    ";
    $values = $form_state['values'];
    $args[] = $values['description'];
    $args[] = $values['subject'];
    $args[] = $values['body'];
    $args[] = $values['id'];
    $args[] = $values['language'];
    if (db_query($query, $args)) {
    }
    else {
      drupal_set_message(t('Failed to save template for %id for the %language translation', array(
        '%id' => $values['id'],
        '%language' => $values['language'],
      )));
    }
  }
  else {

    // Do insert.
    $query = "INSERT INTO {mail_edit} (description, subject, id, body, language) VALUES (\n      '%s',\n      '%s',\n      '%s',\n      '%s',\n      '%s'\n    ) ";
    $values = $form_state['values'];
    $args[] = $values['description'];
    $args[] = $values['subject'];
    $args[] = $values['id'];
    $args[] = $values['body'];
    $args[] = $values['language'];
    if (!db_query($query, $args)) {
      drupal_set_message(t('Failed to save template for %id for the %language translation', array(
        '%id' => $values['id'],
        '%language' => $values['language'],
      )));
    }
  }
  $form_state['redirect'] = 'admin/build/mail-edit';
}