getUnreadMessagesChats() public static method

Get's unread messages from users
public static getUnreadMessagesChats ( $limit = 10, $offset, $filterAdditional = [] )
コード例 #1
0
        erLhcoreClassChat::validateFilterIn($Params['user_parameters_unordered']['operatord']);
        $filter['customfilter'][] = '(dep_id = 0 OR dep_id IN (' . implode(",", $Params['user_parameters_unordered']['operatord']) . '))';
    }
    $onlineOperators = erLhcoreClassModelUserDep::getOnlineOperators($currentUser, $canListOnlineUsersAll, $filter, is_numeric($Params['user_parameters_unordered']['limito']) ? (int) $Params['user_parameters_unordered']['limito'] : 10, $onlineTimeout);
    erLhcoreClassChat::prefillGetAttributes($onlineOperators, array('lastactivity_ago', 'user_id', 'id', 'name_support', 'active_chats', 'departments_names'), array(), array('remove_all' => true));
    $ReturnMessages['online_op'] = array('list' => array_values($onlineOperators));
}
if ($unreadTabEnabled == true) {
    $filter = array('ignore_fields' => erLhcoreClassChat::$chatListIgnoreField);
    $limitList = is_numeric($Params['user_parameters_unordered']['limitu']) ? (int) $Params['user_parameters_unordered']['limitu'] : 10;
    if (is_array($Params['user_parameters_unordered']['unreadd']) && !empty($Params['user_parameters_unordered']['unreadd'])) {
        erLhcoreClassChat::validateFilterIn($Params['user_parameters_unordered']['unreadd']);
        $filter['filterin']['dep_id'] = $Params['user_parameters_unordered']['unreadd'];
    }
    // Unread chats
    $unreadChats = erLhcoreClassChat::getUnreadMessagesChats($limitList, 0, $filter);
    $lastPendingChatID = 0;
    $lastChatNick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Visitor');
    $lastMessage = erTranslationClassLhTranslation::getInstance()->getTranslation('pagelayout/pagelayout', 'New unread message');
    if (!empty($unreadChats)) {
        $lastPendingChatID = max(array_keys($unreadChats));
        $chatRecent = reset($unreadChats);
        $lastChatNick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Unread message') . ' | ' . $chatRecent->nick . ' | ' . $chatRecent->department;
        $lastMessage = erLhcoreClassChat::getGetLastChatMessagePending($chatRecent->id);
    }
    erLhcoreClassChat::prefillGetAttributes($unreadChats, array('time_created_front', 'department_name', 'unread_time', 'plain_user_name'), array('department', 'time', 'status', 'user_id', 'user'));
    $ReturnMessages['unread_chats'] = array('msg' => $lastMessage, 'nick' => $lastChatNick, 'last_id' => $lastPendingChatID, 'last_id_identifier' => 'unread_chat', 'list' => array_values($unreadChats));
}
// Update last visit
$currentUser->updateLastVisit();
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.syncadmininterface', array('lists' => &$ReturnMessages));
コード例 #2
0
    foreach ($transferchatsDep as &$transf) {
        $transf['time_front'] = date(erLhcoreClassModule::$dateDateHourFormat, $transf['time']);
    }
}
$ReturnMessages['transfer_chats'] = array('list' => array_values($transferchatsUser), 'last_id_identifier' => 'transfer_chat', 'last_id' => $lastPendingTransferID);
$ReturnMessages['transfer_dep_chats'] = array('list' => array_values($transferchatsDep), 'last_id_identifier' => 'transfer_chat', 'last_id' => $lastPendingTransferID);
if ($canListOnlineUsers == true || $canListOnlineUsersAll == true) {
    $onlineOperators = erLhcoreClassModelUserDep::getOnlineOperators($currentUser, $canListOnlineUsersAll);
    foreach ($onlineOperators as &$onlineOperator) {
        erLhcoreClassChat::prefillGetAttributesObject($onlineOperator->user, array('lastactivity_ago'), array('username', 'password', 'email', 'filepath', 'filename', 'job_title', 'skype', 'xmpp_username'));
    }
    $ReturnMessages['online_op'] = array('list' => array_values($onlineOperators));
}
if ($unreadTabEnabled == true) {
    // Unread chats
    $unreadChats = erLhcoreClassChat::getUnreadMessagesChats(20, 0, array('ignore_fields' => erLhcoreClassChat::$chatListIgnoreField));
    $lastPendingChatID = 0;
    $lastChatNick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Visitor');
    $lastMessage = erTranslationClassLhTranslation::getInstance()->getTranslation('pagelayout/pagelayout', 'New unread message');
    if (!empty($unreadChats)) {
        $lastPendingChatID = max(array_keys($unreadChats));
        $chatRecent = reset($unreadChats);
        $lastChatNick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Unread message') . ' | ' . $chatRecent->nick . ' | ' . $chatRecent->department;
        $lastMessage = erLhcoreClassChat::getGetLastChatMessagePending($chatRecent->id);
    }
    erLhcoreClassChat::prefillGetAttributes($unreadChats, array('time_created_front', 'department_name', 'unread_time'), array('department', 'time', 'status', 'dep_id', 'user_id'));
    $ReturnMessages['unread_chats'] = array('msg' => $lastMessage, 'nick' => $lastChatNick, 'last_id' => $lastPendingChatID, 'last_id_identifier' => 'unread_chat', 'list' => array_values($unreadChats));
}
// Update last visit
$currentUser->updateLastVisit();
echo json_encode(array('error' => 'false', 'result' => $ReturnMessages));
コード例 #3
0
ファイル: lists.php プロジェクト: Adeelgill/livehelperchat
<?php

$currentUser = erLhcoreClassUser::instance();
if (!$currentUser->isLogged() && !$currentUser->authenticate($_POST['username'], $_POST['password'])) {
    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');
コード例 #4
0
} else {
    $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'chat_search', 'format_filter' => true, 'uparams' => $Params['user_parameters_unordered']));
    $filterParams['is_search'] = false;
}
if ($Params['user_parameters_unordered']['print'] == 1) {
    $tpl = erLhcoreClassTemplate::getInstance('lhchat/printchats.tpl.php');
    $items = erLhcoreClassChat::getUnreadMessagesChats(10000, 0, $filterParams['filter']);
    $tpl->set('items', $items);
    $Result['content'] = $tpl->fetch();
    $Result['pagelayout'] = 'popup';
    return;
}
if ($Params['user_parameters_unordered']['xls'] == 1) {
    erLhcoreClassChatExport::chatListExportXLS(erLhcoreClassChat::getUnreadMessagesChats(10000, 0, $filterParams['filter']));
    exit;
}
$append = erLhcoreClassSearchHandler::getURLAppendFromInput($filterParams['input_form']);
$pages = new lhPaginator();
$pages->items_total = erLhcoreClassChat::getUnreadMessagesChatsCount($filterParams['filter']);
$pages->translationContext = 'chat/unreadchats';
$pages->serverURL = erLhcoreClassDesign::baseurl('chat/unreadchats') . $append;
$pages->paginate();
$tpl->set('pages', $pages);
if ($pages->items_total > 0) {
    $items = erLhcoreClassChat::getUnreadMessagesChats($pages->items_per_page, $pages->low, $filterParams['filter']);
    $tpl->set('items', $items);
}
$filterParams['input_form']->form_action = erLhcoreClassDesign::baseurl('chat/unreadchats');
$tpl->set('input', $filterParams['input_form']);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('chat/lists'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closedchats', 'Chats list')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/unreadchats', 'Unread chats list')));