Browse Source

Working on adding the resend button to the actual ticket page

tags/3.1.0
Mike Koch 2 years ago
parent
commit
e086322332

+ 9
- 0
admin/admin_ticket.php View File

@@ -1500,6 +1500,15 @@ function hesk_getAdminButtonsInTicket($reply = 0, $white = 1)

$options = $reply ? '' : '<div class="pull-right">';

// Resend email notification
if ($reply) {
$options .= '
<button class="btn btn-default" data-action="resend-email-notification" data-reply-id="' . $reply['id'] . '" data-ticket-id="' . $ticket['id'] . '">
<i class="fa fa-envelope navy-blue"></i> Resend Email Notification[!]
</button>
';
}

/* Edit post */
if ($can_edit) {
$tmp = $reply ? '&amp;reply=' . $reply['id'] : '';

+ 1
- 1
api/BusinessLogic/Exceptions/InternalUseOnlyException.php View File

@@ -5,6 +5,6 @@ namespace BusinessLogic\Exceptions;

class InternalUseOnlyException extends ApiFriendlyException {
function __construct() {
parent::__construct("This endpoint can only be used internally", "Internal Use Only", 400);
parent::__construct("This endpoint can only be used internally", "Internal Use Only", 401);
}
}

+ 25
- 24
api/BusinessLogic/Security/UserContext.php View File

@@ -61,44 +61,45 @@ class UserContext {
* @return UserContext the built user context
*/
static function fromDataRow($dataRow) {
var_dump($dataRow);
$userContext = new UserContext();
$userContext->id = $dataRow['id'];
$userContext->id = intval($dataRow['id']);
$userContext->username = $dataRow['user'];
$userContext->admin = $dataRow['isadmin'] === '1';
$userContext->admin = boolval($dataRow['isadmin']);
$userContext->name = $dataRow['name'];
$userContext->email = $dataRow['email'];
$userContext->signature = $dataRow['signature'];
$userContext->language = $dataRow['language'];
$userContext->categories = explode(',', $dataRow['categories']);
$userContext->permissions = explode(',', $dataRow['heskprivileges']);
$userContext->autoAssign = $dataRow['autoassign'];
$userContext->ratingNegative = $dataRow['ratingneg'];
$userContext->ratingPositive = $dataRow['ratingpos'];
$userContext->rating = $dataRow['rating'];
$userContext->totalNumberOfReplies = $dataRow['replies'];
$userContext->active = $dataRow['active'];
$userContext->autoAssign = boolval($dataRow['autoassign']);
$userContext->ratingNegative = intval($dataRow['ratingneg']);
$userContext->ratingPositive = intval($dataRow['ratingpos']);
$userContext->rating = floatval($dataRow['rating']);
$userContext->totalNumberOfReplies = intval($dataRow['replies']);
$userContext->active = boolval($dataRow['active']);

$preferences = new UserContextPreferences();
$preferences->afterReply = $dataRow['afterreply'];
$preferences->autoStartTimeWorked = $dataRow['autostart'];
$preferences->autoreload = $dataRow['autoreload'];
$preferences->defaultNotifyCustomerNewTicket = $dataRow['notify_customer_new'];
$preferences->defaultNotifyCustomerReply = $dataRow['notify_customer_reply'];
$preferences->showSuggestedKnowledgebaseArticles = $dataRow['show_suggested'];
$preferences->defaultCalendarView = $dataRow['default_calendar_view'];
$preferences->afterReply = intval($dataRow['afterreply']);
$preferences->autoStartTimeWorked = boolval($dataRow['autostart']);
$preferences->autoreload = intval($dataRow['autoreload']);
$preferences->defaultNotifyCustomerNewTicket = boolval($dataRow['notify_customer_new']);
$preferences->defaultNotifyCustomerReply = boolval($dataRow['notify_customer_reply']);
$preferences->showSuggestedKnowledgebaseArticles = boolval($dataRow['show_suggested']);
$preferences->defaultCalendarView = intval($dataRow['default_calendar_view']);
$preferences->defaultTicketView = $dataRow['default_list'];
$userContext->preferences = $preferences;

$notifications = new UserContextNotifications();
$notifications->newUnassigned = $dataRow['notify_new_unassigned'];
$notifications->newAssignedToMe = $dataRow['notify_new_my'];
$notifications->replyUnassigned = $dataRow['notify_reply_unassigned'];
$notifications->replyToMe = $dataRow['notify_reply_my'];
$notifications->ticketAssignedToMe = $dataRow['notify_assigned'];
$notifications->privateMessage = $dataRow['notify_pm'];
$notifications->noteOnTicketAssignedToMe = $dataRow['notify_note'];
$notifications->noteOnTicketNotAssignedToMe = $dataRow['notify_note_unassigned'];
$notifications->overdueTicketUnassigned = $dataRow['notify_overdue_unassigned'];
$notifications->newUnassigned = boolval($dataRow['notify_new_unassigned']);
$notifications->newAssignedToMe = boolval($dataRow['notify_new_my']);
$notifications->replyUnassigned = boolval($dataRow['notify_reply_unassigned']);
$notifications->replyToMe = boolval($dataRow['notify_reply_my']);
$notifications->ticketAssignedToMe = boolval($dataRow['notify_assigned']);
$notifications->privateMessage = boolval($dataRow['notify_pm']);
$notifications->noteOnTicketAssignedToMe = boolval($dataRow['notify_note']);
$notifications->noteOnTicketNotAssignedToMe = boolval($dataRow['notify_note_unassigned']);
$notifications->overdueTicketUnassigned = boolval($dataRow['notify_overdue_unassigned']);
$userContext->notificationSettings = $notifications;

return $userContext;

+ 1
- 1
api/Controllers/InternalApiController.php View File

@@ -9,7 +9,7 @@ use BusinessLogic\Helpers;
abstract class InternalApiController {
function checkForInternalUseOnly() {
$tokenHeader = Helpers::getHeader('X-AUTH-TOKEN');
if ($tokenHeader === null || trim($tokenHeader) === '') {
if ($tokenHeader !== null && trim($tokenHeader) !== '') {
throw new InternalUseOnlyException();
}
}

+ 1
- 0
api/autoload.php View File

@@ -11,6 +11,7 @@ require_once(__DIR__ . '/../inc/common.inc.php');
require_once(__DIR__ . '/Core/output.php');
require_once(__DIR__ . '/../hesk_settings.inc.php');
require_once(__DIR__ . '/http_response_code.php');
require_once(__DIR__ . '/../inc/admin_functions.inc.php');

hesk_load_api_database_functions();


+ 1
- 1
api/index.php View File

@@ -47,7 +47,7 @@ function buildUserContextFromSession() {

hesk_session_start();

if (!hesk_isLoggedIn(false)) {
if (empty($_SESSION['id'])) {
throw new \BusinessLogic\Exceptions\SessionNotActiveException();
}


+ 4
- 0
css/colors.css View File

@@ -33,6 +33,10 @@
color: blue;
}

.navy-blue {
color: #3c8dbc;
}

.med-low-priority {
background-color: #8BB467;
}

+ 1
- 0
inc/headerAdmin.inc.php View File

@@ -247,6 +247,7 @@ if (defined('MFH_PAGE_LAYOUT') && MFH_PAGE_LAYOUT == 'TOP_ONLY') {
?>
<body onload="<?php echo $onload;
unset($onload); ?>" class="<?php echo $layout_tag ?> fixed js <?php echo $modsForHesk_settings['admin_color_scheme']; ?>">
<span style="display: none" id="heskUrl"><?php echo $hesk_settings['hesk_url']; ?></span>

<?php
include(HESK_PATH . 'header.txt');

+ 21
- 0
internal-api/js/admin-ticket.js View File

@@ -43,6 +43,27 @@ $(document).ready(function() {
$('.related-ticket').show();
});

$('button[data-action="resend-email-notification"]').click(function() {
var $this = $(this);

var ticketId = $this.data('ticket-id');
var replyId = $this.data('reply-id');
var heskUrl = $('span#heskUrl').text();
var apiUrl = heskUrl + '/api/v1-internal/staff/tickets/' + ticketId + '/resend-email?replyId=' + replyId;

$.ajax({
method: 'GET',
url: apiUrl,
headers: { 'X-Internal-Call': true },
success: function() {
$.jGrowl("Email notification sent!", { theme: 'alert-success', closeTemplate: '' });
},
error: function() {
$.jGrowl("Error occurred when trying to send notification email", { theme: 'alert-danger', closeTemplate: '' });
}
});
});

window.onbeforeunload = function (e) {
e = e || window.event;


Loading…
Cancel
Save