You are here

function pm_block_user_form 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()
  2. 7.2 pm_block_user/pm_block_user.pages.inc \pm_block_user_form()
  3. 7 pm_block_user/pm_block_user.pages.inc \pm_block_user_form()
1 string reference to 'pm_block_user_form'
pm_block_user_menu in pm_block_user/pm_block_user.module
Implements hook_menu().

File

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

Code

function pm_block_user_form($form_state, $author) {
  global $user;
  $form['author'] = array(
    '#type' => 'value',
    '#value' => $author->uid,
  );
  $form['recipient'] = array(
    '#type' => 'value',
    '#value' => $user->uid,
  );
  $form['author_name'] = array(
    '#type' => 'value',
    '#value' => $author->name,
  );
  $form['destination'] = array(
    '#type' => 'value',
    '#value' => isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
  );
  if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) {
    $form['block_action'] = array(
      '#type' => 'value',
      '#value' => 'unblock_user',
    );
    return confirm_form($form, t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array(
      '@author' => $author->name,
    )), isset($_GET['destination']) ? $_GET['destination'] : 'messages/', t('This action cannot be undone.'), t('Unblock @author', array(
      '@author' => $author->name,
    )), t('Cancel'));
  }
  else {
    $form['block_action'] = array(
      '#type' => 'value',
      '#value' => 'block_user',
    );
    return confirm_form($form, t('Are you sure you want to block "@author" from sending you any more messages?', array(
      '@author' => $author->name,
    )), isset($_GET['destination']) ? $_GET['destination'] : 'messages/', '', t('Block @author', array(
      '@author' => $author->name,
    )), t('Cancel'));
  }
}