public static function getList($paramsSearch = array()) { if (!isset($paramsSearch['sort'])) { $paramsSearch['sort'] = 'id ASC'; } return erLhcoreClassChat::getList($paramsSearch, 'erLhcoreClassModelmsg', 'lh_msg'); }
public static function getList($paramsSearch = array()) { $paramsDefault = array('limit' => 32, 'offset' => 0); $params = array_merge($paramsDefault, $paramsSearch); $session = erLhcoreClassChat::getSession(); $q = $session->createFindQuery('erLhcoreClassModelmsg'); $conditions = array(); if (isset($params['filter']) && count($params['filter']) > 0) { foreach ($params['filter'] as $field => $fieldValue) { $conditions[] = $q->expr->eq($field, $q->bindValue($fieldValue)); } } if (isset($params['filterin']) && count($params['filterin']) > 0) { foreach ($params['filterin'] as $field => $fieldValue) { $conditions[] = $q->expr->in($field, $fieldValue); } } if (isset($params['filterlt']) && count($params['filterlt']) > 0) { foreach ($params['filterlt'] as $field => $fieldValue) { $conditions[] = $q->expr->lt($field, $q->bindValue($fieldValue)); } } if (isset($params['filtergt']) && count($params['filtergt']) > 0) { foreach ($params['filtergt'] as $field => $fieldValue) { $conditions[] = $q->expr->gt($field, $q->bindValue($fieldValue)); } } if (count($conditions) > 0) { $q->where($conditions); } $q->limit($params['limit'], $params['offset']); $q->orderBy(isset($params['sort']) ? $params['sort'] : 'id ASC'); $objects = $session->find($q); return $objects; }
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) { $matches = array(); if (strpos($name, '.') === false && preg_match('/^image\\/(gif|jpe?g|png)/', $type, $matches)) { $name = $uploadFileName = 'clipboard.' . $matches[1]; } else { $uploadFileName = $name; } if (!preg_match($this->options['accept_file_types_lhc'], $uploadFileName)) { $file->error = $this->get_error_message('accept_file_types'); return false; } $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range); if (empty($file->error)) { $fileUpload = new erLhcoreClassModelChatFile(); $fileUpload->size = $file->size; $fileUpload->type = $file->type; $fileUpload->name = $file->name; $fileUpload->date = time(); $fileUpload->user_id = isset($this->options['user_id']) ? $this->options['user_id'] : 0; $fileUpload->upload_name = $name; $fileUpload->file_path = $this->options['upload_dir']; if (isset($this->options['chat']) && $this->options['chat'] instanceof erLhcoreClassModelChat) { $fileUpload->chat_id = $this->options['chat']->id; } elseif (isset($this->options['online_user']) && $this->options['online_user'] instanceof erLhcoreClassModelChatOnlineUser) { $fileUpload->online_user_id = $this->options['online_user']->id; } $matches = array(); if (strpos($name, '.') === false && preg_match('/^image\\/(gif|jpe?g|png)/', $fileUpload->type, $matches)) { $fileUpload->extension = $matches[1]; } else { $partsFile = explode('.', $fileUpload->upload_name); $fileUpload->extension = end($partsFile); } $fileUpload->saveThis(); $file->id = $fileUpload->id; if (isset($this->options['chat']) && $this->options['chat'] instanceof erLhcoreClassModelChat) { // Chat assign $chat = $this->options['chat']; // Format message $msg = new erLhcoreClassModelmsg(); $msg->msg = '[file=' . $file->id . '_' . md5($fileUpload->name . '_' . $fileUpload->chat_id) . ']'; $msg->chat_id = $chat->id; $msg->user_id = isset($this->options['user_id']) ? $this->options['user_id'] : 0; if ($msg->user_id > 0 && isset($this->options['name_support'])) { $msg->name_support = (string) $this->options['name_support']; } $chat->last_user_msg_time = $msg->time = time(); erLhcoreClassChat::getSession()->save($msg); // Set last message ID if ($chat->last_msg_id < $msg->id) { $chat->last_msg_id = $msg->id; } $chat->has_unread_messages = 1; $chat->updateThis(); } $this->uploadedFile = $fileUpload; } return $file; }
public static function fetchByHash($hash) { $list = erLhcoreClassChat::getList(array('limit' => 1, 'filter' => array('hash' => $hash)), 'erLhcoreClassModelChatAccept', 'lh_chat_accept'); if (!empty($list)) { return array_pop($list); } else { return false; } }
public static function validateSendMail(erLhAbstractModelEmailTemplate &$sendMail, &$chat, $params = array()) { $Errors = array(); $validationFields = array(); $validationFields['Message'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); $validationFields['Subject'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); $validationFields['FromName'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); $validationFields['FromEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'); $validationFields['ReplyEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'); $validationFields['RecipientEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'); $form = new ezcInputForm(INPUT_POST, $validationFields); $Errors = array(); if (isset($params['archive_mode']) && $params['archive_mode'] == true) { $messages = array_reverse(erLhcoreClassChat::getList(array('limit' => 100, 'sort' => 'id DESC', 'customfilter' => array('user_id != -1'), 'filter' => array('chat_id' => $chat->id)), 'erLhcoreClassModelChatArchiveMsg', erLhcoreClassModelChatArchiveRange::$archiveMsgTable)); } else { $messages = array_reverse(erLhcoreClassModelmsg::getList(array('limit' => 100, 'sort' => 'id DESC', 'customfilter' => array('user_id != -1'), 'filter' => array('chat_id' => $chat->id)))); } // Fetch chat messages $tpl = new erLhcoreClassTemplate('lhchat/messagelist/plain.tpl.php'); $tpl->set('chat', $chat); $tpl->set('messages', $messages); $sendMail->content = str_replace(array('{user_chat_nick}', '{messages_content}', '{chat_id}'), array($chat->nick, $tpl->fetch(), $chat->id), $sendMail->content); if ($form->hasValidData('Message')) { $sendMail->content = str_replace('{additional_message}', $form->Message, $sendMail->content); } $sendMail->content = erLhcoreClassBBCode::parseForMail($sendMail->content); if ($form->hasValidData('FromEmail')) { $sendMail->from_email = $form->FromEmail; } if ($form->hasValidData('ReplyEmail')) { $sendMail->reply_to = $form->ReplyEmail; } if ($form->hasValidData('FromName')) { $sendMail->from_name = $form->FromName; } if ($form->hasValidData('Subject')) { $sendMail->subject = $form->Subject; } if ($form->hasValidData('RecipientEmail')) { $sendMail->recipient = $form->RecipientEmail; } else { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Please enter recipient e-mail!'); } if (empty($sendMail->from_email)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'From e-mail is missing!'); } if (empty($sendMail->reply_to)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Reply e-mail is missing!'); } if (empty($sendMail->subject)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Subject is missing!'); } return $Errors; }
public function __get($var) { switch ($var) { case 'is_online': $this->is_online = erLhcoreClassChat::isOnline($this->id); return $this->is_online; break; case 'is_online_exclipic': $this->is_online_exclipic = erLhcoreClassChat::isOnline($this->id, true); return $this->is_online_exclipic; break; case 'inform_options_array': $this->inform_options_array = $this->inform_options != '' ? unserialize($this->inform_options) : array(); return $this->inform_options_array; break; case 'can_delete': $this->can_delete = erLhcoreClassChat::getCount(array('filter' => array('dep_id' => $this->id))) == 0; return $this->can_delete; break; case 'department_transfer': $this->department_transfer = false; if ($this->department_transfer_id > 0) { try { $this->department_transfer = self::fetch($this->department_transfer_id, true); } catch (Exception $e) { } } return $this->department_transfer; break; case 'start_hour_front': return floor($this->start_hour / 100); break; case 'start_minutes_front': return $this->start_hour - $this->start_hour_front * 100; break; case 'end_hour_front': return floor($this->end_hour / 100); break; case 'end_minutes_front': return $this->end_hour - $this->end_hour_front * 100; break; default: break; } }
public function afterSave() { $db = ezcDbInstance::get(); $stmt = $db->prepare('DELETE FROM lh_userdep WHERE dep_group_id = :dep_group_id AND user_id = :user_id'); $stmt->bindValue(':dep_group_id', $this->dep_group_id); $stmt->bindValue(':user_id', $this->user_id); $stmt->execute(); foreach ($this->dep_group->departments_ids as $depId) { $stmt = $db->prepare('INSERT INTO lh_userdep (user_id,dep_id,hide_online,last_activity,last_accepted,active_chats,type,dep_group_id) VALUES (:user_id,:dep_id,:hide_online,0,0,:active_chats,1,:dep_group_id)'); $stmt->bindValue(':user_id', $this->user_id); $stmt->bindValue(':dep_id', $depId); $stmt->bindValue(':hide_online', $this->user->hide_online); $stmt->bindValue(':dep_group_id', $this->dep_group_id); $stmt->bindValue(':active_chats', erLhcoreClassChat::getCount(array('filter' => array('user_id' => $this->user_id, 'status' => erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)))); $stmt->execute(); } erLhcoreClassModelDepartamentGroupMember::updateUserDepartmentsIds($this->user_id); }
public function removeInstanceData() { foreach (erLhAbstractModelFormCollected::getList(array('limit' => 1000000)) as $item) { $item->removeThis(); } foreach (erLhAbstractModelWidgetTheme::getList(array('limit' => 1000000)) as $item) { $item->removeThis(); } foreach (erLhcoreClassChat::getList(array('limit' => 1000000)) as $item) { $item->removeThis(); } foreach (erLhcoreClassChat::getList(array('limit' => 1000000), 'erLhcoreClassModelChatFile', 'lh_chat_file') as $item) { $item->removeThis(); } foreach (erLhcoreClassModelUser::getUserList(array('limit' => 1000000)) as $item) { $item->removeFile(); } // Dispatch event for extensions erLhcoreClassChatEventDispatcher::getInstance()->dispatch('instance.destroyed', array('instance' => $this)); return true; }
public function __get($var) { switch ($var) { case 'chat': $this->chat = false; if ($this->chat_id > 0) { try { $this->chat = erLhcoreClassModelChat::fetch($this->chat_id); } catch (Exception $e) { erLhcoreClassChatbox::getSession()->delete($this); } } else { $this->chat = new erLhcoreClassModelChat(); $this->chat->hash = erLhcoreClassChat::generateHash(); } return $this->chat; break; default: break; } }
public function afterSave() { $db = ezcDbInstance::get(); $stmt = $db->prepare('SELECT user_id FROM lh_departament_group_user WHERE dep_group_id = :dep_group_id'); $stmt->bindValue(':dep_group_id', $this->dep_group_id); $stmt->execute(); $userIds = $stmt->fetchAll(PDO::FETCH_COLUMN); foreach ($userIds as $userId) { $stmt = $db->prepare('SELECT hide_online FROM lh_users WHERE id = :user_id'); $stmt->bindValue(':user_id', $userId); $stmt->execute(); $hide_online = $stmt->fetch(PDO::FETCH_COLUMN); $stmt = $db->prepare('INSERT INTO lh_userdep (user_id,dep_id,hide_online,last_activity,last_accepted,active_chats,type,dep_group_id) VALUES (:user_id,:dep_id,:hide_online,0,0,:active_chats,1,:dep_group_id)'); $stmt->bindValue(':user_id', $userId); $stmt->bindValue(':dep_id', $this->dep_id); $stmt->bindValue(':hide_online', $hide_online); $stmt->bindValue(':dep_group_id', $this->dep_group_id); $stmt->bindValue(':active_chats', erLhcoreClassChat::getCount(array('filter' => array('user_id' => $userId, 'status' => erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)))); $stmt->execute(); self::updateUserDepartmentsIds($userId); } }
public static function addUserDepartaments($Departaments, $userID = false, $UserData = false) { $db = ezcDbInstance::get(); if ($userID === false) { $currentUser = erLhcoreClassUser::instance(); $userID = $currentUser->getUserID(); } $stmt = $db->prepare('DELETE FROM lh_userdep WHERE user_id = :user_id ORDER BY id ASC'); $stmt->bindValue(':user_id', $userID); $stmt->execute(); foreach ($Departaments as $DepartamentID) { $stmt = $db->prepare('INSERT INTO lh_userdep (user_id,dep_id,hide_online,last_activity,last_accepted,active_chats) VALUES (:user_id,:dep_id,:hide_online,0,0,:active_chats)'); $stmt->bindValue(':user_id', $userID); $stmt->bindValue(':dep_id', $DepartamentID); $stmt->bindValue(':hide_online', $UserData->hide_online); $stmt->bindValue(':active_chats', erLhcoreClassChat::getCount(array('filter' => array('user_id' => $UserData->id, 'status' => erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)))); $stmt->execute(); } if (isset($_SESSION['lhCacheUserDepartaments_' . $userID])) { unset($_SESSION['lhCacheUserDepartaments_' . $userID]); } }
$tosVariable = 'offline_tos_visible_in_page_widget'; $tosCheckedVariable = 'tos_checked_offline'; ?> <?php include_once erLhcoreClassDesign::designtpl('lhchat/part/accept_tos.tpl.php'); ?> <div class="btn-group" role="group" aria-label="..."> <?php include erLhcoreClassDesign::designtpl('lhchat/part/buttons/leave_a_message_button_widget.tpl.php'); ?> <?php include erLhcoreClassDesign::designtpl('lhchat/part/offline_button_multiinclude.tpl.php'); ?> <?php if (erLhcoreClassModelChatConfig::fetch('reopen_chat_enabled')->current_value == 1 && ($reopenData = erLhcoreClassChat::canReopenDirectly(array('reopen_closed' => erLhcoreClassModelChatConfig::fetch('allow_reopen_closed')->current_value))) !== false) { ?> <?php include erLhcoreClassDesign::designtpl('lhchat/part/buttons/reopen_offline_button_widget.tpl.php'); ?> <?php } ?> </div> <input type="hidden" value="<?php echo htmlspecialchars($referer); ?> " name="URLRefer"/> <input type="hidden" value="1" name="StartChat"/>
<?php try { $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); if ($chat->hash == $Params['user_parameters']['hash'] && ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT || $chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)) { $lastMessage = erLhcoreClassChat::getGetLastChatMessageEdit($chat->id, 0); if (isset($lastMessage['msg'])) { $array['id'] = $lastMessage['id']; $array['msg'] = $lastMessage['msg']; $array['error'] = 'f'; echo json_encode($array); exit; } } } catch (Exception $e) { } echo json_encode(array('error' => 't')); exit;
<?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;
<?php if (is_numeric($Params['user_parameters']['chat_id'])) { /* * If online user mode we have to make different check * */ $browse = false; if ($Params['user_parameters_unordered']['cobrowsemode'] == 'onlineuser') { $onlineUser = erLhcoreClassModelChatOnlineUser::fetch($Params['user_parameters']['chat_id']); $browse = erLhcoreClassCoBrowse::getBrowseInstanceByOnlineUser($onlineUser); } else { $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); if (erLhcoreClassChat::hasAccessToRead($chat)) { $browse = erLhcoreClassCoBrowse::getBrowseInstance($chat); } } if ($browse instanceof erLhcoreClassModelCoBrowse) { if ($browse->modifications != '') { $changes = json_decode($browse->modifications); $changes[] = array('url' => $browse->url); $changes[] = array('lmsg' => $browse->mtime > 0 ? $browse->mtime_front : ''); $changes[] = array('finished' => array('status' => !$browse->is_sharing, 'text' => $browse->is_sharing == 0 ? erTranslationClassLhTranslation::getInstance()->getTranslation('cobrowse/browse', 'Screen sharing session has finished') : erTranslationClassLhTranslation::getInstance()->getTranslation('cobrowse/browse', 'Screen is shared'))); if ($browse->finished == 1) { $changes[] = array('clear' => true); } array_unshift($changes, array('base' => $browse->url)); echo json_encode($changes); $browse->modifications = ''; $browse->saveThis(); } else { $changes = array();
<?php $tpl = erLhcoreClassTemplate::getInstance('lhfile/list.tpl.php'); if (isset($_GET['doSearch'])) { $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'filelist', 'format_filter' => true, 'use_override' => true, 'uparams' => $Params['user_parameters_unordered'])); $filterParams['is_search'] = true; } else { $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'filelist', 'format_filter' => true, 'uparams' => $Params['user_parameters_unordered'])); $filterParams['is_search'] = false; } $append = erLhcoreClassSearchHandler::getURLAppendFromInput($filterParams['input_form']); $pages = new lhPaginator(); $pages->serverURL = erLhcoreClassDesign::baseurl('file/list') . $append; $pages->items_total = erLhcoreClassChat::getCount($filterParams['filter'], 'lh_chat_file'); $pages->setItemsPerPage(20); $pages->paginate(); $items = array(); if ($pages->items_total > 0) { $items = erLhcoreClassChat::getList(array_merge(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id DESC'), $filterParams['filter']), 'erLhcoreClassModelChatFile', 'lh_chat_file'); } $tpl->set('items', $items); $tpl->set('pages', $pages); $filterParams['input_form']->form_action = erLhcoreClassDesign::baseurl('file/list'); $tpl->set('input', $filterParams['input_form']); $Result['content'] = $tpl->fetch(); $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('system/configuration', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('file/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('system/configuration', 'List of files')));
</ul> <div class="tab-content"> <div role="tabpanel" class="tab-pane active" id="transferusermodal"> <h4><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/transferchat', 'Logged in users'); ?> </h4> <p><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/transferchat', 'Transfer a chat to one of your departments users'); ?> </p> <?php foreach (erLhcoreClassChat::getOnlineUsers(array($user_id)) as $key => $user) { ?> <label><input type="radio" name="TransferTo<?php echo $chat->id; ?> " value="<?php echo $user['id']; ?> " <?php echo $key == 0 ? 'checked="checked"' : ''; ?> > <?php echo htmlspecialchars($user['name']); ?> <?php echo htmlspecialchars($user['surname']);
public function saveThis() { erLhcoreClassChat::getSession()->saveOrUpdate($this); }
<div> <input type="button" value="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('files/files', 'Refresh'); ?> " class="btn btn-default" onclick="lhinst.updateChatFiles('<?php echo $chat->id; ?> ')" /> <ul id="chat-files-list-<?php echo $chat->id; ?> "> <?php foreach (erLhcoreClassChat::getList(array('filter' => array('chat_id' => $chat->id)), 'erLhcoreClassModelChatFile', 'lh_chat_file') as $file) { ?> <li id="file-id-<?php echo $file->id; ?> "><a title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('files/files', 'Delete file'); ?> " onclick="return lhinst.deleteChatfile('<?php echo $file->id; ?> ')" class="btn btn-xs btn-danger icon-trash"></a> <a href="<?php echo erLhcoreClassDesign::baseurl('file/downloadfile'); ?> /<?php echo $file->id; ?>
<div class="form-group"> <label class="inline"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/generalsettings', 'Auto creation by chatbox identifier is enabled'); ?> <input type="checkbox" name="AutoCreation" value="1" <?php isset($chatbox_data['chatbox_auto_enabled']) && $chatbox_data['chatbox_auto_enabled'] == '1' ? print 'checked="checked"' : ''; ?> /></label> </div> <div class="form-group"> <label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/generalsettings', 'Secret hash, this is used when auto creation is disabled'); ?> , <a href="http://livehelperchat.com/documentation-6c.html"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chatbox/generalsettings', 'more information on how to use it'); ?> </a></label> <input class="form-control" type="text" name="SecretHash" value="<?php isset($chatbox_data['chatbox_secret_hash']) && $chatbox_data['chatbox_secret_hash'] != '' ? print $chatbox_data['chatbox_secret_hash'] : (print erLhcoreClassChat::generateHash()); ?> " /> </div> <input type="submit" class="btn btn-default" name="StoreChatboxSettings" value="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('system/buttons', 'Save'); ?> " /> </form>
public function createArchive() { $items = erLhcoreClassChat::getList(array('filter' => array('range_from' => $this->range_from, 'range_to' => $this->range_to)), 'erLhcoreClassModelChatArchiveRange', 'lh_chat_archive_range'); if (empty($items)) { $this->saveThis(); } else { $item = array_shift($items); $this->id = $item->id; } $db = ezcDbInstance::get(); $stmt = $db->prepare("SHOW TABLES LIKE 'lh_chat_archive_{$this->id}'"); $stmt->execute(); $exists = $stmt->fetch(); if ($exists === false) { // Create archive chat table $stmt = $db->prepare('SHOW CREATE TABLE `lh_chat`;'); $stmt->execute(); $rows = $stmt->fetch(); $command = $rows[1]; $command = preg_replace('/AUTO_INCREMENT\\=[0-9]+/i', 'AUTO_INCREMENT=1', $command); $command = str_replace("`lh_chat`", "`lh_chat_archive_{$this->id}`", $command); $db->query($command); // Create archive msg table $stmt = $db->prepare('SHOW CREATE TABLE `lh_msg`;'); $stmt->execute(); $rows = $stmt->fetch(); $command = $rows[1]; $command = preg_replace('/AUTO_INCREMENT\\=[0-9]+/i', 'AUTO_INCREMENT=1', $command); $command = str_replace("`lh_msg`", "`lh_chat_archive_msg_{$this->id}`", $command); $db->query($command); } return $this->id; }
<div class="message-row system-response"> <div class="msg-date"><?php echo erLhcoreClassChat::formatDate($msg['time']); ?> </div><i><span class="usr-tit sys-tit"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmin', 'System assistant'); ?> </span><?php echo erLhcoreClassBBCode::make_clickable(htmlspecialchars($msg['msg'])); ?> </i> </div>
if (isset($_GET['doSearch'])) { $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'chat_search', 'format_filter' => true, 'use_override' => true, 'uparams' => $Params['user_parameters_unordered'])); $filterParams['is_search'] = true; } else { $filterParams = erLhcoreClassSearchHandler::getParams(array('module' => 'chat', 'module_file' => 'chat_search', 'format_filter' => true, 'uparams' => $Params['user_parameters_unordered'])); $filterParams['is_search'] = false; } $append = erLhcoreClassSearchHandler::getURLAppendFromInput($filterParams['input_form']); // Set correct archive tables $archive->setArchiveTables(); $pages = new lhPaginator(); $pages->serverURL = erLhcoreClassDesign::baseurl('chatarchive/listarchivechats') . '/' . $archive->id . $append; $pages->items_total = erLhcoreClassChat::getCount($filterParams['filter'], erLhcoreClassModelChatArchiveRange::$archiveTable); $pages->setItemsPerPage(2); $pages->paginate(); $items = array(); if ($pages->items_total > 0) { try { $items = erLhcoreClassChat::getList(array_merge(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id ASC'), $filterParams['filter']), 'erLhcoreClassModelChatArchive', erLhcoreClassModelChatArchiveRange::$archiveTable); } catch (Exception $e) { print_r($e->getMessage()); } } $filterParams['input_form']->form_action = erLhcoreClassDesign::baseurl('chatarchive/listarchivechats') . '/' . $archive->id; $tpl->set('input', $filterParams['input_form']); $tpl->set('items', $items); $tpl->set('archive', $archive); $tpl->set('pages', $pages); $Result['content'] = $tpl->fetch(); $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('department/departments', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('chatarchive/archive'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatarchive/archive', 'Chat archive')), array('url' => erLhcoreClassDesign::baseurl('chatarchive/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatarchive/list', 'Archives list'))); $Result['path'][] = array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatarchive/list', 'Archived chats'));
} else { // Default auto responder $responder = erLhAbstractModelAutoResponder::processAutoResponder($chat); if ($responder instanceof erLhAbstractModelAutoResponder) { $chat->wait_timeout = $responder->wait_timeout; $chat->timeout_message = $responder->timeout_message; $chat->wait_timeout_send = 1 - $responder->repeat_number; $chat->wait_timeout_repeat = $responder->repeat_number; if ($responder->wait_message != '') { $msg = new erLhcoreClassModelmsg(); $msg->msg = trim($responder->wait_message); $msg->chat_id = $chat->id; $msg->name_support = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Live Support'); $msg->user_id = 1; $msg->time = time() + 5; erLhcoreClassChat::getSession()->save($msg); } } } // Set chat attributes for transfer workflow logic if ($chat->department !== false && $chat->department->department_transfer_id > 0) { $chat->transfer_if_na = 1; $chat->transfer_timeout_ts = time(); $chat->transfer_timeout_ac = $chat->department->transfer_timeout; } $chat->last_msg_id = $msg->id; $chat->last_user_msg_time = time(); $chat->saveThis(); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => &$chat)); // Redirect user erLhcoreClassModule::redirect('chat/chatwidgetchat/' . $chat->id . '/' . $chat->hash . $modeAppendTheme . '/(cstarted)/chat_started_by_invitation_cb');
<div role="tabpanel" class="tab-pane" id="userchats"> <ul class="foot-print-content list-unstyled" style="max-height: 170px;"> <?php foreach (erLhcoreClassChat::getList(array('limit' => 100, 'filter' => array('online_user_id' => $online_user->id))) as $chatPrev) { ?> <?php if (!isset($chat) || $chat->id != $chatPrev->id) { ?> <li> <?php if (!empty($chatPrev->country_code)) { ?> <img src="<?php echo erLhcoreClassDesign::design('images/flags'); ?> /<?php echo $chatPrev->country_code; ?> .png" alt="<?php echo htmlspecialchars($chatPrev->country_name); ?> " title="<?php echo htmlspecialchars($chatPrev->country_name); ?> " /> <?php } ?> <a title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface', 'Open in a new window'); ?> " class="material-icons" onclick="lhinst.startChatNewWindow('<?php
<?php try { $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); if (erLhcoreClassChat::hasAccessToRead($chat)) { $lastMessage = erLhcoreClassChat::getGetLastChatMessageEdit($chat->id, $currentUser->getUserID()); if (isset($lastMessage['msg'])) { $array = array(); $array['id'] = $lastMessage['id']; $array['msg'] = preg_replace('#\\[translation\\](.*?)\\[/translation\\]#is', '', $lastMessage['msg']); $array['error'] = 'f'; echo json_encode($array); } else { echo json_encode(array('error' => 't')); } } } catch (Exception $e) { echo json_encode(array('error' => 't')); } exit;
<?php header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); header('Content-type: text/javascript'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 8) . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); $tpl = erLhcoreClassTemplate::getInstance('lhchat/chatcheckstatus.tpl.php'); if (is_array($Params['user_parameters_unordered']['department'])) { erLhcoreClassChat::validateFilterIn($Params['user_parameters_unordered']['department']); $tpl->set('department', implode('/', $Params['user_parameters_unordered']['department'])); $tpl->set('department_array', $Params['user_parameters_unordered']['department']); } else { $tpl->set('department', false); $tpl->set('department_array', false); } $tpl->set('status', $Params['user_parameters_unordered']['status'] == 'true' ? true : false); if (erLhcoreClassModelChatConfig::fetch('track_is_online')->current_value) { $ignorable_ip = erLhcoreClassModelChatConfig::fetch('ignorable_ip')->current_value; if ($ignorable_ip == '' || !erLhcoreClassIPDetect::isIgnored(erLhcoreClassIPDetect::getIP(), explode(',', $ignorable_ip))) { if ((string) $Params['user_parameters_unordered']['vid'] != '') { $db = ezcDbInstance::get(); /** * Perhaps there is some pending operations for online visitor * */ $stmt = $db->prepare('SELECT operation FROM lh_chat_online_user WHERE vid = :vid'); $stmt->bindValue(':vid', (string) $Params['user_parameters_unordered']['vid']); $stmt->execute(); $operation = $stmt->fetch(PDO::FETCH_COLUMN);
} $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)); echo json_encode(array('error' => 'false', 'result' => $ReturnMessages)); exit;
public function __get($var) { switch ($var) { case 'time_created_front': $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time); return $this->time_created_front; break; case 'user_closed_ts_front': $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts); return $this->user_closed_ts_front; break; case 'is_operator_typing': $this->is_operator_typing = $this->operator_typing > time() - 60; // typing is considered if status did not changed for 30 seconds return $this->is_operator_typing; break; case 'is_user_typing': $this->is_user_typing = $this->user_typing > time() - 10; // typing is considered if status did not changed for 30 seconds return $this->is_user_typing; break; case 'wait_time_seconds': $this->wait_time_seconds = time() - $this->time; return $this->wait_time_seconds; case 'wait_time_front': $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time); return $this->wait_time_front; break; case 'wait_time_pending': $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time); return $this->wait_time_pending; break; case 'chat_duration_front': $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration); return $this->chat_duration_front; break; case 'user_name': return $this->user_name = (string) $this->user; break; case 'plain_user_name': $this->plain_user_name = false; if ($this->user !== false) { $this->plain_user_name = (string) $this->user->name_support; } return $this->plain_user_name; break; case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id, true); } catch (Exception $e) { $this->user = false; } } return $this->user; break; case 'operator_typing_user': $this->operator_typing_user = false; if ($this->operator_typing_id > 0) { try { $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id); } catch (Exception $e) { $this->operator_typing_user = false; } } return $this->operator_typing_user; break; case 'online_user': $this->online_user = false; if ($this->online_user_id > 0) { try { $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id); } catch (Exception $e) { $this->online_user = false; } } return $this->online_user; break; case 'department': $this->department = false; if ($this->dep_id > 0) { try { $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true); } catch (Exception $e) { } } return $this->department; break; case 'product': $this->product = false; if ($this->product_id > 0) { try { $this->product = erLhAbstractModelProduct::fetch($this->product_id, true); } catch (Exception $e) { } } return $this->product; break; case 'product_name': $this->product_name = (string) $this->product; return $this->product_name; break; case 'department_name': return $this->department_name = (string) $this->department; break; case 'number_in_queue': $this->number_in_queue = 1; if ($this->status == self::STATUS_PENDING_CHAT) { $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1; } return $this->number_in_queue; break; case 'screenshot': $this->screenshot = false; if ($this->screenshot_id > 0) { try { $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id); } catch (Exception $e) { } } return $this->screenshot; break; case 'unread_time': $diff = time() - $this->last_user_msg_time; $hours = floor($diff / 3600); $minits = floor(($diff - $hours * 3600) / 60); $seconds = $diff - $hours * 3600 - $minits * 60; $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds); return $this->unread_time; break; case 'user_tz_identifier_time': $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier)); $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat); return $this->user_tz_identifier_time; break; case 'additional_data_array': $jsonData = json_decode($this->additional_data); if ($jsonData !== null) { $this->additional_data_array = $jsonData; } else { $this->additional_data_array = $this->additional_data; } return $this->additional_data_array; break; case 'chat_variables_array': if (!empty($this->chat_variables)) { $jsonData = json_decode($this->chat_variables, true); if ($jsonData !== null) { $this->chat_variables_array = $jsonData; } else { $this->chat_variables_array = $this->chat_variables; } } else { $this->chat_variables_array = $this->chat_variables; } return $this->chat_variables_array; break; case 'user_status_front': if ($this->online_user !== false) { $this->user_status_front = erLhcoreClassChat::setActivityByChatAndOnlineUser($this, $this->online_user); } else { $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1; } return $this->user_status_front; break; default: break; } }
} try { if (is_numeric((string) $Params['user_parameters_unordered']['chatid']) && $Params['user_parameters_unordered']['chatid'] > 0) { if ((string) $Params['user_parameters_unordered']['hash'] != '') { $hash = $Params['user_parameters_unordered']['hash']; } if (is_numeric($Params['user_parameters_unordered']['chatid'])) { $chat = erLhcoreClassModelChat::fetch($Params['user_parameters_unordered']['chatid']); } } else { if ((string) $Params['user_parameters_unordered']['hash'] != '') { list($chatID, $hash) = explode('_', $Params['user_parameters_unordered']['hash']); $chat = erLhcoreClassModelChat::fetch($chatID); } } erLhcoreClassChat::setTimeZoneByChat($chat); if ($chat->hash == $hash) { $survey = erLhAbstractModelSurvey::fetch($Params['user_parameters_unordered']['survey']); if ($survey instanceof erLhAbstractModelSurvey) { $surveyItem = erLhAbstractModelSurveyItem::getInstance($chat, $survey); if (isset($_POST['Vote'])) { $errors = erLhcoreClassSurveyValidator::validateSurvey($surveyItem, $survey); if (empty($errors)) { $surveyItem->saveOrUpdate(); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('survey.filled', array('chat' => &$chat, 'survey' => $survey, 'survey_item' => &$surveyItem)); $tpl->set('just_stored', true); } else { $tpl->set('errors', $errors); } } $tpl->set('chat', $chat);