public static function getList($paramsSearch = array()) { if (!isset($paramsSearch['sort'])) { $paramsSearch['sort'] = 'id ASC'; } return erLhcoreClassChat::getList($paramsSearch, 'erLhcoreClassModelmsg', 'lh_msg'); }
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 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; }
<?php $online_user = erLhcoreClassModelChatOnlineUser::fetchByVid($Params['user_parameters']['vid']); if ($online_user !== false) { $tpl = erLhcoreClassTemplate::getInstance('lhfile/chatfileslistuser.tpl.php'); $tpl->set('items', erLhcoreClassChat::getList(array('filter' => array('online_user_id' => $online_user->id), 'limit' => 100, 'sort' => 'id DESC'), 'erLhcoreClassModelChatFile', 'lh_chat_file')); echo json_encode(array('result' => $tpl->fetch())); } exit;
?> <ul class="list-unstyled"><li ng-repeat="operator in online_op.list track by operator.id" ><a ng-show="operator.user_id != <?php echo erLhcoreClassUser::instance()->getUserID(); ?> " href="#" ng-click="lhc.startChatOperator(operator.user_id)" class="small button round">Start chat</a> {{operator.name_support}} | Last activity: {{operator.lastactivity_ago}} ago.</li></ul><?php } ?> </div></div><?php } } } ?> </div></div></div><script>$( document ).ready(function() {lhinst.attachTabNavigator();$('#right-column-page').removeAttr('id');$('#tabs a:first').tab('show')});<?php $chatsOpen = CSCacheAPC::getMem()->getArray('lhc_open_chats'); if (!empty($chatsOpen)) { $chats = erLhcoreClassChat::getList(array('filterin' => array('id' => $chatsOpen))); $deleteKeys = array_diff($chatsOpen, array_keys($chats)); foreach ($deleteKeys as $chat_id) { CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat_id); } foreach ($chats as $chat) { if (erLhcoreClassChat::hasAccessToRead($chat)) { echo "lhinst.startChat('{$chat->id}',\$('#tabs'),'" . erLhcoreClassDesign::shrt($chat->nick, 10, '...', 30, ENT_QUOTES) . "');"; } else { CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat->id); } } } ?> </script><?php } else {
<?php $tpl = erLhcoreClassTemplate::getInstance('lhchatarchive/list.tpl.php'); $pages = new lhPaginator(); $pages->serverURL = erLhcoreClassDesign::baseurl('chatarchive/list'); $pages->items_total = erLhcoreClassChat::getCount(array(), 'lh_chat_archive_range', 'count(id)'); $pages->setItemsPerPage(20); $pages->paginate(); $items = array(); if ($pages->items_total > 0) { $items = erLhcoreClassChat::getList(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id ASC'), 'erLhcoreClassModelChatArchiveRange', 'lh_chat_archive_range'); } $tpl->set('items', $items); $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'))); $Result['path'][] = array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatarchive/list', 'Archives list'));
<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
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; }
$tpl->set('items', $items); $Result['content'] = $tpl->fetch(); $Result['pagelayout'] = 'popup'; return; } if (in_array($Params['user_parameters_unordered']['xls'], array(1, 2))) { erLhcoreClassChatExport::chatListExportXLS(erLhcoreClassChat::getList(array_merge($filterParams['filter'], array('limit' => 100000, 'offset' => 0))), array('type' => (int) $Params['user_parameters_unordered']['xls'])); exit; } $append = erLhcoreClassSearchHandler::getURLAppendFromInput($filterParams['input_form']); $pages = new lhPaginator(); $pages->items_total = erLhcoreClassChat::getCount($filterParams['filter']); $pages->translationContext = 'chat/pendingchats'; $pages->serverURL = erLhcoreClassDesign::baseurl('chat/list') . $append; $pages->paginate(); $tpl->set('pages', $pages); if ($pages->items_total > 0) { $items = erLhcoreClassChat::getList(array_merge($filterParams['filter'], array('limit' => $pages->items_per_page, 'offset' => $pages->low))); erLhcoreClassChat::setOnlineStatusDirectly($items); $tpl->set('items', $items); } $filterParams['input_form']->form_action = erLhcoreClassDesign::baseurl('chat/list'); $tpl->set('input', $filterParams['input_form']); $tpl->set('inputAppend', $append); $tpl->set('can_delete_global', $currentUser->hasAccessTo('lhchat', 'deleteglobalchat')); $tpl->set('can_delete_general', $currentUser->hasAccessTo('lhchat', 'deletechat')); $tpl->set('can_close_global', $currentUser->hasAccessTo('lhchat', 'allowcloseremote')); $tpl->set('current_user_id', $currentUser->getUserID()); $Result['content'] = $tpl->fetch(); $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('chat/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/pendingchats', 'Chats list'))); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.list_path', array('result' => &$Result));
<?php $tpl = erLhcoreClassTemplate::getInstance('lhchatarchive/viewarchivedchat.tpl.php'); $archive = erLhcoreClassModelChatArchiveRange::fetch($Params['user_parameters']['archive_id']); $archive->setTables(); $chat = erLhcoreClassModelChatArchive::fetch($Params['user_parameters']['chat_id']); $tpl->set('chat', $chat); $tpl->set('messages', erLhcoreClassChat::getList(array('limit' => 1000, 'filter' => array('chat_id' => $chat->id)), 'erLhcoreClassModelChatArchiveMsg', erLhcoreClassModelChatArchiveRange::$archiveMsgTable)); $tpl->set('archive', $archive); $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')), array('url' => erLhcoreClassDesign::baseurl('chatarchive/listarchivechats') . '/' . $archive->id, 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatarchive/list', 'Archived chats'))); $Result['path'][] = array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chatarchive/viewarchivedchat', 'View archived chat'));
/** * Chat's list */ public static function validateChatList() { $validAttributes = array('int' => array('departament_id' => array('type' => 'filter', 'field' => 'dep_id', 'validator' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1))), 'user_id' => array('type' => 'filter', 'field' => 'user_id', 'validator' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1))), 'status' => array('type' => 'filter', 'field' => 'status', 'validator' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1))))); $filter = self::formatFilter($validAttributes); $limitation = self::getLimitation(); // Does not have any assigned department if ($limitation === false) { return array('list' => array(), 'list_count' => 0); } if ($limitation !== true) { $filter['customfilter'][] = $limitation; } // Get chats list $chats = erLhcoreClassChat::getList($filter); // Get chats count $chatsCount = erLhcoreClassChat::getCount($filter); // Chats list return array('list' => array_values($chats), 'list_count' => $chatsCount, 'error' => false); }
public static function getTablesStatus($definition) { $db = ezcDbInstance::get(); $tablesStatus = array(); // Get archive tables $archives = erLhcoreClassChat::getList(array('offset' => 0, 'limit' => 1000000, 'sort' => 'id ASC'), 'erLhcoreClassModelChatArchiveRange', 'lh_chat_archive_range'); // Update archives tables also foreach ($archives as $archive) { $archive->setTables(); $definition['tables'][erLhcoreClassModelChatArchiveRange::$archiveTable] = $definition['tables']['lh_chat']; $definition['tables'][erLhcoreClassModelChatArchiveRange::$archiveMsgTable] = $definition['tables']['lh_msg']; } foreach ($definition['tables'] as $table => $tableDefinition) { $tablesStatus[$table] = array('error' => false, 'status' => '', 'queries' => array()); try { $sql = 'SHOW COLUMNS FROM ' . $table; $stmt = $db->prepare($sql); $stmt->execute(); $columnsData = $stmt->fetchAll(PDO::FETCH_ASSOC); $columnsDesired = (array) $tableDefinition; $status = array(); foreach ($columnsDesired as $columnDesired) { $columnFound = false; $typeMatch = true; foreach ($columnsData as $column) { if ($columnDesired['field'] == $column['field']) { $columnFound = true; if ($columnDesired['type'] != $column['type']) { $typeMatch = false; } } } if ($typeMatch == false) { $tablesStatus[$table]['error'] = true; $status[] = "[{$columnDesired['field']}] column type is not correct"; $extra = ''; if ($columnDesired['extra'] == 'auto_increment') { $extra = ' AUTO_INCREMENT'; } $tablesStatus[$table]['queries'][] = "ALTER TABLE `{$table}`\r\n\t\t\t\t\t\tCHANGE `{$columnDesired['field']}` `{$columnDesired['field']}` {$columnDesired['type']} NOT NULL{$extra};"; } if ($columnFound == false) { $tablesStatus[$table]['error'] = true; $status[] = "[{$columnDesired['field']}] column was not found"; $default = ''; if ($columnDesired['default'] != null) { $default = " DEFAULT '{$columnDesired['default']}'"; } $tablesStatus[$table]['queries'][] = "ALTER TABLE `{$table}`\r\n\t\t\t\t\t\tADD `{$columnDesired['field']}` {$columnDesired['type']} NOT NULL{$default},\r\n\t\t\t\t\t\tCOMMENT='';"; } } if (!empty($status)) { $tablesStatus[$table]['status'] = implode(", ", $status); $tablesStatus[$table]['error'] = true; } } catch (Exception $e) { $tablesStatus[$table]['error'] = true; $tablesStatus[$table]['status'] = "table does not exists"; $tablesStatus[$table]['queries'][] = $definition['tables_create'][$table]; } } foreach ($definition['tables_indexes'] as $table => $dataTableIndex) { try { $sql = 'SHOW INDEX FROM ' . $table; $stmt = $db->prepare($sql); $stmt->execute(); $columnsData = $stmt->fetchAll(PDO::FETCH_ASSOC); $status = array(); $existingIndexes = array(); foreach ($columnsData as $indexData) { $existingIndexes[] = $indexData['key_name']; } $existingIndexes = array_unique($existingIndexes); $newIndexes = array_diff(array_keys($dataTableIndex['new']), $existingIndexes); foreach ($newIndexes as $newIndex) { $tablesStatus[$table]['queries'][] = $dataTableIndex['new'][$newIndex]; $status[] = "{$newIndex} index was not found"; } $removeIndexes = array_intersect($dataTableIndex['old'], $existingIndexes); foreach ($removeIndexes as $removeIndex) { $tablesStatus[$table]['queries'][] = "ALTER TABLE `{$table}` DROP INDEX `{$removeIndex}`;"; $tablesStatus[$table]['error'] = true; $status[] = "{$removeIndex} legacy index was found"; } if (!empty($status)) { $tablesStatus[$table]['status'] = implode(", ", $status); $tablesStatus[$table]['error'] = true; } } catch (Exception $e) { // Just not existing table perhaps } } foreach ($definition['tables_data'] as $table => $dataTable) { $tableIdentifier = $definition['tables_data_identifier'][$table]; $status = array(); // Check that table has all required records foreach ($dataTable as $record) { try { $sql = "SELECT COUNT(*) as total_records FROM `{$table}` WHERE `{$tableIdentifier}` = :identifier_value"; $stmt = $db->prepare($sql); $stmt->bindValue(':identifier_value', $record[$tableIdentifier]); $stmt->execute(); $columnsData = $stmt->fetchColumn(); if ($columnsData == 0) { $status[] = "Record with identifier {$tableIdentifier} = {$record[$tableIdentifier]} was not found"; $columns = array(); $values = array(); foreach ($record as $column => $value) { $columns[] = '`' . $column . '`'; $values[] = $db->quote($value); } $tablesStatus[$table]['queries'][] = "INSERT INTO `{$table}` (" . implode(',', $columns) . ") VALUES (" . implode(',', $values) . ")"; } } catch (Exception $e) { $status[] = "Record with identifier {$tableIdentifier} = {$record[$tableIdentifier]} was not found"; $columns = array(); $values = array(); foreach ($record as $column => $value) { $columns[] = '`' . $column . '`'; $values[] = $db->quote($value); } $tablesStatus[$table]['queries'][] = "INSERT INTO `{$table}` (" . implode(',', $columns) . ") VALUES (" . implode(',', $values) . ")"; // Perhaps table does not exists } } if (!empty($status)) { $tablesStatus[$table]['status'] .= implode(", ", $status); $tablesStatus[$table]['error'] = true; } } return $tablesStatus; }
public static function autoInformVisitor($minutesTimeout) { if ($minutesTimeout > 0) { $items = erLhcoreClassChat::getList(array('limit' => 10, 'filterlt' => array('last_op_msg_time' => time() - 1 * 60), 'filter' => array('has_unread_op_messages' => 1, 'unread_op_messages_informed' => 0))); // Update chats instantly foreach ($items as $item) { $item->has_unread_op_messages = 0; $item->unread_op_messages_informed = 1; $item->updateThis(); } // Now inform visitors foreach ($items as $item) { erLhcoreClassChatMail::informVisitorUnreadMessage($item); } } }
* * */ echo "Starting chat/workflow\n"; if (erLhcoreClassModelChatConfig::fetch('run_departments_workflow')->current_value == 1) { echo "Starting departments workflow\n"; $ts = time(); foreach (erLhcoreClassChat::getList(array('limit' => 500, 'customfilter' => array('transfer_timeout_ts < (' . $ts . '-transfer_timeout_ac)'), 'filter' => array('status' => erLhcoreClassModelChat::STATUS_PENDING_CHAT, 'transfer_if_na' => 1))) as $chat) { $canExecuteWorkflow = true; if (erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value >= 0) { if ($chat->department !== false && $chat->department->department_transfer_id > 0) { $canExecuteWorkflow = erLhcoreClassChat::getPendingChatsCountPublic($chat->department->department_transfer_id) <= erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value; } } if ($canExecuteWorkflow == true) { erLhcoreClassChatWorkflow::transferWorkflow($chat); echo "executing department transfer workflow for - ", $chat->id, "\n"; } else { echo "Skipping transfer because dedicated department queue is full\n"; } } echo "Ended departments workflow\n"; } // Unanswered chats callback echo erLhcoreClassChatWorkflow::mainUnansweredChatWorkflow(); echo "Closed chats - ", erLhcoreClassChatWorkflow::automaticChatClosing(), "\n"; echo "Purged chats - ", erLhcoreClassChatWorkflow::automaticChatPurge(), "\n"; foreach (erLhcoreClassChat::getList(array('limit' => 500, 'filter' => array('status' => erLhcoreClassModelChat::STATUS_PENDING_CHAT))) as $chat) { erLhcoreClassChatWorkflow::autoAssign($chat, $chat->department); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.pending_process_workflow', array('chat' => &$chat)); } echo "Ended chat/workflow\n";
public static function deleteByChatId($chat_id) { foreach (erLhcoreClassChat::getList(array('filter' => array('chat_id' => $chat_id)), 'erLhcoreClassModelChatFile', 'lh_chat_file') as $file) { $file->removeThis(); } }
<?php $tpl = erLhcoreClassTemplate::getInstance('lhchat/activechats.tpl.php'); if (isset($_POST['doDelete'])) { if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('chat/activechats'); exit; } $definition = array('ChatID' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', null, FILTER_REQUIRE_ARRAY)); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if ($form->hasValidData('ChatID')) { $chats = erLhcoreClassChat::getList(array('filterin' => array('id' => $form->ChatID))); foreach ($chats as $chatToDelete) { CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chatToDelete->id); if ($currentUser->hasAccessTo('lhchat', 'deleteglobalchat') || $currentUser->hasAccessTo('lhchat', 'deletechat') && $chatToDelete->user_id == $currentUser->getUserID()) { $chatToDelete->removeThis(); } } } } 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; } if ($Params['user_parameters_unordered']['print'] == 1) { $tpl = erLhcoreClassTemplate::getInstance('lhchat/printchats.tpl.php'); $items = erLhcoreClassChat::getActiveChats(10000, 0, $filterParams['filter']);
<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; ?>
<?php $tpl = erLhcoreClassTemplate::getInstance('lhfile/chatfileslist.tpl.php'); $tpl->set('items', erLhcoreClassChat::getList(array('filter' => array('chat_id' => $Params['user_parameters']['chat_id']), 'limit' => 100, 'sort' => 'id DESC'), 'erLhcoreClassModelChatFile', 'lh_chat_file')); echo json_encode(array('result' => $tpl->fetch())); exit;
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'));
public static function automaticChatPurge() { $purgedChatsNumber = 0; $timeout = (int) erLhcoreClassModelChatConfig::fetch('autopurge_timeout')->current_value; if ($timeout > 0) { $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_CLOSED_CHAT))) as $chat) { $chat->removeThis(); erLhcoreClassChat::updateActiveChats($chat->user_id); $purgedChatsNumber++; } } return $purgedChatsNumber; }
<?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')));
$format = (string) $Params['user_parameters_unordered']['format'] == 'xml' ? 'xml' : 'json'; $hashSecret = erLhcoreClassModelChatConfig::fetch('export_hash')->current_value; try { if (sha1('getlist' . $hashSecret) == $hash) { $filter = array(); if (is_array($Params['user_parameters_unordered']['status'])) { foreach ($Params['user_parameters_unordered']['status'] as $status) { $filter['filterin']['status'][] = (int) $status; } } $totalChats = erLhcoreClassChat::getCount($filter); $pages = new lhPaginator(); $pages->items_total = $totalChats; $pages->setItemsPerPage(is_numeric($Params['user_parameters_unordered']['limit']) ? (int) $Params['user_parameters_unordered']['limit'] : 100); $pages->paginate(); $list = erLhcoreClassChat::getList(array_merge(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id DESC'), $filter)); if ($format == 'json') { header('Content-type: application/json'); echo json_encode(array('list' => array_keys($list))); exit; } else { header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="utf-8" ?><lhc>'; foreach (array_keys($list) as $id) { echo "<item>{$id}</item>"; } echo '</lhc>'; exit; } } else { throw new Exception('Invalid hash.');