You are here

function shoutbox_delete_form_submit in Shoutbox 6

Same name and namespace in other branches
  1. 5 shoutbox.module \shoutbox_delete_form_submit()
  2. 6.2 shoutbox.pages.inc \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.

File

./shoutbox.module, line 733
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, &$form_state) {
  $form_state['redirect'] = '';
  if ($form_state['clicked_button']['#value'] == t('Confirm')) {
    if (is_numeric($form_state['values']['shout_id'])) {
      $result = db_query("SELECT * FROM {shoutbox} WHERE shout_id = %d", $form_state['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_state['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 {
        return drupal_not_found();
      }
    }
  }
}