You are here

function privatemsg_privatemsg_block_message in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg.module \privatemsg_privatemsg_block_message()
  2. 7.2 privatemsg.module \privatemsg_privatemsg_block_message()

Implements hook_privatemsg_block_message().

File

./privatemsg.module, line 1427
Allows users to send private messages to other users.

Code

function privatemsg_privatemsg_block_message($author, $recipients, $context = array()) {
  $blocked = array();
  if (privatemsg_is_disabled($author)) {
    $blocked[] = array(
      'recipient' => 'user_' . $author->uid,
      'message' => t('You have disabled private message sending and receiving.'),
    );
  }
  foreach ($recipients as $recipient) {
    if (privatemsg_is_disabled($recipient)) {
      $blocked[] = array(
        'recipient' => 'user_' . $recipient->uid,
        'message' => t('%recipient has disabled private message receiving.', array(
          '%recipient' => privatemsg_recipient_format($recipient, array(
            'plain' => TRUE,
          )),
        )),
      );
    }
    else {
      if (isset($recipient->status) && !$recipient->status) {
        $blocked[] = array(
          'recipient' => 'user_' . $recipient->uid,
          'message' => t('%recipient has disabled his or her account.', array(
            '%recipient' => privatemsg_recipient_format($recipient, array(
              'plain' => TRUE,
            )),
          )),
        );
      }
    }
  }
  return $blocked;
}