@@ -33,6 +33,10 @@ class TableMessage extends TableAccess
33
33
* @var object of TableAcess for the current content of the message.
34
34
*/
35
35
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 ;
36
40
37
41
/**
38
42
* Constructor that will create an object of a recordset of the table adm_messages.
@@ -311,14 +315,23 @@ public function getConversation($msgId)
311
315
}
312
316
313
317
/**
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.
316
321
*/
317
322
public function getConversationPartner ()
318
323
{
319
324
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 ;
322
335
}
323
336
324
337
return false ;
0 commit comments