Skip to content

Commit

Permalink
Private message will not be shown to the recipient of that message #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Aug 26, 2022
1 parent f56e20f commit c83b0f6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions adm_program/system/classes/TableMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class TableMessage extends TableAccess
* @var object of TableAcess for the current content of the message.
*/
protected $msgContentObject;
/**
* @var int ID the conversation partner of a private message. This is the recipient of the message from msg_usr_id_sender.
*/
protected $msgConversationPartnerId = 0;

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

/**
* If the message type is PM this method will return the conversation partner of the PM.
* @return int Returns **ID** of the user that is partner in the actual conversation or false if it's not a message.
* If the message type is PM this method will return the conversation partner of the PM. This is the
* recipient of the message send from **msg_usr_id_sender**.
* @return int Returns **ID** of the user that is partner in the actual conversation or **false** if it's not a message.
*/
public function getConversationPartner()
{
if ($this->getValue('msg_type') === self::MESSAGE_TYPE_PM) {
$recipients = $this->readRecipientsData();
return $recipients[0]['id'];
if($this->msgConversationPartnerId === 0) {
$recipients = $this->readRecipientsData();
foreach ($recipients as $recipient) {
if ($recipient['id'] !== $this->getValue('msg_usr_id_sender')) {
$this->msgConversationPartnerId = $recipient['id'];
}
}
}

return $this->msgConversationPartnerId;
}

return false;
Expand Down

0 comments on commit c83b0f6

Please sign in to comment.