Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getConversation($conversationId, $messagesOffset = 0, $messagesPerPage = 5000)
- {
- $conversationId = (int) $conversationId;
- $conversation = array();
- $queryString = <<<SQL
- SELECT
- c.*,
- u.username,
- u.avatar,
- u.usergroup,
- u.displaygroup
- FROM PREFIX_conversations c INNER JOIN PREFIX_users u
- ON (c.user_id = u.uid)
- WHERE c.id = '{$conversationId}' LIMIT 1;
- SQL;
- $queryString = str_replace('PREFIX_', TABLE_PREFIX, $queryString);
- $query = $this->db->write_query($queryString);
- if ($this->db->num_rows($query) > 0) {
- $fetchedConversation = $this->db->fetch_array($query);
- $conversation = array(
- 'id' => (int) $fetchedConversation['id'],
- 'subject' => htmlspecialchars_uni($fetchedConversation['subject']),
- 'created_at' => my_date(
- $this->mybb->settings['dateformat'] . ' ' . $this->mybb->settings['timeformat'],
- $fetchedConversation['created_at']
- ),
- 'creator' => array(
- 'id' => (int) $fetchedConversation['user_id'],
- 'username' => htmlspecialchars_uni($fetchedConversation['username']),
- 'avatar' => htmlspecialchars_uni($fetchedConversation['avatar']),
- 'usergroup' => (int) $fetchedConversation['usergroup'],
- 'displaygroup' => (int) $fetchedConversation['displaygroup'],
- 'profilelink' => build_profile_link(
- format_name(
- htmlspecialchars_uni($fetchedConversation['username']),
- $fetchedConversation['usergroup'],
- $fetchedConversation['displaygroup']
- ),
- $fetchedConversation['user_id']
- )
- ),
- 'participants' => $this->getParticipantsForConversation($conversationId),
- 'messages' => $this->getMessagesForConversation($conversationId, $messagesOffset, $messagesPerPage),
- );
- if (!$this->checkCanViewConversation($conversation)) {
- throw new MyBBStuff_ConversationSystem_NoPermissionException('You do not have permission to view this conversation');
- }
- }
- return $conversation;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement