本文整理汇总了PHP中erLhcoreClassChat::getPendingMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassChat::getPendingMessages方法的具体用法?PHP erLhcoreClassChat::getPendingMessages怎么用?PHP erLhcoreClassChat::getPendingMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassChat
的用法示例。
在下文中一共展示了erLhcoreClassChat::getPendingMessages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
if ($canExecuteWorkflow == true) {
erLhcoreClassChatWorkflow::transferWorkflow($chat);
}
}
if ($chat->reinform_timeout > 0 && $chat->unread_messages_informed == 0 && $chat->has_unread_messages == 1 && time() - $chat->last_user_msg_time > $chat->reinform_timeout) {
$department = $chat->department;
if ($department !== false) {
$options = $department->inform_options_array;
erLhcoreClassChatWorkflow::unreadInformWorkflow(array('department' => $department, 'options' => $options), $chat);
}
}
// Sync only if chat is pending or active
if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT || $chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
// Check for new messages only if chat last message id is greater than user last message id
if ((int) $Params['user_parameters']['message_id'] < $chat->last_msg_id) {
$Messages = erLhcoreClassChat::getPendingMessages((int) $Params['user_parameters']['chat_id'], (int) $Params['user_parameters']['message_id']);
if (count($Messages) > 0) {
$tpl = erLhcoreClassTemplate::getInstance('lhchat/syncuser.tpl.php');
$tpl->set('messages', $Messages);
$tpl->set('chat', $chat);
$tpl->set('sync_mode', isset($Params['user_parameters_unordered']['mode']) ? $Params['user_parameters_unordered']['mode'] : '');
$content = $tpl->fetch();
foreach ($Messages as $msg) {
if ($msg['user_id'] > 0) {
$userOwner = 'false';
break;
}
}
$LastMessageIDs = array_pop($Messages);
$LastMessageID = $LastMessageIDs['id'];
$breakSync = true;
示例2: json_encode
$currentUser = erLhcoreClassUser::instance();
if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !$currentUser->validateCSFRToken($_SERVER['HTTP_X_CSRFTOKEN'])) {
echo json_encode(array('error' => 'true', 'result' => 'Invalid CSRF Token'));
exit;
}
$db = ezcDbInstance::get();
while (true) {
$db->beginTransaction();
try {
foreach ($_POST['chats'] as $chat_id_list) {
list($chat_id, $MessageID) = explode(',', $chat_id_list);
$Chat = erLhcoreClassModelChat::fetch($chat_id);
$Chat->updateIgnoreColumns = array('last_msg_id');
if (isset($hasAccessToReadArray[$chat_id]) || erLhcoreClassChat::hasAccessToRead($Chat)) {
$hasAccessToReadArray[$chat_id] = true;
if ($Chat->last_msg_id > (int) $MessageID && count($Messages = erLhcoreClassChat::getPendingMessages($chat_id, $MessageID)) > 0) {
// If chat had flag that it contains unread messages set to 0
if ($Chat->has_unread_messages == 1 || $Chat->unread_messages_informed == 1) {
$Chat->has_unread_messages = 0;
$Chat->unread_messages_informed = 0;
$Chat->saveThis();
}
$newMessagesNumber = count($Messages);
$tpl->set('messages', $Messages);
$tpl->set('chat', $Chat);
$msgText = '';
if ($userOwner == 'true') {
foreach ($Messages as $msg) {
if ($msg['user_id'] != $currentUser->getUserID()) {
$userOwner = 'false';
$msgText = $msg['msg'];
示例3: header
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
erLhcoreClassRestAPIHandler::validateRequest();
$chat = erLhcoreClassModelChat::fetch((int) $_GET['chat_id']);
if (erLhcoreClassRestAPIHandler::hasAccessToRead($chat) == true) {
erLhcoreClassRestAPIHandler::outputResponse(array('error' => false, 'messages' => erLhcoreClassChat::getPendingMessages($chat->id, isset($_GET['last_message_id']) ? (int) $_GET['last_message_id'] : 0)));
} else {
throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'You do not have permission to read this chat!'));
}
} catch (Exception $e) {
echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;