public function __get($var) { switch ($var) { case 'user': $this->user = erLhcoreClassModelUser::fetch($this->user_id); return $this->user; break; default: break; } }
public function __get($var) { switch ($var) { case 'dep_group': $this->dep_group = erLhcoreClassModelDepartamentGroup::fetch($this->dep_group_id); return $this->dep_group; break; case 'user': $this->user = erLhcoreClassModelUser::fetch($this->user_id); return $this->user; break; default: break; } }
public function __get($var) { switch ($var) { case 'user': try { $this->user = erLhcoreClassModelUser::fetch($this->user_id); } catch (Exception $e) { $this->user = '******'; } return $this->user; break; default: break; } }
public function __get($var) { switch ($var) { case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id); } catch (Exception $e) { $this->user = false; } } return $this->user; break; case 'department': $this->department = false; if ($this->department_id > 0) { try { $this->department = erLhcoreClassModelDepartament::fetch($this->department_id, true); } catch (Exception $e) { $this->department = false; } } return $this->department; break; case 'msg_to_user': $this->msg_to_user = str_replace(array_keys($this->replaceData), array_values($this->replaceData), $this->msg); // If not all variables were replaced fallback to fallback message if (preg_match('/\\{[a-zA-Z0-9_]+\\}/i', $this->msg_to_user)) { $this->msg_to_user = str_replace(array_keys($this->replaceData), array_values($this->replaceData), $this->fallback_msg); } return $this->msg_to_user; break; case 'message_title': if ($this->title != '') { $this->message_title = $this->title; } else { $this->message_title = $this->msg_to_user; } return $this->message_title; break; default: break; } }
public function __get($var) { switch ($var) { case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id); } catch (Exception $e) { $this->user = false; } } return $this->user; break; default: break; } }
public function __get($var) { switch ($var) { case 'user': $this->user = erLhcoreClassModelUser::fetch($this->user_id); return $this->user; break; case 'lastactivity_ago': $this->lastactivity_ago = $this->user->lastactivity_ago; return $this->lastactivity_ago; break; case 'name_support': $this->name_support = $this->user->name_support; return $this->name_support; break; case 'name_official': $this->name_official = $this->user->name_official; return $this->name_official; break; case 'departments_names': $this->departments_names = array(); $ids = $this->user->departments_ids; if ($ids != '') { $parts = explode(',', $ids); sort($parts); foreach ($parts as $depId) { if ($depId == 0) { $this->departments_names[] = '∞'; } elseif ($depId > 0) { try { $dep = erLhcoreClassModelDepartament::fetch($depId, true); $this->departments_names[] = $dep->name; } catch (Exception $e) { } } } } return $this->departments_names; break; default: break; } }
public function __get($var) { switch ($var) { case 'file_path_server': $this->file_path_server = $this->file_path . $this->name; return $this->file_path_server; break; case 'security_hash': $this->security_hash = md5($this->name . '_' . $this->chat_id); return $this->security_hash; break; case 'chat': $this->chat = false; if ($this->chat_id > 0) { try { $this->chat = erLhcoreClassModelChat::fetch($this->chat_id); } catch (Exception $e) { $this->chat = new erLhcoreClassModelChat(); } } return $this->chat; break; case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id); } catch (Exception $e) { $this->user = false; } } return $this->user; break; case 'date_front': $this->date_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->date); return $this->date_front; break; default: break; } }
public function __get($var) { switch ($var) { case 'ctime_front': $this->ctime_front = date('Ymd') == date('Ymd', $this->ctime) ? date(erLhcoreClassModule::$dateHourFormat, $this->ctime) : date(erLhcoreClassModule::$dateDateHourFormat, $this->ctime); return $this->ctime_front; break; case 'lactivity_front': $this->lactivity_front = date('Ymd') == date('Ymd', $this->lactivity) ? date(erLhcoreClassModule::$dateHourFormat, $this->lactivity) : date(erLhcoreClassModule::$dateDateHourFormat, $this->lactivity); return $this->lactivity_front; 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 'username_plain': list($this->username_plain) = explode('@', $this->username); return $this->username_plain; break; case 'username_plain_edit': list($this->username_plain_edit) = explode('@', $this->username); $subdomain = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice')->settings['subdomain']; if ($subdomain != '') { $this->username_plain_edit = $this->str_lreplace('.' . $subdomain, '', $this->username_plain_edit); } return $this->username_plain_edit; break; default: break; } }
<?php header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'); header('Content-Type: application/json'); try { erLhcoreClassRestAPIHandler::validateRequest(); if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) { $userData = erLhcoreClassModelUser::fetch((int) $_GET['user_id']); } elseif (isset($_GET['username']) && !empty($_GET['username'])) { $userData = erLhcoreClassModelUser::findOne(array('filter' => array('username' => $_GET['username']))); } elseif (isset($_GET['email']) && !empty($_GET['email'])) { $userData = erLhcoreClassModelUser::findOne(array('filter' => array('email' => $_GET['email']))); } if (!$userData instanceof erLhcoreClassModelUser) { throw new Exception('User could not be found!'); } if ($_GET['status'] == 'true') { $userData->hide_online = 0; $text = 'flash_on'; } else { $text = 'flash_off'; $userData->hide_online = 1; } $userData->operation_admin .= "\$('#online-offline-user').text('" . $text . "');"; erLhcoreClassUser::getSession()->update($userData); erLhcoreClassUserDep::setHideOnlineStatus($userData); erLhcoreClassRestAPIHandler::outputResponse(array('offline' => $userData->hide_online)); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.operator_status_changed', array('user' => &$userData, 'reason' => 'rest_api')); } catch (Exception $e) { echo json_encode(array('error' => true, 'result' => $e->getMessage()));
<?php $tpl = erLhcoreClassTemplate::getInstance('lhuser/edit.tpl.php'); try { $UserData = erLhcoreClassModelUser::fetch((int) $Params['user_parameters']['user_id']); } catch (Exception $e) { erLhcoreClassModule::redirect('user/userlist'); exit; } $tpl->set('tab', $Params['user_parameters_unordered']['tab'] == 'canned' ? 'tab_canned' : ''); if (isset($_POST['Update_account']) || isset($_POST['Save_account'])) { if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('user/edit', '/' . $UserData->id); exit; } $Errors = erLhcoreClassUserValidator::validateUserEdit($UserData); if (isset($_POST['DeletePhoto'])) { $UserData->removeFile(); } $userPhotoErrors = erLhcoreClassUserValidator::validateUserPhoto($UserData); if ($userPhotoErrors !== false) { $Errors = array_merge($Errors, $userPhotoErrors); } if (count($Errors) == 0) { erLhcoreClassUser::getSession()->update($UserData); erLhcoreClassUserDep::setHideOnlineStatus($UserData); $UserData->setUserGroups(); $CacheManager = erConfigClassLhCacheConfig::getInstance(); $CacheManager->expireCache(); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('user.user_modified', array('userData' => &$UserData, 'password' => $UserData->password_front)); if (isset($_POST['Save_account'])) {
$redirectHash = rawurlencode(rawurldecode($Params['user_parameters']['hash'])); header('Location: ' . erLhcoreClassDesign::baseurldirect('site_admin/user/autologin') . '/' . $redirectHash . $redirectFull); exit; } $data = erLhcoreClassModelChatConfig::fetch('autologin_data')->data; if ($data['enabled'] == 1) { $dataRequest = array('r' => base64_decode(rawurldecode($Params['user_parameters_unordered']['r'])), 'u' => rawurldecode($Params['user_parameters_unordered']['u']), 'l' => rawurldecode($Params['user_parameters_unordered']['l']), 't' => rawurldecode($Params['user_parameters_unordered']['t'])); $dataRequest = array_filter($dataRequest); $validateHash = sha1($data['secret_hash'] . sha1($data['secret_hash'] . implode(',', $dataRequest))); if ($validateHash == $Params['user_parameters']['hash']) { if ($dataRequest['t'] > 0 && $dataRequest['t'] < time()) { die(erTranslationClassLhTranslation::getInstance()->getTranslation('users/autologin', 'Autologin hash has expired')); } try { if (is_numeric($dataRequest['u'])) { $userToLogin = erLhcoreClassModelUser::fetch((int) $dataRequest['u']); } else { $users = erLhcoreClassModelUser::getUserList(array('limit' => 1, 'filter' => array('username' => $dataRequest['l']))); if (!empty($users)) { $userToLogin = array_shift($users); } else { die(erTranslationClassLhTranslation::getInstance()->getTranslation('users/autologin', 'Could not find a user')); } } } catch (Exception $e) { die($e->getMessage()); } if ($userToLogin instanceof erLhcoreClassModelUser) { erLhcoreClassUser::instance()->setLoggedUser($userToLogin->id); header('Location: ' . erLhcoreClassDesign::baseurldirect('site_admin') . '/' . ltrim($dataRequest['r'], '/')); exit;
?> ','<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Messages'); ?> '] <?php foreach ($numberOfMsgByUser as $data) { $operator = ''; if ($data['user_id'] == 0) { $operator = 'Visitor'; } elseif ($data['user_id'] == -1) { $operator = 'System assistant'; } elseif ($data['user_id'] == -2) { $operator = 'Virtual assistant'; } else { $operatorObj = erLhcoreClassModelUser::fetch($data['user_id'], true); if (is_object($operatorObj)) { $operator = $operatorObj->username; } else { $operator = '[' . $data['user_id'] . ']'; } } ?> <?php echo ',[\'' . htmlspecialchars($operator, ENT_QUOTES) . '\',' . $data['number_of_chats'] . ']'; ?> <?php } ?> ]); var options = {
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; } }
public function __get($var) { switch ($var) { case 'last_visit_front': return $this->last_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->last_visit); break; case 'first_visit_front': return $this->first_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->first_visit); break; case 'invitation': $this->invitation = false; if ($this->invitation_id > 0) { try { $this->invitation = erLhAbstractModelProactiveChatInvitation::fetch($this->invitation_id); } catch (Exception $e) { $this->invitation = false; } } return $this->invitation; break; case 'has_message_from_operator': return $this->message_seen == 0 && $this->operator_message != ''; break; case 'chat': $this->chat = false; if ($this->chat_id > 0) { try { $this->chat = erLhcoreClassModelChat::fetch($this->chat_id); } catch (Exception $e) { // } } return $this->chat; break; case 'can_view_chat': $this->can_view_chat = false; $currentUser = erLhcoreClassUser::instance(); if ($this->operator_user_id == $currentUser->getUserID()) { $this->can_view_chat = true; // Faster way } else { if ($this->chat instanceof erLhcoreClassModelChat) { $this->can_view_chat = erLhcoreClassChat::hasAccessToRead($this->chat); } } return $this->can_view_chat; break; case 'operator_user': $this->operator_user = false; if ($this->operator_user_id > 0) { try { $this->operator_user = erLhcoreClassModelUser::fetch($this->operator_user_id); } catch (Exception $e) { } } return $this->operator_user; break; case 'operator_user_send': $this->operator_user_send = $this->operator_user !== false; return $this->operator_user_send; break; case 'operator_user_string': $this->operator_user_string = (string) $this->operator_user; return $this->operator_user_string; break; case 'time_on_site_front': $this->time_on_site_front = gmdate(erLhcoreClassModule::$dateHourFormat, $this->time_on_site); return $this->time_on_site_front; break; case 'tt_time_on_site_front': $this->tt_time_on_site_front = null; $diff = $this->tt_time_on_site; $days = floor($diff / (3600 * 24)); $hours = floor(($diff - $days * 3600 * 24) / 3600); $minits = floor(($diff - $hours * 3600 - $days * 3600 * 24) / 60); $seconds = $diff - $hours * 3600 - $minits * 60 - $days * 3600 * 24; if ($days > 0) { $this->tt_time_on_site_front = $days . ' d.'; } elseif ($hours > 0) { $this->tt_time_on_site_front = $hours . ' h.'; } elseif ($minits > 0) { $this->tt_time_on_site_front = $minits . ' m.'; } elseif ($seconds >= 0) { $this->tt_time_on_site_front = $seconds . ' s.'; } return $this->tt_time_on_site_front; break; case 'last_visit_seconds_ago': $this->last_visit_seconds_ago = time() - $this->last_visit; return $this->last_visit_seconds_ago; break; case 'last_check_time_ago': $this->last_check_time_ago = time() - $this->last_check_time; return $this->last_check_time_ago; break; case 'visitor_tz_time': $this->visitor_tz_time = '-'; if ($this->visitor_tz != '') { $date = new DateTime(null, new DateTimeZone($this->visitor_tz)); $this->visitor_tz_time = $date->format(erLhcoreClassModule::$dateHourFormat); } return $this->visitor_tz_time; break; case 'lastactivity_ago': $this->lastactivity_ago = ''; if ($this->last_visit > 0) { $periods = array("s.", "m.", "h.", "d.", "w.", "m.", "y.", "dec."); $lengths = array("60", "60", "24", "7", "4.35", "12", "10"); $difference = time() - $this->last_visit; for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); $this->lastactivity_ago = "{$difference} {$periods[$j]}"; } return $this->lastactivity_ago; 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; default: break; } }
public function __get($var) { switch ($var) { case 'survey': $this->survey = ''; return $this->survey; break; case 'ftime_front': $this->ftime_front = date('Ymd') == date('Ymd', $this->ftime) ? date(erLhcoreClassModule::$dateHourFormat, $this->ftime) : date(erLhcoreClassModule::$dateDateHourFormat, $this->ftime); return $this->ftime_front; break; case 'user': try { $this->user = erLhcoreClassModelUser::fetch($this->user_id, true); } catch (Exception $e) { $this->user = false; } return $this->user; break; case 'is_filled': return !is_null($this->id); 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 'average_stars': return round($this->virtual_total_stars / $this->virtual_chats_number, 2); break; default: break; } }
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_front': $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time); return $this->wait_time_front; 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 '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 '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; default: break; } }
public static function exportAverageOfChatsDialogsByUser($days = 30, $filter = array()) { $data = self::averageOfChatsDialogsByUser($days, $filter, 5000); include 'lib/core/lhform/PHPExcel.php'; $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp; $cacheSettings = array('memoryCacheSize ' => '64MB'); PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->getStyle('A1:AW1')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->setTitle('Report'); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chatexport', 'User ID')); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chatexport', 'Operator')); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chatexport', 'Chat average in seconds')); $i = 2; foreach ($data as $item) { $key = 0; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($key, $i, (string) $item['user_id']); $key++; $obUser = erLhcoreClassModelUser::fetch($item['user_id'], true); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($key, $i, is_object($obUser) ? $obUser->username : $item['user_id']); $key++; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($key, $i, (string) $item['avg_chat_duration']); $i++; } $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); // We'll be outputting an excel file header('Content-type: application/vnd.ms-excel'); // It will be called file.xls header('Content-Disposition: attachment; filename="report.xlsx"'); // Write file to the browser $objWriter->save('php://output'); }
public function __get($var) { switch ($var) { case 'last_visit_front': return $this->last_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->last_visit); break; case 'first_visit_front': return $this->first_visit_front = date(erLhcoreClassModule::$dateDateHourFormat, $this->first_visit); break; case 'invitation': $this->invitation = false; if ($this->invitation_id > 0) { try { $this->invitation = erLhAbstractModelProactiveChatInvitation::fetch($this->invitation_id); } catch (Exception $e) { $this->invitation = false; } } return $this->invitation; break; case 'has_message_from_operator': return $this->message_seen == 0 && $this->operator_message != ''; break; case 'notes_intro': return $this->notes_intro = $this->notes != '' ? '[ ' . mb_substr($this->notes, 0, 50) . ' ]' . '<br/>' : ''; break; case 'chat': $this->chat = false; if ($this->chat_id > 0) { try { $this->chat = erLhcoreClassModelChat::fetch($this->chat_id); } catch (Exception $e) { // } } return $this->chat; break; case 'can_view_chat': $this->can_view_chat = false; $currentUser = erLhcoreClassUser::instance(); if ($this->operator_user_id == $currentUser->getUserID()) { $this->can_view_chat = true; // Faster way } else { if ($this->chat instanceof erLhcoreClassModelChat) { $this->can_view_chat = erLhcoreClassChat::hasAccessToRead($this->chat); } } return $this->can_view_chat; break; case 'operator_user': $this->operator_user = false; if ($this->operator_user_id > 0) { try { $this->operator_user = erLhcoreClassModelUser::fetch($this->operator_user_id); } catch (Exception $e) { } } return $this->operator_user; break; case 'operator_user_send': $this->operator_user_send = $this->operator_user !== false; return $this->operator_user_send; break; case 'operator_user_string': $this->operator_user_string = (string) $this->operator_user; return $this->operator_user_string; break; case 'time_on_site_front': $this->time_on_site_front = gmdate(erLhcoreClassModule::$dateHourFormat, $this->time_on_site); return $this->time_on_site_front; break; case 'tt_time_on_site_front': $this->tt_time_on_site_front = null; $diff = $this->tt_time_on_site; $days = floor($diff / (3600 * 24)); $hours = floor(($diff - $days * 3600 * 24) / 3600); $minits = floor(($diff - $hours * 3600 - $days * 3600 * 24) / 60); $seconds = $diff - $hours * 3600 - $minits * 60 - $days * 3600 * 24; if ($days > 0) { $this->tt_time_on_site_front = $days . ' d.'; } elseif ($hours > 0) { $this->tt_time_on_site_front = $hours . ' h.'; } elseif ($minits > 0) { $this->tt_time_on_site_front = $minits . ' m.'; } elseif ($seconds >= 0) { $this->tt_time_on_site_front = $seconds . ' s.'; } return $this->tt_time_on_site_front; break; case 'last_visit_seconds_ago': $this->last_visit_seconds_ago = time() - $this->last_visit; return $this->last_visit_seconds_ago; break; case 'last_check_time_ago': $this->last_check_time_ago = time() - $this->last_check_time; return $this->last_check_time_ago; break; case 'visitor_tz_time': $this->visitor_tz_time = '-'; if ($this->visitor_tz != '') { $date = new DateTime(null, new DateTimeZone($this->visitor_tz)); $this->visitor_tz_time = $date->format(erLhcoreClassModule::$dateHourFormat); } return $this->visitor_tz_time; break; case 'lastactivity_ago': $this->lastactivity_ago = ''; if ($this->last_visit > 0) { $periods = array("s.", "m.", "h.", "d.", "w.", "m.", "y.", "dec."); $lengths = array("60", "60", "24", "7", "4.35", "12", "10"); $difference = time() - $this->last_visit; for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); $this->lastactivity_ago = "{$difference} {$periods[$j]}"; } return $this->lastactivity_ago; 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 'online_attr_system_array': $this->online_attr_system_array = array(); if ($this->online_attr_system != '') { $this->online_attr_system_array = json_decode($this->online_attr_system, true); } return $this->online_attr_system_array; break; case 'online_status': $this->online_status = 2; // Offline if (erLhcoreClassChat::$trackTimeout == 0) { erLhcoreClassChat::$trackTimeout = 15; } if (erLhcoreClassChat::$trackActivity == true) { if ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && $this->user_active == 1) { //User still on site, it does not matter that he have closed widget. $this->online_status = 0; // Online } elseif ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && $this->user_active == 0) { $this->online_status = 1; // Away } } else { if ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && time() - $this->last_user_msg_time < 300) { //User still on site, it does not matter that he have closed widget. $this->online_status = 0; // Online } elseif ($this->last_check_time_ago < erLhcoreClassChat::$trackTimeout + 10 && time() - $this->last_user_msg_time >= 300) { $this->online_status = 1; // Away } } return $this->online_status; break; default: break; } }
$tpl = erLhcoreClassTemplate::getInstance('lhpermission/request.tpl.php'); $permissionsRequested = (string) $Params['user_parameters']['permissions']; $tpl->set('permission', $permissionsRequested); if (ezcInputForm::hasPostData()) { $definition = array('Permissions' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'UserID' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1))); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect(); exit; } $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); $userRecipient = false; if (!$form->hasValidData('UserID')) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('permission/request', 'Please choose a user!'); } else { $userRecipient = erLhcoreClassModelUser::fetch($form->UserID); } if ($userRecipient !== false && $userRecipient->rec_per_req == 0) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('permission/request', 'This user can not receive permision request!'); } if ($form->hasValidData('Permissions') && $form->Permissions != '') { $permissionsCombinations = explode(',', $form->Permissions); $permissionsRequestedData = array(); foreach ($permissionsCombinations as $combination) { list($module, $function) = explode('_f_', $combination); $moduleName = erLhcoreClassModules::getModuleName($module); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('lhpermission.getmodulename', array('module' => $module, 'name' => &$moduleName)); $functionName = erLhcoreClassModules::getFunctionName($module, $function); $permissionsRequestedData[] = $moduleName . ' - ' . $functionName; } $tpl->set('permission', $form->Permissions);
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'); header('Content-Type: application/json'); try { erLhcoreClassRestAPIHandler::validateRequest(); // init data $user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0; $username = isset($_GET['username']) ? trim($_GET['username']) : ''; $email = isset($_GET['email']) ? trim($_GET['email']) : ''; $password = isset($_GET['password']) ? trim($_GET['password']) : ''; // init param, check what is supplied $param = $username != '' ? array('username' => $username) : array('email' => '00'); // dummy email value to ensure 0 res $param = $email != '' ? array('email' => $email) : $param; // init user $user = $user_id > 0 ? erLhcoreClassModelUser::fetch($user_id) : erLhcoreClassModelUser::findOne(array('filter' => $param)); // check we have data if (!$user instanceof erLhcoreClassModelUser) { throw new Exception('User could not be found!'); } // check if password is given, if so, validate password if ($password != '') { // check password encryption type if (strlen($user->password) == 40) { // get password hash $cfgSite = erConfigClassLhConfig::getInstance(); $secretHash = $cfgSite->getSetting('site', 'secrethash'); $pass_hash = sha1($password . $secretHash . sha1($password)); $verified = $user->password == $pass_hash ? 1 : 0; } else { $verified = password_verify($password, $user->password) ? 1 : 0;
['<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'User'); ?> ','<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Messages'); ?> '] <?php foreach ($numberOfMsgByUser as $data) { $operator = ''; if ($data['user_id'] == 0) { $operator = 'Visitor'; } elseif ($data['user_id'] == -1) { $operator = 'System assistant'; } else { $operator = erLhcoreClassModelUser::fetch($data['user_id'], true)->username; } ?> <?php echo ',[\'' . htmlspecialchars($operator, ENT_QUOTES) . '\',' . $data['number_of_chats'] . ']'; ?> <?php } ?> ]); var options = { title: '<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Number of messages by user'); ?> ', hAxis: {titleTextStyle: {color: 'red'}},
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; } }
/** * Handlers requests like * * May 08 23:02:11 [Warning] [default] [default] {"action":"ping","user":"******"} * May 08 23:02:14 [Warning] [default] [default] {"action":"disconnect","user":"******","server":"xmpp.livehelperchat.com"} * May 08 23:21:52 [Warning] [default] [default] {"action":"connect","user":"******","server":"xmpp.livehelperchat.com"} */ public static function handleOperatorPing($jsonContent) { $params = json_decode($jsonContent, true); $xmppService = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice'); // If ping just update last action if ($params['action'] == 'ping') { // Parse user parts $userParts = self::parseXMPPUser($params['user']); // Fetches user id by xmpp username $userId = self::getUserIDByXMPPUsername($userParts['xmppuser']); // Updates last activity if (is_numeric($userId)) { self::updateActivityByUserId($userId, time() + $xmppService->settings['append_time']); } else { throw new Exception("Could not find LHC user by user - " . $userParts['xmppuser']); } } elseif ($params['action'] == 'disconnect' || $params['action'] == 'connect') { // Fetches user id by xmpp username $userId = self::getUserIDByXMPPUsername($params['user'] . '@' . $params['server']); // Updates last activity to zero if (is_numeric($userId)) { self::updateActivityByUserId($userId, $params['action'] == 'connect' ? time() + $xmppService->settings['append_time'] : 0); if ($params['action'] == 'connect') { $userData = erLhcoreClassModelUser::fetch($userId); if ($userData instanceof erLhcoreClassModelUser && $userData->hide_online == 1) { $userData->hide_online = 0; erLhcoreClassUser::getSession()->update($userData); erLhcoreClassUserDep::setHideOnlineStatus($userData); } } } else { throw new Exception("Could not find LHC user by user - " . $params['user'] . '@' . $params['server']); } } return true; }