getCount() 공개 정적인 메소드

public static getCount ( $params = [], $table = 'lh_chat', $operation = 'COUNT(id)' )
 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);
 }
예제 #3
0
 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]);
     }
 }
 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);
     }
 }
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only visitors)');
?>
</td>
		<td><?php 
$totalVisitorsMessagesCount = erLhcoreClassChat::getCount(array_merge_recursive($filter24, array('filter' => array('user_id' => 0))), 'lh_msg');
echo $totalVisitorsMessagesCount;
?>
</td>
	</tr>
	<tr>
		<td><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only system messages)');
?>
</td>
		<td><?php 
$systemMessagesCount = erLhcoreClassChat::getCount(array_merge_recursive($filter24, array('filter' => array('user_id' => -1))), 'lh_msg');
echo $systemMessagesCount;
?>
</td>
	</tr>
	<tr>
		<td><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only operators)');
?>
</td>
		<td><?php 
echo $totalMessagesCount - $systemMessagesCount - $totalVisitorsMessagesCount;
?>
</td>
	</tr>
</table>
 public static function getCount($params = array())
 {
     return erLhcoreClassChat::getCount($params, "lh_chat_online_user");
 }
 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;
         case 'mod_start_hour_front':
         case 'tud_start_hour_front':
         case 'wed_start_hour_front':
         case 'thd_start_hour_front':
         case 'frd_start_hour_front':
         case 'sad_start_hour_front':
         case 'sud_start_hour_front':
             $startHourName = str_replace('_start_hour_front', '', $var) . '_start_hour';
             return $this->{$startHourName} != -1 ? floor($this->{$startHourName} / 100) : '';
             break;
         case 'mod_start_minutes_front':
         case 'tud_start_minutes_front':
         case 'wed_start_minutes_front':
         case 'thd_start_minutes_front':
         case 'frd_start_minutes_front':
         case 'sad_start_minutes_front':
         case 'sud_start_minutes_front':
             $startHourName = str_replace('_start_minutes_front', '', $var) . '_start_hour';
             $startHourFrontName = str_replace('_start_minutes_front', '', $var) . '_start_hour_front';
             return $this->{$startHourName} != -1 ? $this->{$startHourName} - $this->{$startHourFrontName} * 100 : '';
             break;
         case 'mod_end_hour_front':
         case 'tud_end_hour_front':
         case 'wed_end_hour_front':
         case 'thd_end_hour_front':
         case 'frd_end_hour_front':
         case 'sad_end_hour_front':
         case 'sud_end_hour_front':
             $endHourName = str_replace('_end_hour_front', '', $var) . '_end_hour';
             return $this->{$endHourName} != -1 ? floor($this->{$endHourName} / 100) : '';
             break;
         case 'mod_end_minutes_front':
         case 'tud_end_minutes_front':
         case 'wed_end_minutes_front':
         case 'thd_end_minutes_front':
         case 'frd_end_minutes_front':
         case 'sad_end_minutes_front':
         case 'sud_end_minutes_front':
             $endHourName = str_replace('_end_minutes_front', '', $var) . '_end_hour';
             $endHourFrontName = str_replace('_end_minutes_front', '', $var) . '_end_hour_front';
             return $this->{$endHourName} != -1 ? $this->{$endHourName} - $this->{$endHourFrontName} * 100 : '';
             break;
         default:
             break;
     }
 }
예제 #8
0
 public static function updateActiveChats($user_id)
 {
     $db = ezcDbInstance::get();
     $stmt = $db->prepare('UPDATE lh_userdep SET active_chats = :active_chats WHERE user_id = :user_id');
     $stmt->bindValue(':active_chats', erLhcoreClassChat::getCount(array('filter' => array('user_id' => $user_id, 'status' => erLhcoreClassModelChat::STATUS_ACTIVE_CHAT))), PDO::PARAM_INT);
     $stmt->bindValue(':user_id', $user_id, PDO::PARAM_INT);
     $stmt->execute();
 }
예제 #9
0
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only visitors)');
?>
</td>
						<td><?php 
$totalVisitorsMessagesCount = erLhcoreClassChat::getCount(array('filter' => array('user_id' => 0), 'filtergte' => array('time' => time() - 24 * 3600)), 'lh_msg');
echo $totalVisitorsMessagesCount;
?>
</td>
					</tr>
					<tr>
						<td><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only system messages)');
?>
</td>
						<td><?php 
$systemMessagesCount = erLhcoreClassChat::getCount(array('filter' => array('user_id' => -1), 'filtergte' => array('time' => time() - 24 * 3600)), 'lh_msg');
echo $systemMessagesCount;
?>
</td>
					</tr>
					<tr>
						<td><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only operators)');
?>
</td>
						<td><?php 
echo $totalMessagesCount - $systemMessagesCount - $totalVisitorsMessagesCount;
?>
</td>
					</tr>
				</table>
예제 #10
0
 public static function getAverageChatduration($days = 30)
 {
     $dateUnixPast = mktime(0, 0, 0, date('m'), date('d') - $days, date('y'));
     return erLhcoreClassChat::getCount(array('filtergt' => array('time' => $dateUnixPast, 'chat_duration' => 0), 'filter' => array('status' => erLhcoreClassModelChat::STATUS_CLOSED_CHAT)), 'lh_chat', 'AVG(chat_duration)');
 }
 public function __get($var)
 {
     switch ($var) {
         case 'range_from_front':
             if ($this->range_from != 0) {
                 return date(erLhcoreClassModule::$dateFormat, $this->range_from);
             }
             return '';
             break;
         case 'range_to_front':
             if ($this->range_to != 0) {
                 return date(erLhcoreClassModule::$dateFormat, $this->range_to);
             }
             return '';
             break;
         case 'potential_chats_count':
             $this->potential_chats_count = erLhcoreClassChat::getCount(array('filterlt' => array('time' => $this->range_to), 'filtergt' => array('time' => $this->range_from)));
             return $this->potential_chats_count;
             break;
         case 'chats_in_archive':
             $this->chats_in_archive = 0;
             if ($this->id > 0) {
                 self::$archiveTable = "lh_chat_archive_{$this->id}";
                 self::$archiveMsgTable = "lh_chat_archive_msg_{$this->id}";
                 $this->chats_in_archive = erLhcoreClassChat::getCount(array(), self::$archiveTable);
             }
             return $this->chats_in_archive;
             break;
         case 'messages_in_archive':
             $this->messages_in_archive = 0;
             if ($this->id > 0) {
                 self::$archiveTable = "lh_chat_archive_{$this->id}";
                 self::$archiveMsgTable = "lh_chat_archive_msg_{$this->id}";
                 $this->messages_in_archive = erLhcoreClassChat::getCount(array(), self::$archiveMsgTable);
             }
             return $this->messages_in_archive;
             break;
         default:
             break;
     }
 }
예제 #12
0
<?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')));
 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 '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;
             /**
              * @desc Returns user status based on the following logic
              * 1. Green - if widget is not closed
              * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active
              * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes
              *
              * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site
              * 5. Yellow - from last user message has passed 5 minutes but user still on site
              *
              * 6. Widget is closed and we could not determine online user || None of above conditions are met.
              *
              * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout
              *
              * @param array $params
              *
              * 1 GREEN user has activity in last 5 minutes and ping respond
              * 2 ORANGE user has no activity in last 5 minutes and ping respond
              * 3 GREY Offline user fails to respond pings for X number of times in a row
              *
              * @return int
              */
         /**
          * @desc Returns user status based on the following logic
          * 1. Green - if widget is not closed
          * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active
          * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes
          *
          * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site
          * 5. Yellow - from last user message has passed 5 minutes but user still on site
          *
          * 6. Widget is closed and we could not determine online user || None of above conditions are met.
          *
          * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout
          *
          * @param array $params
          *
          * 1 GREEN user has activity in last 5 minutes and ping respond
          * 2 ORANGE user has no activity in last 5 minutes and ping respond
          * 3 GREY Offline user fails to respond pings for X number of times in a row
          *
          * @return int
          */
         case 'user_status_front':
             $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1;
             if ($this->user_status_front == self::USER_STATUS_CLOSED_CHAT && $this->online_user !== false || erLhcoreClassChat::$onlineCondition == 1 && $this->online_user !== false) {
                 $timeout = (int) erLhcoreClassChat::$trackTimeout || 10;
                 if (erLhcoreClassChat::$trackActivity == true) {
                     if ($this->online_user->last_check_time_ago < $timeout + 10 && $this->online_user->user_active == 1) {
                         //User still on site, it does not matter that he have closed widget.
                         $this->user_status_front = 0;
                     } elseif ($this->online_user->user_active == 0 && $this->online_user->last_check_time_ago < $timeout + 10) {
                         $this->user_status_front = 2;
                     }
                 } else {
                     if ($this->online_user->last_check_time_ago < $timeout + 10 && time() - $this->last_user_msg_time < 300) {
                         //User still on site, it does not matter that he have closed widget.
                         $this->user_status_front = 0;
                     } elseif (time() - $this->last_user_msg_time >= 300 && $this->online_user->last_check_time_ago < $timeout + 10) {
                         $this->user_status_front = 2;
                     }
                 }
             }
             return $this->user_status_front;
             break;
         default:
             break;
     }
 }
예제 #14
0
<?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'));
예제 #15
0
<?php

$hash = (string) $Params['user_parameters']['hash'];
$format = (string) $Params['user_parameters_unordered']['format'] == 'xml' ? 'xml' : 'json';
$hashSecret = erLhcoreClassModelChatConfig::fetch('export_hash')->current_value;
try {
    if (sha1('getcount' . $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);
        if ($format == 'json') {
            header('Content-type: application/json');
            echo json_encode(array('count' => $totalChats));
            exit;
        } else {
            header('Content-type: text/xml');
            echo '<?xml version="1.0" encoding="utf-8" ?>', "<lhc><count>{$totalChats}</count></lhc>";
            exit;
        }
    } else {
        throw new Exception('Invalid hash.');
    }
} catch (Exception $e) {
    if ($format == 'json') {
        header('Content-type: application/json');
        echo json_encode(array('error' => $e->getMessage()));
        exit;
예제 #16
0
}
if ($Params['user_parameters_unordered']['print'] == 1) {
    $tpl = erLhcoreClassTemplate::getInstance('lhchat/printchats.tpl.php');
    $items = erLhcoreClassChat::getList(array_merge($filterParams['filter'], array('limit' => 100000, 'offset' => 0)));
    $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'));
예제 #17
0
 /**
  * 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);
 }
예제 #18
0
$tpl = erLhcoreClassTemplate::getInstance('lhchatarchive/listarchivechats.tpl.php');
$archive = erLhcoreClassModelChatArchiveRange::fetch($Params['user_parameters']['id']);
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);
예제 #19
0
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only visitors)');
?>
</td>
		<td><?php 
$totalVisitorsMessagesCount = erLhcoreClassChat::getCount(array('filter' => array('user_id' => 0)), 'lh_msg');
echo $totalVisitorsMessagesCount;
?>
</td>
	</tr>
	<tr>
		<td><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only system messages)');
?>
</td>
		<td><?php 
$systemMessagesCount = erLhcoreClassChat::getCount(array('filter' => array('user_id' => -1)), 'lh_msg');
echo $systemMessagesCount;
?>
</td>
	</tr>
	<tr>
		<td><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Total messages (only operators)');
?>
</td>
		<td><?php 
echo $totalMessagesCount - $systemMessagesCount - $totalVisitorsMessagesCount;
?>
</td>
	</tr>
</table>
 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;
     }
 }
예제 #21
0
 public static function getAverageChatduration($days = 30, $filter = array())
 {
     if (empty($filter)) {
         $filter['filtergt']['time'] = $dateUnixPast = mktime(0, 0, 0, date('m'), date('d') - $days, date('y'));
     }
     $filter['filtergt']['user_id'] = 0;
     return erLhcoreClassChat::getCount(array_merge_recursive($filter, array('filtergt' => array('chat_duration' => 0), 'filter' => array('status' => erLhcoreClassModelChat::STATUS_CLOSED_CHAT))), 'lh_chat', 'AVG(chat_duration)');
 }