Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. public function getConversation($conversationId, $messagesOffset = 0, $messagesPerPage = 5000)
  2.     {
  3.         $conversationId = (int) $conversationId;
  4.  
  5.         $conversation = array();
  6.  
  7.         $queryString = <<<SQL
  8.     SELECT
  9.       c.*,
  10.       u.username,
  11.       u.avatar,
  12.       u.usergroup,
  13.       u.displaygroup
  14.     FROM PREFIX_conversations c INNER JOIN PREFIX_users u
  15.         ON (c.user_id = u.uid)
  16.     WHERE c.id = '{$conversationId}' LIMIT 1;
  17. SQL;
  18.  
  19.         $queryString = str_replace('PREFIX_', TABLE_PREFIX, $queryString);
  20.  
  21.         $query = $this->db->write_query($queryString);
  22.  
  23.         if ($this->db->num_rows($query) > 0) {
  24.             $fetchedConversation = $this->db->fetch_array($query);
  25.  
  26.             $conversation = array(
  27.                 'id'           => (int) $fetchedConversation['id'],
  28.                 'subject'      => htmlspecialchars_uni($fetchedConversation['subject']),
  29.                 'created_at'   => my_date(
  30.                     $this->mybb->settings['dateformat'] . ' ' . $this->mybb->settings['timeformat'],
  31.                     $fetchedConversation['created_at']
  32.                 ),
  33.                 'creator'      => array(
  34.                     'id' => (int) $fetchedConversation['user_id'],
  35.                     'username'     => htmlspecialchars_uni($fetchedConversation['username']),
  36.                     'avatar'       => htmlspecialchars_uni($fetchedConversation['avatar']),
  37.                     'usergroup'    => (int) $fetchedConversation['usergroup'],
  38.                     'displaygroup' => (int) $fetchedConversation['displaygroup'],
  39.                     'profilelink'  => build_profile_link(
  40.                         format_name(
  41.                             htmlspecialchars_uni($fetchedConversation['username']),
  42.                             $fetchedConversation['usergroup'],
  43.                             $fetchedConversation['displaygroup']
  44.                         ),
  45.                         $fetchedConversation['user_id']
  46.                     )
  47.                 ),
  48.                 'participants' => $this->getParticipantsForConversation($conversationId),
  49.                 'messages'     => $this->getMessagesForConversation($conversationId, $messagesOffset, $messagesPerPage),
  50.             );
  51.  
  52.             if (!$this->checkCanViewConversation($conversation)) {
  53.                 throw new MyBBStuff_ConversationSystem_NoPermissionException('You do not have permission to view this conversation');
  54.             }
  55.         }
  56.  
  57.         return $conversation;
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement