public function getConversations(array $conditions = array(), array $fetchOptions = array())
{
$joinOptions = $this->prepareConversationFetchOptions($fetchOptions);
$whereClause = $this->prepareConversationConditions($conditions, $fetchOptions);
$limitOptions = $this->prepareLimitFetchOptions($fetchOptions);
return $this->fetchAllKeyed($this->limitQueryResults(
'
SELECT conversation_master.*,
conversation_user.*,
conversation_starter.*,
conversation_recipient.recipient_state, conversation_recipient.last_read_date
' . $joinOptions['selectFields'] . '
FROM xf_conversation_user AS conversation_user
INNER JOIN xf_conversation_master AS conversation_master ON
(conversation_user.conversation_id = conversation_master.conversation_id)
INNER JOIN xf_conversation_recipient AS conversation_recipient ON
(conversation_user.conversation_id = conversation_recipient.conversation_id
AND conversation_user.owner_user_id = conversation_recipient.user_id)
LEFT JOIN xf_user AS conversation_starter ON
(conversation_starter.user_id = conversation_master.user_id)
' . $joinOptions['joinTables'] . '
WHERE conversation_user.owner_user_id = xxx
ORDER BY conversation_user.last_message_date DESC
', $limitOptions['limit'], $limitOptions['offset']
), 'conversation_id');
}