本文整理汇总了PHP中erLhcoreClassModelChatOnlineUser::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassModelChatOnlineUser::getList方法的具体用法?PHP erLhcoreClassModelChatOnlineUser::getList怎么用?PHP erLhcoreClassModelChatOnlineUser::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassModelChatOnlineUser
的用法示例。
在下文中一共展示了erLhcoreClassModelChatOnlineUser::getList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public static function handleRequest($paramsHandle = array())
{
if (isset($_SERVER['HTTP_USER_AGENT']) && !self::isBot($_SERVER['HTTP_USER_AGENT'])) {
$newVisitor = false;
if (isset($paramsHandle['vid']) && !empty($paramsHandle['vid'])) {
$items = erLhcoreClassModelChatOnlineUser::getList(array('filter' => array('vid' => $paramsHandle['vid'])));
if (!empty($items)) {
$item = array_shift($items);
// Visit duration les than 30m. Same as google analytics
// See: https://support.google.com/analytics/answer/2731565?hl=en
if (time() - $item->last_visit <= 30 * 60) {
$item->time_on_site += time() - $item->last_visit;
$item->tt_time_on_site += time() - $item->last_visit;
} else {
$item->time_on_site = 0;
$item->total_visits++;
$item->last_visit = time();
$item->pages_count = 0;
// Reset chat_id only if chat is not active or pending
if ($item->chat_id > 0) {
if ($item->chat === false || !in_array($item->chat->status, array(erLhcoreClassModelChat::STATUS_ACTIVE_CHAT, erLhcoreClassModelChat::STATUS_PENDING_CHAT))) {
$item->chat_id = 0;
}
}
if ($item->message_seen == 1 && $item->message_seen_ts < time() - (int) $paramsHandle['message_seen_timeout'] * 3600) {
$item->message_seen = 0;
$item->message_seen_ts = 0;
$item->operator_message = '';
}
}
$item->identifier = isset($paramsHandle['identifier']) && !empty($paramsHandle['identifier']) ? $paramsHandle['identifier'] : $item->identifier;
if (isset($paramsHandle['department']) && is_array($paramsHandle['department']) && count($paramsHandle['department']) == 1) {
$item->dep_id = array_shift($paramsHandle['department']);
} elseif (isset($paramsHandle['department']) && is_numeric($paramsHandle['department'])) {
$item->dep_id = (int) $paramsHandle['department'];
}
} else {
$item = new erLhcoreClassModelChatOnlineUser();
$item->ip = erLhcoreClassIPDetect::getIP();
$item->vid = $paramsHandle['vid'];
$item->identifier = isset($paramsHandle['identifier']) && !empty($paramsHandle['identifier']) ? $paramsHandle['identifier'] : '';
$item->referrer = isset($_GET['r']) ? rawurldecode($_GET['r']) : '';
$item->total_visits = 1;
if (isset($paramsHandle['department']) && is_array($paramsHandle['department']) && count($paramsHandle['department']) == 1) {
$item->dep_id = array_shift($paramsHandle['department']);
} elseif (isset($paramsHandle['department']) && is_numeric($paramsHandle['department'])) {
$item->dep_id = (int) $paramsHandle['department'];
}
if (isset($paramsHandle['tz']) && is_numeric($paramsHandle['tz'])) {
$timezone_name = timezone_name_from_abbr(null, (int) $paramsHandle['tz'] * 3600, true);
if ($timezone_name !== false) {
$item->visitor_tz = $timezone_name;
}
}
self::detectLocation($item);
// Cleanup database then new user comes
self::cleanupOnlineUsers();
$item->store_chat = true;
$newVisitor = true;
}
} else {
self::cleanupOnlineUsers();
return false;
}
if (isset($paramsHandle['pages_count']) && $paramsHandle['pages_count'] == true) {
$item->pages_count++;
$item->tt_pages_count++;
$item->store_chat = true;
if (isset($_GET['onattr']) && is_array($_GET['onattr']) && !empty($_GET['onattr'])) {
$item->online_attr = json_encode($_GET['onattr']);
}
if ($item->has_message_from_operator == true) {
$item->invitation_seen_count++;
}
if (isset($paramsHandle['tz']) && is_numeric($paramsHandle['tz']) && $item->visitor_tz == '') {
$timezone_name = timezone_name_from_abbr(null, (int) $paramsHandle['tz'] * 3600, true);
if ($timezone_name !== false) {
$item->visitor_tz = $timezone_name;
}
}
// Hide invitation message after n times if required
if ($item->has_message_from_operator == true && $item->invitation !== false && $item->invitation->hide_after_ntimes > 0 && $item->invitation_seen_count > $item->invitation->hide_after_ntimes) {
$item->message_seen = 1;
$item->message_seen_ts = time();
}
}
$logPageView = false;
// Update variables only if it's not JS to check for operator message
if (!isset($paramsHandle['check_message_operator']) || isset($paramsHandle['pages_count']) && $paramsHandle['pages_count'] == true) {
$item->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$item->current_page = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$item->page_title = isset($_GET['dt']) ? (string) rawurldecode($_GET['dt']) : '';
$item->last_visit = time();
$item->store_chat = true;
$logPageView = true;
}
if ((!isset($paramsHandle['wopen']) || $paramsHandle['wopen'] == 0) && $item->operator_message == '' && isset($paramsHandle['pro_active_invite']) && $paramsHandle['pro_active_invite'] == 1 && isset($paramsHandle['pro_active_limitation']) && ($paramsHandle['pro_active_limitation'] == -1 || erLhcoreClassChat::getPendingChatsCountPublic($item->dep_id > 0 ? $item->dep_id : false) <= $paramsHandle['pro_active_limitation'])) {
//Process pro active chat invitation if this visitor matches any rules
erLhAbstractModelProactiveChatInvitation::processProActiveInvitation($item);
}
//.........这里部分代码省略.........
示例2: array
exit;
}
$activeChats = erLhcoreClassChat::getActiveChats(10);
$closedChats = erLhcoreClassChat::getClosedChats(10);
$pendingChats = erLhcoreClassChat::getPendingChats(10);
$transferedChats = erLhcoreClassTransfer::getTransferChats();
$unreadChats = erLhcoreClassChat::getUnreadMessagesChats(10, 0);
erLhcoreClassChat::prefillGetAttributes($activeChats, array('department_name'), array('updateIgnoreColumns', 'department'));
erLhcoreClassChat::prefillGetAttributes($closedChats, array('department_name'), array('updateIgnoreColumns', 'department'));
erLhcoreClassChat::prefillGetAttributes($pendingChats, array('department_name'), array('updateIgnoreColumns', 'department'));
erLhcoreClassChat::prefillGetAttributes($unreadChats, array('department_name'), array('updateIgnoreColumns', 'department'));
$onlineUsers = array();
if ($currentUser->hasAccessTo('lhchat', 'use_onlineusers')) {
$filter = array('offset' => 0, 'limit' => 50, 'sort' => 'last_visit DESC', 'filtergt' => array('last_visit' => time() - 3600));
$departmentParams = array();
$userDepartments = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
if ($userDepartments !== true) {
$departmentParams['filterin']['id'] = $userDepartments;
if (!$currentUser->hasAccessTo('lhchat', 'sees_all_online_visitors')) {
$filter['filterin']['dep_id'] = $userDepartments;
}
}
$onlineUsers = erLhcoreClassModelChatOnlineUser::getList($filter);
}
$columnsToHide = array('user_closed_ts', 'tslasign', 'reinform_timeout', 'unread_messages_informed', 'wait_timeout', 'wait_timeout_send', 'status_sub', 'timeout_message', 'nc_cb_executed', 'fbst', 'user_id', 'transfer_timeout_ts', 'operator_typing_id', 'transfer_timeout_ac', 'transfer_if_na', 'na_cb_executed', 'status', 'remarks', 'operation', 'operation_admin', 'screenshot_id', 'mail_send', 'online_user_id', 'dep_id', 'last_msg_id', 'hash', 'user_status', 'support_informed', 'support_informed', 'country_code', 'user_typing', 'user_typing_txt', 'lat', 'lon', 'chat_initiator', 'chat_variables', 'chat_duration', 'operator_typing', 'has_unread_messages', 'last_user_msg_time', 'additional_data');
$columnsName = array('id' => 'ID', 'user_tz_identifier' => 'User time zone', 'department_name' => 'Department', 'nick' => 'Nick', 'time' => 'Time', 'referrer' => 'Referrer', 'session_referrer' => 'Original referrer', 'ip' => 'IP', 'country_name' => 'Country', 'email' => 'E-mail', 'priority' => 'Priority', 'name' => 'Department', 'phone' => 'Phone', 'city' => 'City', 'wait_time' => 'Waited');
$onlineuserscolumnsToHide = array('requires_phone', 'lat_check_time', 'dep_id', 'requires_email', 'requires_username', 'invitation_seen_count', 'screenshot_id', 'operation', 'reopen_chat', 'vid', 'user_country_code', 'invitation_assigned', 'current_page', 'chat_id', 'operator_user_id', 'message_seen', 'operator_user_proactive', 'message_seen_ts', 'lat', 'lon', 'invitation_id', 'time_on_site', 'tt_time_on_site', 'invitation_count', 'store_chat');
$onlineuserscolumnsNames = array('last_check_time' => 'Last online check', 'notes' => 'Notes', 'referrer' => 'Referrer', 'page_title' => 'Page title', 'visitor_tz' => 'Visitor time zone', 'online_attr' => 'Attributes', 'id' => 'ID', 'operator_message' => 'Operator message', 'ip' => 'IP', 'identifier' => 'Identifier', 'user_agent' => 'Browser', 'last_visit' => 'Last visit', 'first_visit' => 'First visit', 'total_visits' => 'Total visits', 'user_country_name' => 'Country', 'city' => 'City', 'pages_count' => 'Pages viewed', 'tt_pages_count' => 'Total pages viewed');
echo json_encode(array('active_chats' => array('rows' => $activeChats, 'size' => count($activeChats), 'hidden_columns' => $columnsToHide, 'timestamp_delegate' => array('time'), 'column_names' => $columnsName), 'unread_chats' => array('rows' => $unreadChats, 'size' => count($unreadChats), 'hidden_columns' => $columnsToHide, 'timestamp_delegate' => array('time'), 'column_names' => $columnsName), 'online_users' => array('rows' => $onlineUsers, 'size' => count($onlineUsers), 'hidden_columns' => $onlineuserscolumnsToHide, 'column_names' => $onlineuserscolumnsNames, 'timestamp_delegate' => array('last_check_time', 'last_visit', 'first_visit')), 'closed_chats' => array('rows' => $closedChats, 'size' => count($closedChats), 'hidden_columns' => $columnsToHide, 'timestamp_delegate' => array('time'), 'column_names' => $columnsName), 'pending_chats' => array('rows' => $pendingChats, 'size' => count($pendingChats), 'hidden_columns' => $columnsToHide, 'timestamp_delegate' => array('time'), 'column_names' => $columnsName), 'transfered_chats' => array('rows' => $transferedChats, 'size' => count($transferedChats), 'hidden_columns' => array_merge($columnsToHide, array('transfer_id')), 'timestamp_delegate' => array('time'), 'column_names' => $columnsName)));
$currentUser->updateLastVisit();
exit;
示例3: setOnlineStatus
/**
* Sets chat's status by online visitors records in efficient way
* */
public static function setOnlineStatus($chatLists)
{
$onlineUserId = array();
foreach ($chatLists as $chatList) {
foreach ($chatList as $chat) {
if (isset($chat->online_user_id) && $chat->online_user_id > 0) {
$onlineUserId[] = (int) $chat->online_user_id;
}
}
}
if (!empty($onlineUserId)) {
$response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.setonlinestatus', array('list' => &$chatLists, 'online_users_id' => $onlineUserId));
// Event listener has done it's job
if (isset($response['status']) && $response['status'] === erLhcoreClassChatEventDispatcher::STOP_WORKFLOW) {
return;
}
$onlineVisitors = erLhcoreClassModelChatOnlineUser::getList(array('sort' => false, 'filterin' => array('id' => $onlineUserId)), array('vid', 'current_page', 'invitation_seen_count', 'page_title', 'chat_id', 'last_visit', 'first_visit', 'user_agent', 'user_country_name', 'user_country_code', 'operator_message', 'operator_user_id', 'operator_user_proactive', 'message_seen', 'message_seen_ts', 'pages_count', 'tt_pages_count', 'lat', 'lon', 'city', 'identifier', 'time_on_site', 'tt_time_on_site', 'referrer', 'invitation_id', 'total_visits', 'invitation_count', 'requires_email', 'requires_username', 'requires_phone', 'dep_id', 'reopen_chat', 'operation', 'operation_chat', 'screenshot_id', 'online_attr', 'online_attr_system', 'visitor_tz', 'notes'));
foreach ($chatLists as &$chatList) {
foreach ($chatList as &$chat) {
if (isset($chat->online_user_id) && $chat->online_user_id > 0 && isset($onlineVisitors[$chat->online_user_id])) {
$chat->user_status_front = self::setActivityByChatAndOnlineUser($chat, $onlineVisitors[$chat->online_user_id]);
} else {
$chat->user_status_front = 1;
}
}
}
}
}