You are here

function pm_block_user_form_submit in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 pm_block_user/pm_block_user.pages.inc \pm_block_user_form_submit()
  2. 7.2 pm_block_user/pm_block_user.pages.inc \pm_block_user_form_submit()
  3. 7 pm_block_user/pm_block_user.pages.inc \pm_block_user_form_submit()

Implements hook_form_submit().

File

pm_block_user/pm_block_user.module, line 485
Allows users to block other users from sending them any messages

Code

function pm_block_user_form_submit($form, &$form_state) {
  if ($form_state['values']['confirm']) {
    switch ($form_state['values']['block_action']) {
      case 'block_user':
        db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']);
        drupal_set_message(t('@author has been blocked from sending you any further messages.', array(
          '@author' => $form_state['values']['author_name'],
        )));
        break;
      case 'unblock_user':
        db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']);
        drupal_set_message(t('@author is now allowed to send you new messages.', array(
          '@author' => $form_state['values']['author_name'],
        )));
        break;
    }
  }
  $form_state['redirect'] = $form_state['values']['destination'];
}