summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpm_block_user/pm_block_user.module13
1 files changed, 7 insertions, 6 deletions
diff --git a/pm_block_user/pm_block_user.module b/pm_block_user/pm_block_user.module
index f450a69..bf5458a 100755
--- a/pm_block_user/pm_block_user.module
+++ b/pm_block_user/pm_block_user.module
@@ -508,17 +508,18 @@ function pm_block_user_privatemsg_block_message($author, $recipients) {
// author from sending them private messages. Use a reference, so when
// user_load() is needed here the array is updated, negating the need for
// further calls to user_load() later in the code.
- foreach ($recipients as $uid => &$recipient) {
+ foreach (array_keys($recipients) as $uid) {
+
// Ensure we have a recipient user object which includes roles.
- if (!isset($recipient->roles)) {
- $recipient = user_load($uid);
+ if (!isset($recipients[$uid]->roles)) {
+ $recipients[$uid] = user_load($uid);
}
// Note: this is checks whether the author may send the message (see third
// parameter). Further below is a check whether the recipient may block it.
- if (_pm_block_user_rule_exists($author, $recipient, PM_BLOCK_USER_DISALLOW_SENDING)) {
+ if (_pm_block_user_rule_exists($author, $recipients[$uid], PM_BLOCK_USER_DISALLOW_SENDING)) {
$blocked[] = array(
- 'uid' => $recipient->uid,
- 'message' => t('Sorry, private messaging rules forbid sending messages to !name.', array('!name' => $recipient->name)),
+ 'uid' => $uid,
+ 'message' => t('Sorry, private messaging rules forbid sending messages to !name.', array('!name' => $recipients[$uid]->name)),
);
}
}