function pm_block_user_privatemsg_message_view_alter

1 pm_block_user.module pm_block_user_privatemsg_message_view_alter(&$vars)
7-1 pm_block_user.module pm_block_user_privatemsg_message_view_alter(&$vars)
7-2 pm_block_user.module pm_block_user_privatemsg_message_view_alter(&$vars)
6-2 pm_block_user.module pm_block_user_privatemsg_message_view_alter(&$vars)

Implements hook_privatemsg_message_view_alter.

File

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

Code

function pm_block_user_privatemsg_message_view_alter(&$vars) {
  global $user;

  // @todo: weird, figure out why it is below #message.
  $author = $vars['message']->author;
  if (_pm_block_user_rule_exists($author, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
    return;
  }
  if (!isset($vars['message']->thread_id)) {
    // No thread id, this is probably only a preview
    return;
  }
  $thread_id = $vars['message']->thread_id;

  if ($user->uid <> $author->uid) {
    if ($vars['message']->is_blocked) {
      $vars['message_actions']['unblock_author'] = array(
        'title' => t('Unblock'),
        'href' => 'messages/block/' . $author->uid,
        'query' => array('destination' => 'messages/view/' . $thread_id),
      );
    }
    else {
      $vars['message_actions']['block_author'] = array(
        'title' => t('Block'),
        'href' => 'messages/block/' . $author->uid,
        'query' => array('destination' => 'messages/view/' . $thread_id),
      );
    }
  }
}