예제 #1
0
 />&nbsp;<?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendnotice', 'Requires phone');
?>
</label></div>
	</div>
	
	<select class="form-control" id="id_CannedMessage-<?php 
echo $chat->id;
?>
" onchange="$('#sendMessageContent').val(($(this).val() > 0) ? $(this).find(':selected').text() : '');">
		        <option value=""><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/adminchat', 'Select a canned message');
?>
</option>
		        <?php 
foreach (erLhcoreClassModelCannedMsg::getCannedMessages($chat->dep_id, erLhcoreClassUser::instance()->getUserID()) as $item) {
    ?>
		            <option value="<?php 
    echo $item->id;
    ?>
"><?php 
    echo htmlspecialchars(str_replace('{nick}', isset($chat) ? $chat->nick : '', $item->msg));
    ?>
</option>
		       <?php 
}
?>
	</select>
		      
	<input type="hidden" name="SendMessage" value="1" />
	<hr>      
<?php

$pages = new lhPaginator();
$pages->serverURL = erLhcoreClassDesign::baseurl('user/account') . '/(tab)/canned';
$pages->items_total = erLhcoreClassModelCannedMsg::getCount(array('filter' => array('user_id' => $user->id)));
$pages->setItemsPerPage(10);
$pages->paginate();
$cannedMessages = array();
if ($pages->items_total > 0) {
    $cannedMessages = erLhcoreClassModelCannedMsg::getList(array('filter' => array('user_id' => $user->id), 'offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id ASC'));
}
?>

<table class="twelve" cellpadding="0" cellspacing="0">
<thead>
<tr>
    <th width="1%">ID</th>
    <th><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Message');
?>
</th>
    <th><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Delay');
?>
</th>
    <th><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Position');
?>
</th>
    <th width="1%">&nbsp;</th>
    <th width="1%">&nbsp;</th>
예제 #3
0
        }
        if (count($Errors) == 0) {
            $cannedMessage->msg = $form->Message;
            $cannedMessage->user_id = $UserData->id;
            $cannedMessage->saveThis();
            $tpl->set('updated_canned', true);
        } else {
            $tpl->set('errors_canned', $Errors);
        }
    }
    /**
     * Delete canned message
     * */
    if (is_numeric($Params['user_parameters_unordered']['msg']) && $Params['user_parameters_unordered']['action'] == 'delete') {
        if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
            die('Invalid CSRF Token');
            exit;
        }
        try {
            $cannedToDelete = erLhcoreClassModelCannedMsg::fetch($Params['user_parameters_unordered']['msg']);
            if ($cannedToDelete->user_id == $UserData->id) {
                $cannedToDelete->removeThis();
            }
        } catch (Exception $e) {
        }
        erLhcoreClassModule::redirect('user/account', '#canned');
        exit;
    }
    $tpl->set('canned_msg', $cannedMessage);
}
$Result['content'] = $tpl->fetch();
	<div class="columns small-8">
		<div class="row">
			<div class="columns small-8">
				<select name="CannedMessage-<?php 
echo $chat->id;
?>
" id="id_CannedMessage-<?php 
echo $chat->id;
?>
">
					<option value=""><?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/adminchat', 'Select a canned message');
?>
</option>
				<?php 
foreach (erLhcoreClassModelCannedMsg::getList() as $item) {
    ?>
					<option data-delay="<?php 
    echo $item->delay;
    ?>
" value="<?php 
    echo $item->id;
    ?>
"><?php 
    echo htmlspecialchars($item->msg);
    ?>
</option>
				<?php 
}
?>
				</select>
예제 #5
0
        $operatorAccepted = true;
        $chatDataChanged = true;
    }
    if ($chat->support_informed == 0 || $chat->has_unread_messages == 1 || $chat->unread_messages_informed == 1) {
        $chatDataChanged = true;
    }
    $chat->support_informed = 1;
    $chat->has_unread_messages = 0;
    $chat->unread_messages_informed = 0;
    erLhcoreClassChat::getSession()->update($chat);
    $ownerString = 'No data';
    $user = $chat->getChatOwner();
    if ($user !== false) {
        $ownerString = $user->name . ' ' . $user->surname;
    }
    $cannedmsg = erLhcoreClassModelCannedMsg::getCannedMessages($chat->dep_id, $currentUser->getUserID());
    echo json_encode(array('error' => false, 'canned_messages' => $cannedmsg, 'chat' => $chat, 'ownerstring' => $ownerString));
    flush();
    session_write_close();
    if ($chatDataChanged == true) {
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.data_changed', array('chat' => &$chat, 'user' => $currentUser));
    }
    if ($operatorAccepted == true) {
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.accept', array('chat' => &$chat, 'user' => $currentUser));
        erLhcoreClassChat::updateActiveChats($chat->user_id);
        erLhcoreClassChatWorkflow::presendCannedMsg($chat);
        $options = $chat->department->inform_options_array;
        erLhcoreClassChatWorkflow::chatAcceptedWorkflow(array('department' => $chat->department, 'options' => $options), $chat);
    }
} else {
    echo json_encode(array('error' => true, 'error_string' => 'You do not have permission to read this chat!'));
예제 #6
0
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();
if ($pages->items_total > 0) {
    $items = erLhcoreClassModelCannedMsg::getList(array_merge(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id ASC'), $departmentParams));
}
$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('chat/cannedmsg', 'System configuration')), array('url' => erLhcoreClassDesign::baseurl('chat/cannedmsg'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Canned messages')));
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.cannedmsg_path', array('result' => &$Result));
예제 #7
0
<?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 (erLhcoreClassChat::hasAccessToRead($chat)) {
    // If status is pending change status to active
    if ($chat->status == 0) {
        $chat->status = 1;
    }
    if ($chat->user_id == 0) {
        $currentUser = erLhcoreClassUser::instance();
        $chat->user_id = $currentUser->getUserID();
    }
    erLhcoreClassChat::getSession()->update($chat);
    $ownerString = 'No data';
    $user = $chat->getChatOwner();
    if ($user !== false) {
        $ownerString = $user->name . ' ' . $user->surname;
    }
    $cannedmsg = erLhcoreClassModelCannedMsg::getCannedMessages($chat->dep_id, erLhcoreClassUser::instance()->getUserID());
    echo json_encode(array('error' => false, 'canned_messages' => $cannedmsg, 'chat' => $chat, 'ownerstring' => $ownerString));
} else {
    echo json_encode(array('error' => true, 'error_string' => 'You do not have permission to read this chat!'));
}
exit;