Ejemplo n.º 1
0
         $convList = isset($_SESSION['converation_list']) ? $_SESSION['converation_list'] : array();
         foreach ($messages as $row) {
             if (!isset($result[$row['userID']])) {
                 //Init Array
                 $result[$row['userID']] = array('html' => '', 'count' => 0, 'name' => '');
                 //If there is a user that has sent new message and is not on the conversation list, add him to the conversation list and get all old messages
                 if (!in_array($row['userID'], $convList)) {
                     //Add to conversation list
                     if (is_array(BuckysPrivateMessenger::openConversationBox($userID, $row['userID']))) {
                         $result[$row['userID']]['html'] = BuckysPrivateMessenger::getMessagesHTML($userID, $row['userID'], 'old');
                     }
                 }
             }
             $result[$row['userID']]['html'] .= '<div class="single_private_message">
                         <img src="' . BuckysUser::getProfileIcon($row) . '" />
                         <div class="private_message_text"><span class="username">' . $row['fullName'] . '</span>' . $row['message'] . ' <span class="date">' . BuckysPrivateMessenger::formatDate(strtotime($row['createdDate'])) . '</span></div>
                       </div>';
             $result[$row['userID']]['count']++;
             $result[$row['userID']]['name'] = $row['fullName'];
         }
     }
     echo '<result>';
     echo '<users><![CDATA[' . $newUserHTML . ']]></users>';
     echo '<messages>';
     foreach ($result as $id => $row) {
         echo '<message id="' . $id . '" encrypted="' . buckys_encrypt_id($id) . '" count="' . $row['count'] . '" name="' . $row['name'] . '"><![CDATA[' . $row['html'] . ']]></message>';
     }
     echo '</messages>';
     echo '</result>';
     exit;
 }
 /**
  * Get Messenger Messages HTMl
  * 
  * @param Int $userID
  * @param Int $buddyID
  * @param String $type: 'new', 'old', 'all'
  */
 public function getMessagesHTML($userID, $buddyID, $type = 'new')
 {
     global $db;
     $rows = BuckysPrivateMessenger::getMessages($userID, $buddyID, $type);
     $html = '';
     $userData = BuckysUser::getUserBasicInfo($userID);
     foreach ($rows as $row) {
         $html .= '<div class="single_private_message">
                     <img src="' . BuckysUser::getProfileIcon($row['messageType'] == 1 ? $row : $userData) . '" />
                     <div class="private_message_text"><span class="username">' . ($row['messageType'] == 1 ? $row['fullName'] : $userData['firstName'] . ' ' . $userData['lastName']) . '</span>' . $row['message'] . ' <span class="date">' . BuckysPrivateMessenger::formatDate(strtotime($row['createdDate'])) . '</span></div>
                   </div>';
     }
     return $html;
 }