Beispiel #1
0
 public static function getSession()
 {
     if (!isset(self::$persistentSession)) {
         self::$persistentSession = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('./pos/lhtransfer'));
     }
     return self::$persistentSession;
 }
    erLhcoreClassChat::prefillGetAttributes($pendingChats, array('time_created_front', 'department_name', 'wait_time_pending', 'wait_time_seconds', 'plain_user_name'), array('department', 'time', 'status', 'user_id', 'user'));
    $ReturnMessages['pending_chats'] = array('list' => array_values($pendingChats), 'nick' => $lastChatNick, 'msg' => $lastMessage, 'last_id_identifier' => 'pending_chat', 'last_id' => $lastPendingChatID);
}
// Transfered chats
$transferchatsUser = erLhcoreClassTransfer::getTransferChats();
$lastPendingTransferID = 0;
if (!empty($transferchatsUser)) {
    reset($transferchatsUser);
    $chatPending = current($transferchatsUser);
    $lastPendingTransferID = $chatPending['transfer_id'];
    foreach ($transferchatsUser as &$transf) {
        $transf['time_front'] = date(erLhcoreClassModule::$dateDateHourFormat, $transf['time']);
    }
}
// Transfered chats to departments
$transferchatsDep = erLhcoreClassTransfer::getTransferChats(array('department_transfers' => true));
if (!empty($transferchatsDep)) {
    reset($transferchatsDep);
    $chatPending = current($transferchatsDep);
    if ($chatPending['transfer_id'] > $lastPendingTransferID) {
        $lastPendingTransferID = $chatPending['transfer_id'];
    }
    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) {
    $filter = array();
    if (is_array($Params['user_parameters_unordered']['operatord']) && !empty($Params['user_parameters_unordered']['operatord'])) {
Beispiel #3
0
<?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');
    // Change department if user cannot read current department, so chat appears in right menu
    $filter = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
    if ($filter !== true && !in_array($chat->dep_id, $filter)) {
        $dep_id = erLhcoreClassUserDep::getDefaultUserDepartment();
        if ($dep_id > 0) {
            $chat->dep_id = $dep_id;
            $chat->status_sub = erLhcoreClassModelChat::STATUS_SUB_OWNER_CHANGED;
        }
    }
}
if (!erLhcoreClassChat::hasAccessToRead($chat)) {
    if ($currentUser->getUserID() == $chatTransfer->transfer_to_user_id) {
        $dep_id = erLhcoreClassUserDep::getDefaultUserDepartment();
        if ($dep_id > 0) {
            $chat->dep_id = $dep_id;
            $chat->status_sub = erLhcoreClassModelChat::STATUS_SUB_OWNER_CHANGED;
        }
    } else {
        exit;
        // User does not have permission to assign chat to himself
    }
}
// All ok, we can make changes
erLhcoreClassChat::getSession()->update($chat);
erLhcoreClassTransfer::getSession()->delete($chatTransfer);
if ($Params['user_parameters_unordered']['postaction'] == 'singlewindow') {
    erLhcoreClassModule::redirect('chat/single/' . $chat->id);
    exit;
}
echo json_encode(array('error' => 'false', 'chat_id' => $chat->id));
exit;
        $chat->user_id = $user->id;
        // Assign chat to receiver operator, this way he will get permission to open chat
        $chat->dep_id = erLhcoreClassUserDep::getDefaultUserDepartment();
        // Set default department to chat creator, this way current user will get permission to open it
        // Store chat
        erLhcoreClassChat::getSession()->save($chat);
        // Store User Message
        $msg->chat_id = $chat->id;
        $msg->user_id = $currentUser->getUserID();
        $msg->time = time();
        $msg->name_support = $currentUserData->name . ' ' . $currentUserData->surname;
        erLhcoreClassChat::getSession()->save($msg);
        $transfer = new erLhcoreClassModelTransfer();
        $transfer->chat_id = $chat->id;
        $transfer->from_dep_id = $chat->dep_id;
        // User which is transfering
        $transfer->transfer_user_id = $currentUser->getUserID();
        // To what user
        $transfer->transfer_to_user_id = $user->id;
        erLhcoreClassTransfer::getSession()->save($transfer);
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.startchatwithoperator_started', array('chat' => &$chat, 'transfer' => &$transfer));
        // Redirect user
        erLhcoreClassModule::redirect('chat/single/' . $chat->id);
        exit;
    } else {
        $tpl->set('errors', $Errors);
    }
}
$tpl->set('msg', $msg);
$Result['content'] = $tpl->fetch();
$Result['pagelayout'] = 'popup';