You are here

function signup_edit_form_save_submit in Signup 7

Same name and namespace in other branches
  1. 6.2 includes/signup_edit_form.inc \signup_edit_form_save_submit()
  2. 6 includes/signup_edit_form.inc \signup_edit_form_save_submit()

Submit callback when saving changes to an existing signup.

1 string reference to 'signup_edit_form_save_submit'
signup_edit_form in includes/signup_edit_form.inc
Build the form for editing existing signups.

File

includes/signup_edit_form.inc, line 142
Code for the form to edit existing signups.

Code

function signup_edit_form_save_submit($form, $form_state) {
  $signup = $form['#signup'];
  if (!empty($form_state['values']['signup_form_data'])) {
    $signup->form_data = $form_state['values']['signup_form_data'];
  }

  // If the form contains an e-mail address for an anonymous signup, save it.
  if (!empty($form_state['values']['signup_anon_mail'])) {
    $signup->anon_mail = $form_state['values']['signup_anon_mail'];
  }

  // If the form contains attendance info, save it.
  if (isset($form_state['values']['attended'])) {
    if ($form_state['values']['attended'] == -1) {
      unset($signup->attended);
    }
    else {
      $signup->attended = $form_state['values']['attended'];
    }
  }

  // Invoke hook_signup_data_alter() to let other modules change this.
  drupal_alter('signup_data', $signup, $form_state['values']);

  // Update the signup in the {signup_log} table.
  signup_save_signup($signup);

  // Because drupal_write_record() doesn't gracefully handle columns that can
  // be NULL, if the attendence was cleared out by this edit, we need to
  // manually set the DB record to NULL here.
  if (!isset($signup->attended)) {

    //db_query("UPDATE {signup_log} SET attended = NULL WHERE sid = %d", $signup->sid);
    db_update('signup_log')
      ->fields(array(
      'attended' => NULL,
    ))
      ->condition('sid', $signup->sid)
      ->execute();
  }
  drupal_set_message(t('Signup information updated.'));
}