You are here

function shoutbox_edit_form_submit in Shoutbox 7.2

Same name and namespace in other branches
  1. 5 shoutbox.module \shoutbox_edit_form_submit()
  2. 6.2 shoutbox.pages.inc \shoutbox_edit_form_submit()
  3. 6 shoutbox.module \shoutbox_edit_form_submit()
  4. 7 shoutbox.pages.inc \shoutbox_edit_form_submit()

Handle the edit form submission.

Parameters

$form_id: The form ID of the form.

$form_values: Form values.

File

./shoutbox.pages.inc, line 467
Page callbacks for the shoutbox module.

Code

function shoutbox_edit_form_submit($form, &$form_state) {

  // if (is_numeric($form_state['values']['shout_id'])) {
  // Load the existing shout if shout id is valid.
  $shout = shoutbox_shout_load($form_state['values']['shout_id']);
  if ($shout) {

    // Edit the shout object.
    $shout->shout = $form_state['values']['shout'];
    if (isset($form_state['values']['moderate'])) {
      $shout->moderate = $form_state['values']['moderate'];
    }
    $shout->changed = REQUEST_TIME;

    // Alert other modules about the update.
    $a1 = NULL;
    shoutbox_invoke('edit', $shout, $a1, $form_state);

    // Update the shout.
    // TODO Please review the conversion of this statement to the D7 database API syntax.

    /* db_query("UPDATE {shoutbox} SET shout = '%s', moderate = %d, changed = %d WHERE shout_id = %d", $shout->shout, $shout->moderate, $shout->changed, $shout->shout_id) */
    db_update('shoutbox')
      ->fields(array(
      'shout' => $shout->shout,
      'moderate' => $shout->moderate,
      'changed' => $shout->changed,
    ))
      ->condition('shout_id', $shout->shout_id)
      ->execute();
    drupal_set_message(t('Your ' . DEFAULTSHOUTSINGULAR . ' has been saved.'));
    $form_state['redirect'] = '';
  }
  else {
    return drupal_not_found();
  }
}