You are here

function shoutbox_delete_form_submit in Shoutbox 5

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

Handle the delete form submission.

Parameters

$form_id: The form ID of the form.

$form_values: Form values.

File

./shoutbox.module, line 772
shoutbox module displays a block for users to create short messages for thw whole site. Uses AHAH to update the database and display content.

Code

function shoutbox_delete_form_submit($form_id, $form_values) {
  if (is_numeric($form_values['shout_id'])) {
    $result = db_query("SELECT * FROM {shoutbox} WHERE shout_id = %d", $form_values['shout_id']);
    if ($shout = db_fetch_object($result)) {
      if (_shoutbox_user_access('delete own shouts', $shout)) {
        db_query("DELETE FROM {shoutbox} WHERE shout_id =%d", $form_values['shout_id']);
        drupal_set_message(t('Your shout was deleted.'));
      }
      else {
        drupal_set_message(t('You do not have permission to delete this post.'));
      }
    }
    else {
      $message = t('Invalid shout ID: %shout', array(
        '%shout' => $form_values['shout_id'],
      ));
      drupal_set_message($message);
    }
  }
  else {
    return drupal_not_found();
  }
  drupal_goto('');
}