function privatemsg_limits_privatemsg_block_message in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg_limits/privatemsg_limits.module \privatemsg_limits_privatemsg_block_message()
- 7 privatemsg_limits/privatemsg_limits.module \privatemsg_limits_privatemsg_block_message()
Implements hook_privatemsg_block_message().
File
- privatemsg_limits/
privatemsg_limits.module, line 111 - Privatemsg Quota module
Code
function privatemsg_limits_privatemsg_block_message($author, $recipients, $context = array()) {
if (variable_get('privatemsg_limits_receive_enabled', FALSE) && (empty($context['thread_id']) || variable_get('privatemsg_limits_receive_object', 'message') == 'message')) {
$blocked = array();
// Users that have the by-pass permission can send messages even if the
// mailbox of the recipient is full.
if (user_access('bypass recipient message limit', $author)) {
return $blocked;
}
foreach ($recipients as $recipient) {
// Only user recipients are supported.
if (!isset($recipient->type) || $recipient->type == 'user' || $recipient->type == 'hidden') {
$amount = _privatemsg_limits_get_amount('receive_amount', $recipient);
$used = _privatemsg_limits_get_received($recipient);
if ($amount > 0 && $used >= $amount) {
$blocked[] = array(
'recipient' => privatemsg_recipient_key($recipient),
'message' => t("This message cannot be sent to !name because !name's mailbox is full.", array(
'!name' => theme('username', $recipient),
)),
);
}
}
}
return $blocked;
}
}