本文整理汇总了PHP中erLhcoreClassChat::getChatDurationToUpdateChatID方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassChat::getChatDurationToUpdateChatID方法的具体用法?PHP erLhcoreClassChat::getChatDurationToUpdateChatID怎么用?PHP erLhcoreClassChat::getChatDurationToUpdateChatID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassChat
的用法示例。
在下文中一共展示了erLhcoreClassChat::getChatDurationToUpdateChatID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeStatus
public static function changeStatus($params)
{
$changeStatus = $params['status'];
$chat = $params['chat'];
$userData = $params['user'];
$allowCloseRemote = $params['allow_close_remote'];
if ($changeStatus == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
if ($chat->status != erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_ACTIVE_CHAT;
$chat->wait_time = time() - $chat->time;
}
if ($chat->user_id == 0) {
$chat->user_id = $userData->id;
}
$chat->updateThis();
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_PENDING_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_PENDING_CHAT;
$chat->support_informed = 0;
$chat->has_unread_messages = 1;
$chat->updateThis();
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_CLOSED_CHAT && $chat->user_id == $userData->id || $allowCloseRemote == true) {
if ($chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
$chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
$msg = new erLhcoreClassModelmsg();
$msg->msg = (string) $userData . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closechatadmin', 'has closed the chat!');
$msg->chat_id = $chat->id;
$msg->user_id = -1;
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
$chat->updateThis();
CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat->id);
// Execute callback for close chat
erLhcoreClassChat::closeChatCallback($chat, $userData);
}
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_CHATBOX_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_CHATBOX_CHAT;
erLhcoreClassChat::getSession()->update($chat);
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_OPERATORS_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_OPERATORS_CHAT;
erLhcoreClassChat::getSession()->update($chat);
}
erLhcoreClassChat::updateActiveChats($chat->user_id);
if ($chat->department !== false) {
erLhcoreClassChat::updateDepartmentStats($chat->department);
}
}
示例2: die
<?php
// Set new chat owner
$currentUser = erLhcoreClassUser::instance();
$currentUser->getUserID();
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
// Chat can be closed only by owner
if ($chat->user_id == $currentUser->getUserID() || $currentUser->hasAccessTo('lhchat', 'allowcloseremote')) {
if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
die('Invalid CSRF Token');
exit;
}
if ($chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
$chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
$userData = $currentUser->getUserData(true);
$msg = new erLhcoreClassModelmsg();
$msg->msg = (string) $userData . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closechatadmin', 'has closed the chat!');
$msg->chat_id = $chat->id;
$msg->user_id = -1;
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
$chat->updateThis();
erLhcoreClassChat::updateActiveChats($chat->user_id);
// Execute callback for close chat
erLhcoreClassChat::closeChatCallback($chat, $userData);
}
}
CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', (int) $Params['user_parameters']['chat_id']);
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
示例3: automaticChatClosing
public static function automaticChatClosing()
{
$closedChatsNumber = 0;
$timeout = (int) erLhcoreClassModelChatConfig::fetch('autoclose_timeout')->current_value;
if ($timeout > 0) {
// Close normal chats
$delay = time() - $timeout * 60;
foreach (erLhcoreClassChat::getList(array('limit' => 500, 'filtergt' => array('last_user_msg_time' => 0), 'filterlt' => array('last_user_msg_time' => $delay), 'filter' => array('status' => erLhcoreClassModelChat::STATUS_ACTIVE_CHAT))) as $chat) {
$chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
$msg = new erLhcoreClassModelmsg();
$msg->msg = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncuser', 'Chat was automatically closed by cron');
$msg->chat_id = $chat->id;
$msg->user_id = -1;
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
if ($chat->last_msg_id < $msg->id) {
$chat->last_msg_id = $msg->id;
}
$chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
$chat->updateThis();
if ($chat->department !== false) {
erLhcoreClassChat::updateDepartmentStats($chat->department);
}
erLhcoreClassChat::updateActiveChats($chat->user_id);
$closedChatsNumber++;
}
// Close pending chats where the only message is user initial message
foreach (erLhcoreClassChat::getList(array('limit' => 500, 'filterlt' => array('time' => $delay), 'filterin' => array('status' => array(erLhcoreClassModelChat::STATUS_PENDING_CHAT, erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)), 'filter' => array('last_user_msg_time' => 0))) as $chat) {
$chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
$msg = new erLhcoreClassModelmsg();
$msg->msg = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncuser', 'Chat was automatically closed by cron');
$msg->chat_id = $chat->id;
$msg->user_id = -1;
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
if ($chat->last_msg_id < $msg->id) {
$chat->last_msg_id = $msg->id;
}
$chat->updateThis();
erLhcoreClassChat::updateActiveChats($chat->user_id);
if ($chat->department !== false) {
erLhcoreClassChat::updateDepartmentStats($chat->department);
}
$closedChatsNumber++;
}
}
return $closedChatsNumber;
}