Skip to content

Commit c83b0f6

Browse files
committed
Private message will not be shown to the recipient of that message #1299
1 parent f56e20f commit c83b0f6

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

adm_program/system/classes/TableMessage.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class TableMessage extends TableAccess
3333
* @var object of TableAcess for the current content of the message.
3434
*/
3535
protected $msgContentObject;
36+
/**
37+
* @var int ID the conversation partner of a private message. This is the recipient of the message from msg_usr_id_sender.
38+
*/
39+
protected $msgConversationPartnerId = 0;
3640

3741
/**
3842
* Constructor that will create an object of a recordset of the table adm_messages.
@@ -311,14 +315,23 @@ public function getConversation($msgId)
311315
}
312316

313317
/**
314-
* If the message type is PM this method will return the conversation partner of the PM.
315-
* @return int Returns **ID** of the user that is partner in the actual conversation or false if it's not a message.
318+
* If the message type is PM this method will return the conversation partner of the PM. This is the
319+
* recipient of the message send from **msg_usr_id_sender**.
320+
* @return int Returns **ID** of the user that is partner in the actual conversation or **false** if it's not a message.
316321
*/
317322
public function getConversationPartner()
318323
{
319324
if ($this->getValue('msg_type') === self::MESSAGE_TYPE_PM) {
320-
$recipients = $this->readRecipientsData();
321-
return $recipients[0]['id'];
325+
if($this->msgConversationPartnerId === 0) {
326+
$recipients = $this->readRecipientsData();
327+
foreach ($recipients as $recipient) {
328+
if ($recipient['id'] !== $this->getValue('msg_usr_id_sender')) {
329+
$this->msgConversationPartnerId = $recipient['id'];
330+
}
331+
}
332+
}
333+
334+
return $this->msgConversationPartnerId;
322335
}
323336

324337
return false;

0 commit comments

Comments
 (0)