} //Create Messages XML $result = array(); if ($newUserHTML != '') { $buddyIDs = array_unique($buddyIDs); $messages = BuckysPrivateMessenger::getMessages($userID, $buddyIDs, 'new'); //Getting Conversation List $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>';
$buddyIDs[] = $row['userID']; } //Create Messages XML $result = []; if ($newUserHTML != '') { $buddyIDs = array_unique($buddyIDs); $messages = BuckysPrivateMessenger::getMessages($userID, $buddyIDs, 'new'); //Getting Conversation List $convList = isset($_SESSION['converation_list']) ? $_SESSION['converation_list'] : []; foreach ($messages as $row) { if (!isset($result[$row['userID']])) { //Init Array $result[$row['userID']] = ['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) && is_array(BuckysPrivateMessenger::openConversationBox($userID, $row['userID']))) { //Add to conversation list $result[$row['userID']]['html'] = BuckysPrivateMessenger::getMessagesHTML($userID, $row['userID'], 'old'); //Update ConvList $convList = isset($_SESSION['converation_list']) ? $_SESSION['converation_list'] : []; } else { $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">' . buckys_format_date($row['createdDate'], 'F j, Y h:i A') . '</span></div> </div>'; } $result[$row['userID']]['count']++; $result[$row['userID']]['name'] = $row['fullName']; } } echo '<result>';