You are here

function shoutbox_edit_form_submit in Shoutbox 6.2

Same name and namespace in other branches
  1. 5 shoutbox.module \shoutbox_edit_form_submit()
  2. 6 shoutbox.module \shoutbox_edit_form_submit()
  3. 7.2 shoutbox.pages.inc \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 359
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
    $shout = shoutbox_load($form_state['values']['shout_id']);

    // Edit the shout object
    $shout->shout = $form_state['values']['shout'];
    $shout->moderate = $form_state['values']['moderate'];
    $shout->changed = time();

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

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