本文整理汇总了PHP中erLhcoreClassChat::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassChat::getSession方法的具体用法?PHP erLhcoreClassChat::getSession怎么用?PHP erLhcoreClassChat::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassChat
的用法示例。
在下文中一共展示了erLhcoreClassChat::getSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_file_upload
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
{
$matches = array();
if (strpos($name, '.') === false && preg_match('/^image\\/(gif|jpe?g|png)/', $type, $matches)) {
$name = $uploadFileName = 'clipboard.' . $matches[1];
} else {
$uploadFileName = $name;
}
if (!preg_match($this->options['accept_file_types_lhc'], $uploadFileName)) {
$file->error = $this->get_error_message('accept_file_types');
return false;
}
$file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
if (empty($file->error)) {
$fileUpload = new erLhcoreClassModelChatFile();
$fileUpload->size = $file->size;
$fileUpload->type = $file->type;
$fileUpload->name = $file->name;
$fileUpload->date = time();
$fileUpload->user_id = isset($this->options['user_id']) ? $this->options['user_id'] : 0;
$fileUpload->upload_name = $name;
$fileUpload->file_path = $this->options['upload_dir'];
if (isset($this->options['chat']) && $this->options['chat'] instanceof erLhcoreClassModelChat) {
$fileUpload->chat_id = $this->options['chat']->id;
} elseif (isset($this->options['online_user']) && $this->options['online_user'] instanceof erLhcoreClassModelChatOnlineUser) {
$fileUpload->online_user_id = $this->options['online_user']->id;
}
$matches = array();
if (strpos($name, '.') === false && preg_match('/^image\\/(gif|jpe?g|png)/', $fileUpload->type, $matches)) {
$fileUpload->extension = $matches[1];
} else {
$partsFile = explode('.', $fileUpload->upload_name);
$fileUpload->extension = end($partsFile);
}
$fileUpload->saveThis();
$file->id = $fileUpload->id;
if (isset($this->options['chat']) && $this->options['chat'] instanceof erLhcoreClassModelChat) {
// Chat assign
$chat = $this->options['chat'];
// Format message
$msg = new erLhcoreClassModelmsg();
$msg->msg = '[file=' . $file->id . '_' . md5($fileUpload->name . '_' . $fileUpload->chat_id) . ']';
$msg->chat_id = $chat->id;
$msg->user_id = isset($this->options['user_id']) ? $this->options['user_id'] : 0;
if ($msg->user_id > 0 && isset($this->options['name_support'])) {
$msg->name_support = (string) $this->options['name_support'];
}
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
// Set last message ID
if ($chat->last_msg_id < $msg->id) {
$chat->last_msg_id = $msg->id;
}
$chat->has_unread_messages = 1;
$chat->updateThis();
}
$this->uploadedFile = $fileUpload;
}
return $file;
}
示例2: getList
public static function getList($paramsSearch = array())
{
$paramsDefault = array('limit' => 32, 'offset' => 0);
$params = array_merge($paramsDefault, $paramsSearch);
$session = erLhcoreClassChat::getSession();
$q = $session->createFindQuery('erLhcoreClassModelmsg');
$conditions = array();
if (isset($params['filter']) && count($params['filter']) > 0) {
foreach ($params['filter'] as $field => $fieldValue) {
$conditions[] = $q->expr->eq($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filterin']) && count($params['filterin']) > 0) {
foreach ($params['filterin'] as $field => $fieldValue) {
$conditions[] = $q->expr->in($field, $fieldValue);
}
}
if (isset($params['filterlt']) && count($params['filterlt']) > 0) {
foreach ($params['filterlt'] as $field => $fieldValue) {
$conditions[] = $q->expr->lt($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filtergt']) && count($params['filtergt']) > 0) {
foreach ($params['filtergt'] as $field => $fieldValue) {
$conditions[] = $q->expr->gt($field, $q->bindValue($fieldValue));
}
}
if (count($conditions) > 0) {
$q->where($conditions);
}
$q->limit($params['limit'], $params['offset']);
$q->orderBy(isset($params['sort']) ? $params['sort'] : 'id ASC');
$objects = $session->find($q);
return $objects;
}
示例3: saveThis
public function saveThis()
{
if ($this->first_visit == 0) {
$this->first_visit = time();
}
if ($this->last_visit == 0) {
$this->last_visit = time();
}
erLhcoreClassChat::getSession()->saveOrUpdate($this);
}
示例4: array
$definition = array('msg' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'msgid' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'int', array('min_range' => 1)));
$form = new ezcInputForm(INPUT_POST, $definition);
if ($form->hasValidData('msg') && trim($form->msg) != '' && mb_strlen($form->msg) < (int) erLhcoreClassModelChatConfig::fetch('max_message_length')->current_value) {
$db = ezcDbInstance::get();
$db->beginTransaction();
try {
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
if ($chat->hash == $Params['user_parameters']['hash'] && ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT || $chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)) {
$msg = erLhcoreClassModelmsg::fetch($form->msgid);
if ($msg->chat_id == $chat->id && $msg->user_id == 0) {
$msg->msg = trim($form->msg);
if ($chat->chat_locale != '' && $chat->chat_locale_to != '') {
erLhcoreClassTranslate::translateChatMsgVisitor($chat, $msg);
}
erLhcoreClassChat::getSession()->update($msg);
$tpl = erLhcoreClassTemplate::getInstance('lhchat/syncuser.tpl.php');
$tpl->set('messages', array((array) $msg));
$tpl->set('chat', $chat);
$tpl->set('sync_mode', isset($Params['user_parameters_unordered']['mode']) ? $Params['user_parameters_unordered']['mode'] : '');
$chat->operation_admin .= "lhinst.updateMessageRowAdmin({$chat->id},{$msg->id});\n";
$chat->user_typing = time();
$chat->user_typing_txt = htmlspecialchars_decode(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/updatemsguser', 'User has edited his last message'), ENT_QUOTES);
$chat->updateThis();
echo json_encode(array('error' => 'f', 'msg' => trim($tpl->fetch())));
}
}
$db->commit();
} catch (Exception $e) {
$db->rollback();
}
示例5: getCount
public static function getCount($params = array(), $table = 'lh_chat', $operation = 'COUNT(id)')
{
$session = erLhcoreClassChat::getSession();
$q = $session->database->createSelectQuery();
$q->select($operation)->from($table);
$conditions = array();
if (isset($params['filter']) && count($params['filter']) > 0) {
foreach ($params['filter'] as $field => $fieldValue) {
$conditions[] = $q->expr->eq($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filterin']) && count($params['filterin']) > 0) {
foreach ($params['filterin'] as $field => $fieldValue) {
$conditions[] = $q->expr->in($field, $fieldValue);
}
}
if (isset($params['filterlt']) && count($params['filterlt']) > 0) {
foreach ($params['filterlt'] as $field => $fieldValue) {
$conditions[] = $q->expr->lt($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filtergt']) && count($params['filtergt']) > 0) {
foreach ($params['filtergt'] as $field => $fieldValue) {
$conditions[] = $q->expr->gt($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filterlte']) && count($params['filterlte']) > 0) {
foreach ($params['filterlte'] as $field => $fieldValue) {
$conditions[] = $q->expr->lte($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filtergte']) && count($params['filtergte']) > 0) {
foreach ($params['filtergte'] as $field => $fieldValue) {
$conditions[] = $q->expr->gte($field, $q->bindValue($fieldValue));
}
}
if (isset($params['filterlike']) && count($params['filterlike']) > 0) {
foreach ($params['filterlike'] as $field => $fieldValue) {
$conditions[] = $q->expr->like($field, $q->bindValue('%' . $fieldValue . '%'));
}
}
if (isset($params['customfilter']) && count($params['customfilter']) > 0) {
foreach ($params['customfilter'] as $fieldValue) {
$conditions[] = $fieldValue;
}
}
if (count($conditions) > 0) {
$q->where($conditions);
}
if (isset($params['use_index'])) {
$q->useIndex($params['use_index']);
}
$stmt = $q->prepare();
$stmt->execute();
$result = $stmt->fetchColumn();
return $result;
}
示例6: fetch
public static function fetch($msg_id)
{
$msg = erLhcoreClassChat::getSession()->load('erLhcoreClassModelmsg', (int) $msg_id);
return $msg;
}
示例7: array
<?php
if (is_numeric($Params['user_parameters']['chat_id'])) {
/*
* If online user mode we have to make different check
* */
$browse = false;
if ($Params['user_parameters_unordered']['cobrowsemode'] == 'onlineuser') {
$onlineUser = erLhcoreClassModelChatOnlineUser::fetch($Params['user_parameters']['chat_id']);
$browse = erLhcoreClassCoBrowse::getBrowseInstanceByOnlineUser($onlineUser);
} else {
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
if (erLhcoreClassChat::hasAccessToRead($chat)) {
$browse = erLhcoreClassCoBrowse::getBrowseInstance($chat);
}
}
if ($browse instanceof erLhcoreClassModelCoBrowse) {
if ($browse->modifications != '') {
$changes = json_decode($browse->modifications);
$changes[] = array('url' => $browse->url);
$changes[] = array('lmsg' => $browse->mtime > 0 ? $browse->mtime_front : '');
$changes[] = array('finished' => array('status' => !$browse->is_sharing, 'text' => $browse->is_sharing == 0 ? erTranslationClassLhTranslation::getInstance()->getTranslation('cobrowse/browse', 'Screen sharing session has finished') : erTranslationClassLhTranslation::getInstance()->getTranslation('cobrowse/browse', 'Screen is shared')));
if ($browse->finished == 1) {
$changes[] = array('clear' => true);
}
array_unshift($changes, array('base' => $browse->url));
echo json_encode($changes);
$browse->modifications = '';
$browse->saveThis();
} else {
$changes = array();
示例8: die
<?php
// Set new chat owner
$currentUser = erLhcoreClassUser::instance();
$currentUser->getUserID();
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
// Chat can be closed only by owner
if ($chat->user_id == $currentUser->getUserID() || $currentUser->hasAccessTo('lhchat', 'allowcloseremote')) {
if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
die('Invalid CSRF Token');
exit;
}
if ($chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
$chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
$userData = $currentUser->getUserData(true);
$msg = new erLhcoreClassModelmsg();
$msg->msg = (string) $userData . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closechatadmin', 'has closed the chat!');
$msg->chat_id = $chat->id;
$msg->user_id = -1;
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
$chat->updateThis();
erLhcoreClassChat::updateActiveChats($chat->user_id);
// Execute callback for close chat
erLhcoreClassChat::closeChatCallback($chat, $userData);
}
}
CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', (int) $Params['user_parameters']['chat_id']);
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
示例9: getInstance
/**
* Gets pending chats
*/
public static function getInstance($identifier = 'default', $chathash = '')
{
if ($identifier == '' || $identifier == 'default') {
$identifier = 'default';
$items = self::getList(array('filter' => array('identifier' => $identifier)));
if (empty($items)) {
$chatboxData = erLhcoreClassModelChatConfig::fetch('chatbox_data');
$data = (array) $chatboxData->data;
$chatbox = new erLhcoreClassModelChatbox();
$chatbox->identifier = $identifier;
$chatbox->name = $data['chatbox_default_name'];
$chat = new erLhcoreClassModelChat();
$chat->status = erLhcoreClassModelChat::STATUS_CHATBOX_CHAT;
$chat->time = time();
$chat->setIP();
$chat->hash = erLhcoreClassChat::generateHash();
$chat->nick = $data['chatbox_default_opname'];
$chat->referrer = isset($_GET['URLReferer']) ? $_GET['URLReferer'] : '';
// Assign default department
$departments = erLhcoreClassModelDepartament::getList(array('filter' => array('disabled' => 0)));
$ids = array_keys($departments);
$id = array_shift($ids);
$chat->dep_id = $id;
// Store chat
erLhcoreClassChat::getSession()->save($chat);
$chatbox->chat_id = $chat->id;
$chatbox->saveThis();
return $chatbox;
} else {
return array_shift($items);
}
} else {
$chatboxData = erLhcoreClassModelChatConfig::fetch('chatbox_data');
$data = (array) $chatboxData->data;
$canCreate = $data['chatbox_auto_enabled'] == 1 ? true : false;
if ($canCreate == false) {
if (sha1($data['chatbox_secret_hash'] . sha1($data['chatbox_secret_hash'] . $identifier)) == $chathash) {
$canCreate = true;
}
}
if ($canCreate == true) {
$items = self::getList(array('filter' => array('identifier' => $identifier)));
if (empty($items)) {
$chatbox = new erLhcoreClassModelChatbox();
$chatbox->identifier = $identifier;
$chatbox->name = $data['chatbox_default_name'];
$chat = new erLhcoreClassModelChat();
$chat->status = erLhcoreClassModelChat::STATUS_CHATBOX_CHAT;
$chat->time = time();
$chat->setIP();
$chat->hash = erLhcoreClassChat::generateHash();
$chat->nick = $data['chatbox_default_opname'];
$chat->referrer = isset($_GET['URLReferer']) ? $_GET['URLReferer'] : '';
// Assign default department
$departments = erLhcoreClassModelDepartament::getList();
$ids = array_keys($departments);
$id = array_shift($ids);
$chat->dep_id = $id;
// Store chat
erLhcoreClassChat::getSession()->save($chat);
$chatbox->chat_id = $chat->id;
$chatbox->saveThis();
return $chatbox;
} else {
return array_shift($items);
}
} else {
$items = self::getList(array('filter' => array('identifier' => $identifier)));
if (!empty($items)) {
return array_shift($items);
}
}
return false;
}
}
示例10: json_encode
<?php
if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !$currentUser->validateCSFRToken($_SERVER['HTTP_X_CSRFTOKEN'])) {
echo json_encode(array('error' => 'true', 'result' => 'Invalid CSFR Token'));
exit;
}
try {
$file = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChatFile', $Params['user_parameters']['file_id']);
if (($file->user_id == $currentUser->getUserID() || $file->chat !== false && $file->chat->user_id == $currentUser->getUserID()) && $currentUser->hasAccessTo('lhfile', 'file_delete_chat')) {
$file->removeThis();
echo json_encode(array('error' => 'false'));
exit;
} else {
throw new Exception('No permission to delete the file!');
}
} catch (Exception $e) {
echo json_encode(array('error' => 'true', 'result' => $e->getMessage()));
exit;
}
exit;
?>
示例11: fetch
/**
* Method override to delete proper archive messages
* */
public static function fetch($chat_id)
{
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChatArchive', (int) $chat_id);
return $chat;
}
示例12: array
if ($form->hasValidData('Delay')) {
$Departament->delay = $form->Delay;
}
if ($form->hasValidData('DepartmentID')) {
$Departament->department_id = $form->DepartmentID;
if ($userDepartments !== true) {
if (!in_array($Departament->department_id, $userDepartments)) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Please choose a department');
}
}
} else {
// User has to choose a department
if ($userDepartments !== true) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Please choose a department');
} else {
$Departament->department_id = 0;
}
}
if (count($Errors) == 0) {
$Departament->msg = $form->Message;
erLhcoreClassChat::getSession()->save($Departament);
erLhcoreClassModule::redirect('chat/cannedmsg');
exit;
} else {
$tpl->set('errors', $Errors);
}
}
$tpl->set('msg', $Departament);
$tpl->set('limitDepartments', $userDepartments !== true ? array('filterin' => array('id' => $userDepartments)) : array());
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('chat/cannedmsg'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Canned messages')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'New canned message')));
示例13: array
/**
* Append user departments filter
* */
$departmentParams = array();
$userDepartments = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID());
if ($userDepartments !== true) {
$departmentParams['filterin']['department_id'] = $userDepartments;
}
if (is_numeric($Params['user_parameters_unordered']['id']) && $Params['user_parameters_unordered']['action'] == 'delete') {
// Delete selected canned message
try {
if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
die('Invalid CSRF Token');
exit;
}
$Msg = erLhcoreClassChat::getSession()->load('erLhcoreClassModelCannedMsg', (int) $Params['user_parameters_unordered']['id']);
if ($userDepartments === true || in_array($Msg->department_id, $userDepartments)) {
$Msg->removeThis();
}
} catch (Exception $e) {
// Do nothing
}
erLhcoreClassModule::redirect('chat/cannedmsg');
exit;
}
$pages = new lhPaginator();
$pages->serverURL = erLhcoreClassDesign::baseurl('chat/cannedmsg');
$pages->items_total = erLhcoreClassModelCannedMsg::getCount($departmentParams);
$pages->setItemsPerPage(20);
$pages->paginate();
$items = array();
示例14:
<?php
$currentUser = erLhcoreClassUser::instance();
if (!$currentUser->isLogged() && !$currentUser->authenticate($_POST['username'], $_POST['password'])) {
exit;
}
$chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
if ($currentUser->hasAccessTo('lhchat', 'deleteglobalchat') || $currentUser->hasAccessTo('lhchat', 'deletechat') && $chat->user_id == $currentUser->getUserID()) {
erLhcoreClassChat::getSession()->delete($chat);
$q = ezcDbInstance::get()->createDeleteQuery();
// Messages
$q->deleteFrom('lh_msg')->where($q->expr->eq('chat_id', $Params['user_parameters']['chat_id']));
$stmt = $q->prepare();
$stmt->execute();
// Transfered chats
$q->deleteFrom('lh_transfer')->where($q->expr->eq('chat_id', $Params['user_parameters']['chat_id']));
$stmt = $q->prepare();
$stmt->execute();
}
exit;
示例15: changeStatus
public static function changeStatus($params)
{
$changeStatus = $params['status'];
$chat = $params['chat'];
$userData = $params['user'];
$allowCloseRemote = $params['allow_close_remote'];
if ($changeStatus == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
if ($chat->status != erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_ACTIVE_CHAT;
$chat->wait_time = time() - $chat->time;
}
if ($chat->user_id == 0) {
$chat->user_id = $userData->id;
}
$chat->updateThis();
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_PENDING_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_PENDING_CHAT;
$chat->support_informed = 0;
$chat->has_unread_messages = 1;
$chat->updateThis();
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_CLOSED_CHAT && $chat->user_id == $userData->id || $allowCloseRemote == true) {
if ($chat->status != erLhcoreClassModelChat::STATUS_CLOSED_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_CLOSED_CHAT;
$chat->chat_duration = erLhcoreClassChat::getChatDurationToUpdateChatID($chat->id);
$msg = new erLhcoreClassModelmsg();
$msg->msg = (string) $userData . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/closechatadmin', 'has closed the chat!');
$msg->chat_id = $chat->id;
$msg->user_id = -1;
$chat->last_user_msg_time = $msg->time = time();
erLhcoreClassChat::getSession()->save($msg);
$chat->updateThis();
CSCacheAPC::getMem()->removeFromArray('lhc_open_chats', $chat->id);
// Execute callback for close chat
erLhcoreClassChat::closeChatCallback($chat, $userData);
}
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_CHATBOX_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_CHATBOX_CHAT;
erLhcoreClassChat::getSession()->update($chat);
} elseif ($changeStatus == erLhcoreClassModelChat::STATUS_OPERATORS_CHAT) {
$chat->status = erLhcoreClassModelChat::STATUS_OPERATORS_CHAT;
erLhcoreClassChat::getSession()->update($chat);
}
erLhcoreClassChat::updateActiveChats($chat->user_id);
if ($chat->department !== false) {
erLhcoreClassChat::updateDepartmentStats($chat->department);
}
}