Merge branch '3-3-0' into '357-calendar-planning-phase-two'
# Conflicts: # api/BusinessLogic/Security/UserContext.php # api/BusinessLogic/Security/UserPrivilege.php # api/index.php # language/en/text.php
This commit is contained in:
commit
f53065f7f6
@ -54,7 +54,15 @@ else {
|
|||||||
?>
|
?>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<?php hesk_handle_messages(); ?>
|
<?php
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_HOME');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
hesk_handle_messages();
|
||||||
|
?>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h1 class="box-title">
|
<h1 class="box-title">
|
||||||
|
@ -939,6 +939,11 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
/* This will handle error, success and notice messages */
|
/* This will handle error, success and notice messages */
|
||||||
hesk_handle_messages();
|
hesk_handle_messages();
|
||||||
|
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_VIEW_TICKET');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare special custom fields
|
// Prepare special custom fields
|
||||||
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
|
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
|
||||||
if ($v['use'] && hesk_is_custom_field_in_category($k, $ticket['category']) ) {
|
if ($v['use'] && hesk_is_custom_field_in_category($k, $ticket['category']) ) {
|
||||||
|
@ -278,6 +278,12 @@ function print_login()
|
|||||||
<?php
|
<?php
|
||||||
/* This will handle error, success and notice messages */
|
/* This will handle error, success and notice messages */
|
||||||
hesk_handle_messages();
|
hesk_handle_messages();
|
||||||
|
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_LOGIN');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="login-logo">
|
<div class="login-logo">
|
||||||
|
@ -121,7 +121,9 @@ function hesk_kb_header($kb_link, $catid=1)
|
|||||||
</ol>
|
</ol>
|
||||||
<?php
|
<?php
|
||||||
show_subnav('view', $catid);
|
show_subnav('view', $catid);
|
||||||
|
echo '<div style="margin-left:40px;margin-right:40px">';
|
||||||
hesk_kbSearchLarge(1);
|
hesk_kbSearchLarge(1);
|
||||||
|
echo '</div>';
|
||||||
} // END hesk_kb_header()
|
} // END hesk_kb_header()
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +216,15 @@ function hesk_show_kb_article($artid)
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<?php hesk_kb_header($hesk_settings['kb_link'], $article['catid']); ?>
|
<?php
|
||||||
|
hesk_kb_header($hesk_settings['kb_link'], $article['catid']);
|
||||||
|
echo '<div style="margin-left:40px;margin-right:40px">';
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_VIEW_KB_ARTICLE');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
?>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
@ -397,6 +407,13 @@ function hesk_show_kb_category($catid, $is_search = 0) {
|
|||||||
{
|
{
|
||||||
/* Print header */
|
/* Print header */
|
||||||
hesk_kb_header($hesk_settings['kb_link'], $catid);
|
hesk_kb_header($hesk_settings['kb_link'], $catid);
|
||||||
|
|
||||||
|
echo '<div style="margin-left:40px;margin-right:40px">';
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_KB_HOME');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
} ?>
|
} ?>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<?php if ($thiscat['parent']): ?>
|
<?php if ($thiscat['parent']): ?>
|
||||||
|
@ -270,6 +270,12 @@ if (!isset($_SESSION['hide']['treemenu']))
|
|||||||
<?php
|
<?php
|
||||||
show_subnav();
|
show_subnav();
|
||||||
|
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_KB_HOME');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
// Show a notice if total public articles is less than 5
|
// Show a notice if total public articles is less than 5
|
||||||
if ($total_articles < 5)
|
if ($total_articles < 5)
|
||||||
{
|
{
|
||||||
|
@ -157,6 +157,11 @@ $show_quick_help = $show['show'];
|
|||||||
/* This will handle error, success and notice messages */
|
/* This will handle error, success and notice messages */
|
||||||
hesk_handle_messages();
|
hesk_handle_messages();
|
||||||
|
|
||||||
|
$service_messages = mfh_get_service_messages('STAFF_SUBMIT_TICKET');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
if ($show_quick_help): ?>
|
if ($show_quick_help): ?>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
|
@ -15,6 +15,7 @@ define('IN_SCRIPT', 1);
|
|||||||
define('HESK_PATH', '../');
|
define('HESK_PATH', '../');
|
||||||
define('PAGE_TITLE', 'ADMIN_SERVICE_MESSAGES');
|
define('PAGE_TITLE', 'ADMIN_SERVICE_MESSAGES');
|
||||||
define('MFH_PAGE_LAYOUT', 'TOP_ONLY');
|
define('MFH_PAGE_LAYOUT', 'TOP_ONLY');
|
||||||
|
define('EXTRA_JS', '<script src="'.HESK_PATH.'internal-api/js/service-messages.js"></script>');
|
||||||
|
|
||||||
/* Get all the required files and functions */
|
/* Get all the required files and functions */
|
||||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
@ -31,26 +32,8 @@ hesk_isLoggedIn();
|
|||||||
hesk_checkPermission('can_service_msg');
|
hesk_checkPermission('can_service_msg');
|
||||||
|
|
||||||
// Define required constants
|
// Define required constants
|
||||||
define('LOAD_TABS', 1);
|
|
||||||
define('WYSIWYG', 1);
|
define('WYSIWYG', 1);
|
||||||
|
|
||||||
// What should we do?
|
|
||||||
if ($action = hesk_REQUEST('a')) {
|
|
||||||
if ($action == 'edit_sm') {
|
|
||||||
edit_sm();
|
|
||||||
} elseif (defined('HESK_DEMO')) {
|
|
||||||
hesk_process_messages($hesklang['ddemo'], 'service_messages.php', 'NOTICE');
|
|
||||||
} elseif ($action == 'new_sm') {
|
|
||||||
new_sm();
|
|
||||||
} elseif ($action == 'save_sm') {
|
|
||||||
save_sm();
|
|
||||||
} elseif ($action == 'order_sm') {
|
|
||||||
order_sm();
|
|
||||||
} elseif ($action == 'remove_sm') {
|
|
||||||
remove_sm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print header */
|
/* Print header */
|
||||||
require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
|
require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
|
||||||
|
|
||||||
@ -60,68 +43,24 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h1 class="box-title">
|
||||||
|
<?php echo $hesklang['manage_service_messages']; ?>
|
||||||
|
<i class="fa fa-question-circle settingsquestionmark" data-toggle="tooltip"
|
||||||
|
title="<?php echo hesk_makeJsString($hesklang['sm_intro']); ?>"
|
||||||
|
data-placement="bottom"></i>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="nav-tabs-custom">
|
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
|
||||||
<?php
|
|
||||||
// Show a link to banned_emails.php if user has permission to do so
|
|
||||||
if (hesk_checkPermission('can_ban_emails', 0)) {
|
|
||||||
echo '
|
|
||||||
<li role="presentation">
|
|
||||||
<a title="' . $hesklang['banemail'] . '" href="banned_emails.php">' . $hesklang['banemail'] . '</a>
|
|
||||||
</li>';
|
|
||||||
}
|
|
||||||
if (hesk_checkPermission('can_ban_ips', 0)) {
|
|
||||||
echo '
|
|
||||||
<li role="presentation">
|
|
||||||
<a title="' . $hesklang['banip'] . '" href="banned_ips.php">' . $hesklang['banip'] . '</a>
|
|
||||||
</li>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<li role="presentation" class="active">
|
|
||||||
<a href="#"><?php echo $hesklang['sm_title']; ?> <i class="fa fa-question-circle settingsquestionmark"
|
|
||||||
onclick="javascript:alert('<?php echo hesk_makeJsString($hesklang['sm_intro']); ?>')"></i></a>
|
|
||||||
</li>
|
|
||||||
<?php
|
|
||||||
// Show a link to email tpl management if user has permission to do so
|
|
||||||
if (hesk_checkPermission('can_man_email_tpl', 0)) {
|
|
||||||
echo '
|
|
||||||
<li role="presentation">
|
|
||||||
<a title="' . $hesklang['email_templates'] . '" href="manage_email_templates.php">' . $hesklang['email_templates'] . '</a>
|
|
||||||
</li>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
if (hesk_checkPermission('can_man_ticket_statuses', 0)) {
|
|
||||||
echo '
|
|
||||||
<li role="presentation">
|
|
||||||
<a title="' . $hesklang['statuses'] . '" href="manage_statuses.php">' . $hesklang['statuses'] . '</a>
|
|
||||||
</li>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
// Show a link to custom_fields.php if user has permission to do so
|
|
||||||
if ( hesk_checkPermission('can_man_settings',0) ) {
|
|
||||||
echo '
|
|
||||||
<li role="presentation">
|
|
||||||
<a title="' . $hesklang['tab_4'] . '" href="custom_fields.php">' . $hesklang['tab_4'] . '</a>
|
|
||||||
</li>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</ul>
|
|
||||||
<div class="tab-content summaryList tabPadding">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right">
|
||||||
|
<button id="create-button" class="btn btn-success">
|
||||||
|
<i class="fa fa-plus-circle"></i>
|
||||||
|
<?php echo $hesklang['create_new']; ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<?php
|
<?php
|
||||||
/* This will handle error, success and notice messages */
|
|
||||||
hesk_handle_messages();
|
|
||||||
|
|
||||||
if (isset($_SESSION['new_sm']) && !isset($_SESSION['edit_sm'])) {
|
|
||||||
$_SESSION['new_sm'] = hesk_stripArray($_SESSION['new_sm']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_SESSION['preview_sm'])) {
|
|
||||||
hesk_service_message($_SESSION['new_sm']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($hesk_settings['kb_wysiwyg']) {
|
if ($hesk_settings['kb_wysiwyg']) {
|
||||||
?>
|
?>
|
||||||
@ -144,264 +83,63 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
theme_advanced_resizing: true
|
theme_advanced_resizing: true
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<input type="hidden" name="kb_wysiwyg" value="1">
|
||||||
<?php
|
<?php
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h4><?php echo $hesklang['ex_sm']; ?></h4>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<?php
|
|
||||||
|
|
||||||
// Get service messages from database
|
|
||||||
$res = hesk_dbQuery('SELECT * FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'service_messages` ORDER BY `order` ASC');
|
|
||||||
$num = hesk_dbNumRows($res);
|
|
||||||
|
|
||||||
if ($num < 1) {
|
|
||||||
echo '<p>' . $hesklang['no_sm'] . '</p>';
|
|
||||||
} else {
|
} else {
|
||||||
// List of staff
|
?>
|
||||||
if (!isset($admins)) {
|
<input type="hidden" name="kb_wysiwyg" value="0">
|
||||||
$admins = array();
|
<?php
|
||||||
$res2 = hesk_dbQuery("SELECT `id`,`name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users`");
|
|
||||||
while ($row = hesk_dbFetchAssoc($res2)) {
|
|
||||||
$admins[$row['id']] = $row['name'];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="display: none"><?php echo $hesklang['id']; ?></th>
|
||||||
<th><?php echo $hesklang['sm_mtitle']; ?></th>
|
<th><?php echo $hesklang['sm_mtitle']; ?></th>
|
||||||
<th><?php echo $hesklang['sm_author']; ?></th>
|
<th><?php echo $hesklang['sm_author']; ?></th>
|
||||||
|
<th><?php echo $hesklang['lgs']; ?></th>
|
||||||
<th><?php echo $hesklang['sm_type']; ?></th>
|
<th><?php echo $hesklang['sm_type']; ?></th>
|
||||||
<th> <?php echo $hesklang['opt']; ?> </th>
|
<th><?php echo $hesklang['opt']; ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody id="table-body">
|
||||||
<?php
|
|
||||||
$j = 1;
|
|
||||||
$k = 1;
|
|
||||||
|
|
||||||
while ($sm = hesk_dbFetchAssoc($res)) {
|
|
||||||
$faIcon = $sm['icon'];
|
|
||||||
switch ($sm['style']) {
|
|
||||||
case 1:
|
|
||||||
$sm_style = "alert alert-success";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$sm_style = "alert alert-info";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$sm_style = "alert alert-warning";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
$sm_style = "alert alert-danger";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sm_style = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = $sm['type'] ? $hesklang['sm_draft'] : $hesklang['sm_published'];
|
|
||||||
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="<?php echo $sm_style; ?>">
|
|
||||||
<i class="<?php echo $faIcon; ?>"></i>
|
|
||||||
<b><?php echo $sm['title']; ?></b>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><?php echo(isset($admins[$sm['author']]) ? $admins[$sm['author']] : $hesklang['e_udel']); ?></td>
|
|
||||||
<td><?php echo $type; ?></td>
|
|
||||||
<td>
|
|
||||||
<?php
|
|
||||||
if ($num > 1) {
|
|
||||||
if ($k == 1) {
|
|
||||||
?>
|
|
||||||
<img src="../img/blank.gif" width="16" height="16" alt=""
|
|
||||||
style="padding:3px;border:none;"/>
|
|
||||||
<a href="service_messages.php?a=order_sm&id=<?php echo $sm['id']; ?>&move=15&token=<?php hesk_token_echo(); ?>">
|
|
||||||
<i class="fa fa-arrow-down font-size-16p green"
|
|
||||||
data-toggle="tooltip" data-placement="top"
|
|
||||||
data-original-title="<?php echo $hesklang['move_dn']; ?>"></i></a>
|
|
||||||
<?php
|
|
||||||
} elseif ($k == $num) {
|
|
||||||
?>
|
|
||||||
<a href="service_messages.php?a=order_sm&id=<?php echo $sm['id']; ?>&move=-15&token=<?php hesk_token_echo(); ?>">
|
|
||||||
<i class="fa fa-arrow-up font-size-16p green" data-toggle="tooltip"
|
|
||||||
data-placement="top"
|
|
||||||
data-original-title="<?php echo $hesklang['move_up']; ?>"></i></a>
|
|
||||||
<img src="../img/blank.gif" width="16" height="16" alt=""
|
|
||||||
style="padding:3px;border:none;"/>
|
|
||||||
<?php
|
|
||||||
} else {
|
|
||||||
?>
|
|
||||||
<a href="service_messages.php?a=order_sm&id=<?php echo $sm['id']; ?>&move=-15&token=<?php hesk_token_echo(); ?>">
|
|
||||||
<i class="fa fa-arrow-up font-size-16p green" data-toggle="tooltip"
|
|
||||||
data-placement="top"
|
|
||||||
data-original-title="<?php echo $hesklang['move_up']; ?>"></i></a>
|
|
||||||
<a href="service_messages.php?a=order_sm&id=<?php echo $sm['id']; ?>&move=15&token=<?php hesk_token_echo(); ?>">
|
|
||||||
<i class="fa fa-arrow-down font-size-16p green"
|
|
||||||
data-toggle="tooltip" data-placement="top"
|
|
||||||
data-original-title="<?php echo $hesklang['move_dn']; ?>"></i></a>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<a href="service_messages.php?a=edit_sm&id=<?php echo $sm['id']; ?>">
|
|
||||||
<i class="fa fa-pencil font-size-16p orange" data-toggle="tooltip"
|
|
||||||
data-placement="top"
|
|
||||||
data-original-title="<?php echo $hesklang['edit']; ?>"></i></a>
|
|
||||||
<a href="service_messages.php?a=remove_sm&id=<?php echo $sm['id']; ?>&token=<?php hesk_token_echo(); ?>"
|
|
||||||
onclick="return hesk_confirmExecute('<?php echo hesk_makeJsString($hesklang['del_sm']); ?>');">
|
|
||||||
<i class="fa fa-times font-size-16p red" data-toggle="tooltip"
|
|
||||||
data-placement="top"
|
|
||||||
data-original-title="<?php echo $hesklang['delete']; ?>"></i></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
$j++;
|
|
||||||
$k++;
|
|
||||||
} // End while
|
|
||||||
|
|
||||||
?>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h4><a name="new_article"></a><?php echo hesk_SESSION('edit_sm') ? $hesklang['edit_sm'] : $hesklang['new_sm']; ?></h4>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<form action="service_messages.php" method="post" name="form1" role="form" class="form-horizontal" data-toggle="validator">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="style"
|
|
||||||
class="col-md-2 control-label"><?php echo $hesklang['sm_style']; ?></label>
|
|
||||||
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio alert pad-5" style="box-shadow: none; border-radius: 4px;">
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="style" value="0" onclick="setIcon('')"
|
|
||||||
<?php if (!isset($_SESSION['new_sm']['style']) || (isset($_SESSION['new_sm']['style']) && $_SESSION['new_sm']['style'] == 0)) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?>>
|
|
||||||
<?php echo $hesklang['sm_none']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio alert alert-success pad-5">
|
|
||||||
<label style="margin-top: -5px">
|
|
||||||
<input type="radio" name="style" value="1"
|
|
||||||
onclick="setIcon('fa fa-check-circle')"
|
|
||||||
<?php if (isset($_SESSION['new_sm']['style']) && $_SESSION['new_sm']['style'] == 1) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?>>
|
|
||||||
<?php echo $hesklang['sm_success']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio alert alert-info pad-5" onclick="setIcon('fa fa-comment')">
|
|
||||||
<label style="margin-top: -5px">
|
|
||||||
<input type="radio" name="style" value="2"
|
|
||||||
<?php if (isset($_SESSION['new_sm']['style']) && $_SESSION['new_sm']['style'] == 2) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?>>
|
|
||||||
<?php echo $hesklang['sm_info']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio alert alert-warning pad-5"
|
|
||||||
onclick="setIcon('fa fa-exclamation-triangle')">
|
|
||||||
<label style="margin-top: -5px">
|
|
||||||
<input type="radio" name="style" value="3"
|
|
||||||
<?php if (isset($_SESSION['new_sm']['style']) && $_SESSION['new_sm']['style'] == 3) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?>>
|
|
||||||
<?php echo $hesklang['sm_notice']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio alert alert-danger pad-5" onclick="setIcon('fa fa-times-circle')">
|
|
||||||
<label style="margin-top: -5px">
|
|
||||||
<input type="radio" name="style" value="4"
|
|
||||||
<?php if (isset($_SESSION['new_sm']['style']) && $_SESSION['new_sm']['style'] == 4) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?> >
|
|
||||||
<?php echo $hesklang['sm_error']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="overlay" id="overlay">
|
||||||
<label for="icon" class="col-md-2 control-label"><?php echo $hesklang['sm_icon']; ?></label>
|
<i class="fa fa-spinner fa-spin"></i>
|
||||||
<?php
|
|
||||||
$icon = '';
|
|
||||||
if (isset($_SESSION['new_sm']['icon'])) {
|
|
||||||
$icon = $_SESSION['new_sm']['icon'];
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="col-md-10">
|
|
||||||
<p style="display:none" id="no-icon"><?php echo $hesklang['sm_no_icon']; ?></p>
|
|
||||||
|
|
||||||
<p style="display:none" id="search-icon"><?php echo $hesklang['sm_search_icon']; ?></p>
|
|
||||||
|
|
||||||
<p style="display:none"
|
|
||||||
id="footer-icon"><?php echo $hesklang['sm_iconpicker_footer_label']; ?></p>
|
|
||||||
|
|
||||||
<div name="icon" class="btn btn-default iconpicker-container" data-toggle="iconpicker"
|
|
||||||
data-icon="<?php echo $icon; ?>"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
</section>
|
||||||
<label for="type" class="col-md-2 control-label"><?php echo $hesklang['sm_type']; ?></label>
|
|
||||||
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio pad-5">
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="type" value="0"
|
|
||||||
<?php if (!isset($_SESSION['new_sm']['type']) || (isset($_SESSION['new_sm']['type']) && $_SESSION['new_sm']['type'] == 0)) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?> >
|
|
||||||
<?php echo $hesklang['sm_published']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<div class="radio pad-5">
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="type" value="1"
|
|
||||||
<?php if (isset($_SESSION['new_sm']['type']) && $_SESSION['new_sm']['type'] == 1) {
|
|
||||||
echo 'checked';
|
|
||||||
} ?> >
|
|
||||||
<?php echo $hesklang['sm_draft']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal fade" id="service-message-modal" tabindex="-1" role="dialog" style="overflow: hidden">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close cancel-callback" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">
|
||||||
|
<span id="edit-label"><?php echo $hesklang['edit_sm']; ?></span>
|
||||||
|
<span id="create-label"><?php echo $hesklang['new_sm']; ?></span>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
|
<form id="service-message" class="form-horizontal" data-toggle="validator" method="post">
|
||||||
|
<div class="modal-body">
|
||||||
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
|
<li role="presentation" class="active"><a href="#sm-contents" role="tab" data-toggle="tab">Contents</a></li>
|
||||||
|
<li role="presentation"><a href="#properties" role="tab" data-toggle="tab">Properties</a></li>
|
||||||
|
</ul><br>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="sm-contents">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="title"
|
<label for="title"
|
||||||
class="col-md-2 control-label"><?php echo $hesklang['sm_mtitle']; ?></label>
|
class="col-md-2 control-label"><?php echo $hesklang['sm_mtitle']; ?></label>
|
||||||
|
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<input class="form-control"
|
<input class="form-control"
|
||||||
placeholder="<?php echo htmlspecialchars($hesklang['sm_mtitle']); ?>"
|
placeholder="<?php echo htmlspecialchars($hesklang['sm_mtitle']); ?>"
|
||||||
type="text" name="title" size="70" maxlength="255"
|
type="text" name="title" size="70" maxlength="255"
|
||||||
<?php if (isset($_SESSION['new_sm']['title'])) {
|
data-error="<?php echo htmlspecialchars($hesklang['sm_e_title']); ?>" required>
|
||||||
echo 'value="' . $_SESSION['new_sm']['title'] . '"';
|
|
||||||
} ?> data-error="<?php echo htmlspecialchars($hesklang['sm_e_title']); ?>" required>
|
|
||||||
<div class="help-block with-errors"></div>
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -411,301 +149,295 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
|
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<textarea placeholder="<?php echo htmlspecialchars($hesklang['sm_msg']); ?>"
|
<textarea placeholder="<?php echo htmlspecialchars($hesklang['sm_msg']); ?>"
|
||||||
class="form-control" name="message" rows="25" cols="70" id="content">
|
class="form-control" name="message" id="content"></textarea>
|
||||||
<?php if (isset($_SESSION['new_sm']['message'])) {
|
</div>
|
||||||
echo $_SESSION['new_sm']['message'];
|
</div>
|
||||||
} ?>
|
</div>
|
||||||
</textarea>
|
<div role="tabpanel" class="tab-pane" id="properties">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="language" class="col-md-2 control-label">
|
||||||
|
<?php echo $hesklang['lgs']; ?>
|
||||||
|
</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<select name="language" class="form-control">
|
||||||
|
<option value="ALL"><?php echo $hesklang['all']; ?></option>
|
||||||
|
<?php foreach($hesk_settings['languages'] as $name => $info): ?>
|
||||||
|
<option value="<?php echo $info['folder']; ?>">
|
||||||
|
<?php echo $name; ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?php echo isset($_SESSION['edit_sm']) ? '<input type="hidden" name="a" value="save_sm" /><input type="hidden" name="id" value="' . intval($_SESSION['new_sm']['id']) . '" />' : '<input type="hidden" name="a" value="new_sm" />'; ?>
|
<div class="row" style="padding-bottom: 10px;">
|
||||||
<input type="hidden" name="token" value="<?php hesk_token_echo(); ?>"/>
|
<label for="style"
|
||||||
|
class="col-md-2 control-label"><?php echo $hesklang['sm_style']; ?></label>
|
||||||
|
|
||||||
<div class="col-md-10 col-md-offset-2">
|
<div class="col-md-3">
|
||||||
<div class="btn-group" role="group">
|
<div class="radio alert pad-5" style="box-shadow: none; border-radius: 4px;">
|
||||||
<input type="submit" name="sm_save" value="<?php echo $hesklang['sm_save']; ?>"
|
<label>
|
||||||
class="btn btn-primary">
|
<input type="radio" name="style" value="0" onclick="setIcon('')">
|
||||||
<input type="submit" name="sm_preview"
|
<?php echo $hesklang['sm_none']; ?>
|
||||||
value="<?php echo $hesklang['sm_preview']; ?>" class="btn btn-default">
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="radio alert alert-success pad-5">
|
||||||
|
<label style="margin-top: -5px">
|
||||||
|
<input type="radio" name="style" value="1" onclick="setIcon('fa fa-check-circle')">
|
||||||
|
<?php echo $hesklang['sm_success']; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="radio alert alert-info pad-5" onclick="setIcon('fa fa-comment')">
|
||||||
|
<label style="margin-top: -5px">
|
||||||
|
<input type="radio" name="style" value="2">
|
||||||
|
<?php echo $hesklang['sm_info']; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 col-md-offset-2">
|
||||||
|
<div class="radio alert alert-warning pad-5">
|
||||||
|
<label style="margin-top: -5px">
|
||||||
|
<input type="radio" name="style" value="3"
|
||||||
|
onclick="setIcon('fa fa-exclamation-triangle')">
|
||||||
|
<?php echo $hesklang['sm_notice']; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="radio alert alert-danger pad-5">
|
||||||
|
<label style="margin-top: -5px">
|
||||||
|
<input type="radio" name="style" value="4" onclick="setIcon('fa fa-times-circle')">
|
||||||
|
<?php echo $hesklang['sm_error']; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="icon" class="col-md-2 control-label"><?php echo $hesklang['sm_icon']; ?></label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<p style="display:none" id="no-icon"><?php echo $hesklang['sm_no_icon']; ?></p>
|
||||||
|
|
||||||
|
<p style="display:none" id="search-icon"><?php echo $hesklang['sm_search_icon']; ?></p>
|
||||||
|
|
||||||
|
<p style="display:none"
|
||||||
|
id="footer-icon"><?php echo $hesklang['sm_iconpicker_footer_label']; ?></p>
|
||||||
|
|
||||||
|
<div name="icon" class="btn btn-default iconpicker-container" data-toggle="iconpicker"
|
||||||
|
data-search="false" data-icon=""></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="col-md-2 control-label"><?php echo $hesklang['sm_type']; ?></label>
|
||||||
|
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="radio pad-5">
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="type" value="0">
|
||||||
|
<?php echo $hesklang['sm_published']; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="radio pad-5">
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="type" value="1">
|
||||||
|
<?php echo $hesklang['sm_draft']; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="location" class="col-md-2 control-label"><?php echo $hesklang['sm_location']; ?></label>
|
||||||
|
<div class="col-sm-4" style="margin-left:20px">
|
||||||
|
<h5 style="text-decoration: underline;"><?php echo $hesklang['sm_customer_pages']; ?></h5>
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<div data-select-all="customer-location" class="btn btn-default">
|
||||||
|
<?php echo $hesklang['select_all_title_case']; ?>
|
||||||
|
</div>
|
||||||
|
<div data-deselect-all="customer-location" class="btn btn-default">
|
||||||
|
<?php echo $hesklang['deselect_all_title_case']; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="customer-location" type="checkbox"
|
||||||
|
name="location[]" value="CUSTOMER_HOME"> <?php echo $hesklang['sm_homepage']; ?>
|
||||||
|
</div>
|
||||||
|
<?php if ($hesk_settings['kb_enable'] > 0): ?>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="customer-location" type="checkbox"
|
||||||
|
name="location[]" value="CUSTOMER_KB_HOME"> <?php echo $hesklang['sm_kb_home']; ?>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="customer-location" type="checkbox"
|
||||||
|
name="location[]" value="CUSTOMER_VIEW_KB_ARTICLE"> <?php echo $hesklang['sm_view_kb_article']; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; if ($hesk_settings['kb_enable'] != 2): ?>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="customer-location" type="checkbox"
|
||||||
|
name="location[]" value="CUSTOMER_SUBMIT_TICKET"> <?php echo $hesklang['sm_submit_ticket']; ?>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="customer-location" type="checkbox"
|
||||||
|
name="location[]" value="CUSTOMER_VIEW_TICKET"> <?php echo $hesklang['sm_view_ticket']; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4" style="margin-left:20px">
|
||||||
|
<h5 style="text-decoration: underline;"><?php echo $hesklang['sm_staff_pages']; ?></h5>
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<div data-select-all="staff-location" class="btn btn-default">
|
||||||
|
<?php echo $hesklang['select_all_title_case']; ?>
|
||||||
|
</div>
|
||||||
|
<div data-deselect-all="staff-location" class="btn btn-default">
|
||||||
|
<?php echo $hesklang['deselect_all_title_case']; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="staff-location" type="checkbox"
|
||||||
|
name="location[]" value="STAFF_LOGIN"> <?php echo $hesklang['sm_login_page']; ?>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="staff-location" type="checkbox"
|
||||||
|
name="location[]" value="STAFF_HOME"> <?php echo $hesklang['sm_homepage']; ?>
|
||||||
|
</div>
|
||||||
|
<?php if ($hesk_settings['kb_enable'] > 0): ?>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="staff-location" type="checkbox"
|
||||||
|
name="location[]" value="STAFF_KB_HOME"> <?php echo $hesklang['sm_kb_home']; ?>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="staff-location" type="checkbox"
|
||||||
|
name="location[]" value="STAFF_VIEW_KB_ARTICLE"> <?php echo $hesklang['sm_view_kb_article']; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; if ($hesk_settings['kb_enable'] != 2): ?>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="staff-location" type="checkbox"
|
||||||
|
name="location[]" value="STAFF_SUBMIT_TICKET"> <?php echo $hesklang['sm_submit_ticket']; ?>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input data-select-target="staff-location" type="checkbox"
|
||||||
|
name="location[]" value="STAFF_VIEW_TICKET"> <?php echo $hesklang['sm_view_ticket']; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="preview-pane"></div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<input type="hidden" name="id">
|
||||||
|
<input type="hidden" name="order">
|
||||||
|
<div id="action-buttons" class="btn-group">
|
||||||
|
<button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
|
||||||
|
<i class="fa fa-times-circle"></i>
|
||||||
|
<span><?php echo $hesklang['cancel']; ?></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-primary preview-button">
|
||||||
|
<i class="fa fa-search"></i>
|
||||||
|
<span><?php echo $hesklang['sm_preview']; ?></span>
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="btn btn-success save-button">
|
||||||
|
<i class="fa fa-check-circle"></i>
|
||||||
|
<span><?php echo $hesklang['save']; ?></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
echo mfh_get_hidden_fields_for_language(array(
|
||||||
|
'sm_published',
|
||||||
|
'sm_draft',
|
||||||
|
'no_sm',
|
||||||
|
'sm_added',
|
||||||
|
'sm_mdf',
|
||||||
|
'error_saving_updating_sm',
|
||||||
|
'sm_deleted',
|
||||||
|
'error_deleting_sm',
|
||||||
|
'error_sorting_categories',
|
||||||
|
'error_retrieving_sm',
|
||||||
|
'all',
|
||||||
|
));
|
||||||
|
|
||||||
|
echo '<script>var users = [];';
|
||||||
|
$usersRs = hesk_dbQuery("SELECT `id`, `name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `active` = '1'");
|
||||||
|
$users = array();
|
||||||
|
while ($row = hesk_dbFetchAssoc($usersRs)) {
|
||||||
|
$users[] = $row;
|
||||||
|
echo "users[" . $row['id'] . "] = {
|
||||||
|
id: ".$row['id'].",
|
||||||
|
name: '".$row['name']."'
|
||||||
|
}\n";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
var languages = [];\n";
|
||||||
|
foreach ($hesk_settings['languages'] as $key => $value) {
|
||||||
|
echo "languages[" . json_encode($value['folder']) . "] = " . json_encode($key) . ";\n";
|
||||||
|
}
|
||||||
|
echo '</script>';
|
||||||
|
?>
|
||||||
|
<script type="text/html" id="service-message-title-template">
|
||||||
|
<div class="{{CLASS}}">
|
||||||
|
<i data-property="icon"></i>
|
||||||
|
<b data-property="title"></b>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</script>
|
||||||
</div>
|
<script type="text/html" id="service-message-preview-template">
|
||||||
</div>
|
<?php
|
||||||
</div>
|
$sm = array(
|
||||||
</section>
|
'icon' => 'fa',
|
||||||
</div>
|
'style' => 0,
|
||||||
|
'title' => '{{TITLE}}',
|
||||||
|
'message' => '{{MESSAGE}}'
|
||||||
|
);
|
||||||
|
hesk_service_message($sm);
|
||||||
|
?>
|
||||||
|
</script>
|
||||||
|
<script type="text/html" id="service-message-template">
|
||||||
|
<tr>
|
||||||
|
<td style="display: none"><span data-property="id" data-value="x"></span></td>
|
||||||
|
<td><span data-property="title"></span></td>
|
||||||
|
<td><span data-property="author"></span></td>
|
||||||
|
<td><span data-property="language"></span></td>
|
||||||
|
<td><span data-property="type"></span></td>
|
||||||
|
<td>
|
||||||
|
<span class="sort-arrows">
|
||||||
|
<a href="#" data-action="sort"
|
||||||
|
data-direction="up">
|
||||||
|
<i class="fa fa-fw fa-arrow-up icon-link green"
|
||||||
|
data-toggle="tooltip" title="<?php echo $hesklang['move_up']; ?>"></i>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-action="sort"
|
||||||
|
data-direction="down">
|
||||||
|
<i class="fa fa-fw fa-arrow-down icon-link green"
|
||||||
|
data-toggle="tooltip" title="<?php echo $hesklang['move_dn'] ?>"></i>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
<a href="#" data-action="edit">
|
||||||
|
<i class="fa fa-fw fa-pencil icon-link orange"
|
||||||
|
data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-action="delete">
|
||||||
|
<i class="fa fa-fw fa-times icon-link red"
|
||||||
|
data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
hesk_cleanSessionVars(array('new_sm', 'preview_sm', 'edit_sm'));
|
|
||||||
|
|
||||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
|
|
||||||
/*** START FUNCTIONS ***/
|
|
||||||
|
|
||||||
|
|
||||||
function save_sm()
|
|
||||||
{
|
|
||||||
global $hesk_settings, $hesklang, $listBox;
|
|
||||||
global $hesk_error_buffer;
|
|
||||||
|
|
||||||
// A security check
|
|
||||||
# hesk_token_check('POST');
|
|
||||||
|
|
||||||
$hesk_error_buffer = array();
|
|
||||||
|
|
||||||
// Get service messageID
|
|
||||||
$id = intval(hesk_POST('id')) or hesk_error($hesklang['sm_e_id']);
|
|
||||||
|
|
||||||
$style = intval(hesk_POST('style', 0));
|
|
||||||
if ($style > 4 || $style < 0) {
|
|
||||||
$style = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = empty($_POST['type']) ? 0 : 1;
|
|
||||||
$icon = hesk_POST('icon');
|
|
||||||
$title = hesk_input(hesk_POST('title')) or $hesk_error_buffer[] = $hesklang['sm_e_title'];
|
|
||||||
$message = hesk_getHTML(hesk_POST('message'));
|
|
||||||
|
|
||||||
// Clean the HTML code
|
|
||||||
require(HESK_PATH . 'inc/htmlpurifier/HeskHTMLPurifier.php');
|
|
||||||
$purifier = new HeskHTMLPurifier($hesk_settings['cache_dir']);
|
|
||||||
$message = $purifier->heskPurify($message);
|
|
||||||
|
|
||||||
// Any errors?
|
|
||||||
if (count($hesk_error_buffer)) {
|
|
||||||
$_SESSION['edit_sm'] = true;
|
|
||||||
|
|
||||||
$_SESSION['new_sm'] = array(
|
|
||||||
'id' => $id,
|
|
||||||
'style' => $style,
|
|
||||||
'type' => $type,
|
|
||||||
'title' => $title,
|
|
||||||
'icon' => $icon,
|
|
||||||
'message' => hesk_input(hesk_POST('message')),
|
|
||||||
);
|
|
||||||
|
|
||||||
$tmp = '';
|
|
||||||
foreach ($hesk_error_buffer as $error) {
|
|
||||||
$tmp .= "<li>$error</li>\n";
|
|
||||||
}
|
|
||||||
$hesk_error_buffer = $tmp;
|
|
||||||
|
|
||||||
$hesk_error_buffer = $hesklang['rfm'] . '<br /><br /><ul>' . $hesk_error_buffer . '</ul>';
|
|
||||||
hesk_process_messages($hesk_error_buffer, 'service_messages.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Just preview the message?
|
|
||||||
if (isset($_POST['sm_preview'])) {
|
|
||||||
$_SESSION['preview_sm'] = true;
|
|
||||||
$_SESSION['edit_sm'] = true;
|
|
||||||
|
|
||||||
$_SESSION['new_sm'] = array(
|
|
||||||
'id' => $id,
|
|
||||||
'style' => $style,
|
|
||||||
'type' => $type,
|
|
||||||
'title' => $title,
|
|
||||||
'message' => $message,
|
|
||||||
'icon' => $icon,
|
|
||||||
);
|
|
||||||
|
|
||||||
header('Location: service_messages.php');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the service message in the database
|
|
||||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` SET
|
|
||||||
`author` = '" . intval($_SESSION['id']) . "',
|
|
||||||
`title` = '" . hesk_dbEscape($title) . "',
|
|
||||||
`message` = '" . hesk_dbEscape($message) . "',
|
|
||||||
`style` = '{$style}',
|
|
||||||
`type` = '{$type}',
|
|
||||||
`icon` = '{$icon}'
|
|
||||||
WHERE `id`={$id}");
|
|
||||||
|
|
||||||
$_SESSION['smord'] = $id;
|
|
||||||
hesk_process_messages($hesklang['sm_mdf'], 'service_messages.php', 'SUCCESS');
|
|
||||||
|
|
||||||
} // End save_sm()
|
|
||||||
|
|
||||||
|
|
||||||
function edit_sm()
|
|
||||||
{
|
|
||||||
global $hesk_settings, $hesklang;
|
|
||||||
|
|
||||||
// Get service messageID
|
|
||||||
$id = intval(hesk_GET('id')) or hesk_error($hesklang['sm_e_id']);
|
|
||||||
|
|
||||||
// Get details from the database
|
|
||||||
$res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `id`={$id} LIMIT 1");
|
|
||||||
if (hesk_dbNumRows($res) != 1) {
|
|
||||||
hesk_error($hesklang['sm_not_found']);
|
|
||||||
}
|
|
||||||
$sm = hesk_dbFetchAssoc($res);
|
|
||||||
|
|
||||||
$_SESSION['new_sm'] = $sm;
|
|
||||||
$_SESSION['edit_sm'] = true;
|
|
||||||
|
|
||||||
} // End edit_sm()
|
|
||||||
|
|
||||||
|
|
||||||
function order_sm()
|
|
||||||
{
|
|
||||||
global $hesk_settings, $hesklang;
|
|
||||||
|
|
||||||
// A security check
|
|
||||||
hesk_token_check();
|
|
||||||
|
|
||||||
// Get ID and move parameters
|
|
||||||
$id = intval(hesk_GET('id')) or hesk_error($hesklang['sm_e_id']);
|
|
||||||
$move = intval(hesk_GET('move'));
|
|
||||||
$_SESSION['smord'] = $id;
|
|
||||||
|
|
||||||
// Update article details
|
|
||||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` SET `order`=`order`+" . intval($move) . " WHERE `id`={$id}");
|
|
||||||
|
|
||||||
// Update order of all service messages
|
|
||||||
update_sm_order();
|
|
||||||
|
|
||||||
// Finish
|
|
||||||
header('Location: service_messages.php');
|
|
||||||
exit();
|
|
||||||
|
|
||||||
} // End order_sm()
|
|
||||||
|
|
||||||
|
|
||||||
function update_sm_order()
|
|
||||||
{
|
|
||||||
global $hesk_settings, $hesklang;
|
|
||||||
|
|
||||||
// Get list of current service messages
|
|
||||||
$res = hesk_dbQuery("SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` ORDER BY `order` ASC");
|
|
||||||
|
|
||||||
// Update database
|
|
||||||
$i = 10;
|
|
||||||
while ($sm = hesk_dbFetchAssoc($res)) {
|
|
||||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` SET `order`=" . intval($i) . " WHERE `id`='" . intval($sm['id']) . "'");
|
|
||||||
$i += 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} // END update_sm_order()
|
|
||||||
|
|
||||||
|
|
||||||
function remove_sm()
|
|
||||||
{
|
|
||||||
global $hesk_settings, $hesklang;
|
|
||||||
|
|
||||||
// A security check
|
|
||||||
hesk_token_check();
|
|
||||||
|
|
||||||
// Get ID
|
|
||||||
$id = intval(hesk_GET('id')) or hesk_error($hesklang['sm_e_id']);
|
|
||||||
|
|
||||||
// Delete the service message
|
|
||||||
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `id`={$id}");
|
|
||||||
|
|
||||||
// Were we successful?
|
|
||||||
if (hesk_dbAffectedRows() == 1) {
|
|
||||||
hesk_process_messages($hesklang['sm_deleted'], './service_messages.php', 'SUCCESS');
|
|
||||||
} else {
|
|
||||||
hesk_process_messages($hesklang['sm_not_found'], './service_messages.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End remove_sm()
|
|
||||||
|
|
||||||
|
|
||||||
function new_sm()
|
|
||||||
{
|
|
||||||
global $hesk_settings, $hesklang, $listBox;
|
|
||||||
global $hesk_error_buffer;
|
|
||||||
|
|
||||||
// A security check
|
|
||||||
# hesk_token_check('POST');
|
|
||||||
|
|
||||||
$hesk_error_buffer = array();
|
|
||||||
|
|
||||||
$style = intval(hesk_POST('style', 0));
|
|
||||||
if ($style > 4 || $style < 0) {
|
|
||||||
$style = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = empty($_POST['type']) ? 0 : 1;
|
|
||||||
$icon = hesk_POST('icon');
|
|
||||||
$title = hesk_input(hesk_POST('title')) or $hesk_error_buffer[] = $hesklang['sm_e_title'];
|
|
||||||
$message = hesk_getHTML(hesk_POST('message'));
|
|
||||||
|
|
||||||
// Clean the HTML code
|
|
||||||
require(HESK_PATH . 'inc/htmlpurifier/HeskHTMLPurifier.php');
|
|
||||||
$purifier = new HeskHTMLPurifier($hesk_settings['cache_dir']);
|
|
||||||
$message = $purifier->heskPurify($message);
|
|
||||||
|
|
||||||
// Any errors?
|
|
||||||
if (count($hesk_error_buffer)) {
|
|
||||||
$_SESSION['new_sm'] = array(
|
|
||||||
'style' => $style,
|
|
||||||
'type' => $type,
|
|
||||||
'title' => $title,
|
|
||||||
'icon' => $icon,
|
|
||||||
'message' => hesk_input(hesk_POST('message')),
|
|
||||||
);
|
|
||||||
|
|
||||||
$tmp = '';
|
|
||||||
foreach ($hesk_error_buffer as $error) {
|
|
||||||
$tmp .= "<li>$error</li>\n";
|
|
||||||
}
|
|
||||||
$hesk_error_buffer = $tmp;
|
|
||||||
|
|
||||||
$hesk_error_buffer = $hesklang['rfm'] . '<br /><br /><ul>' . $hesk_error_buffer . '</ul>';
|
|
||||||
hesk_process_messages($hesk_error_buffer, 'service_messages.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Just preview the message?
|
|
||||||
if (isset($_POST['sm_preview'])) {
|
|
||||||
$_SESSION['preview_sm'] = true;
|
|
||||||
|
|
||||||
$_SESSION['new_sm'] = array(
|
|
||||||
'style' => $style,
|
|
||||||
'type' => $type,
|
|
||||||
'title' => $title,
|
|
||||||
'icon' => $icon,
|
|
||||||
'message' => $message,
|
|
||||||
);
|
|
||||||
|
|
||||||
header('Location: service_messages.php');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the latest service message order
|
|
||||||
$res = hesk_dbQuery("SELECT `order` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` ORDER BY `order` DESC LIMIT 1");
|
|
||||||
$row = hesk_dbFetchRow($res);
|
|
||||||
$my_order = intval($row[0]) + 10;
|
|
||||||
|
|
||||||
// Insert service message into database
|
|
||||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` (`author`,`title`,`message`,`style`,`type`,`order`, `icon`) VALUES (
|
|
||||||
'" . intval($_SESSION['id']) . "',
|
|
||||||
'" . hesk_dbEscape($title) . "',
|
|
||||||
'" . hesk_dbEscape($message) . "',
|
|
||||||
'{$style}',
|
|
||||||
'{$type}',
|
|
||||||
'{$my_order}',
|
|
||||||
'{$icon}'
|
|
||||||
)");
|
|
||||||
|
|
||||||
$_SESSION['smord'] = hesk_dbInsertID();
|
|
||||||
hesk_process_messages($hesklang['sm_added'], 'service_messages.php', 'SUCCESS');
|
|
||||||
|
|
||||||
} // End new_sm()
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -4,8 +4,8 @@ namespace BusinessLogic\Exceptions;
|
|||||||
|
|
||||||
class MissingAuthenticationTokenException extends ApiFriendlyException {
|
class MissingAuthenticationTokenException extends ApiFriendlyException {
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::__construct("An 'X-Auth-Token' is required for all requests",
|
parent::__construct("An 'X-Auth-Token' is required for this request",
|
||||||
'Security Exception',
|
'Security Exception',
|
||||||
400);
|
401);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -58,7 +58,7 @@ class UserContext extends \BaseClass {
|
|||||||
public $active;
|
public $active;
|
||||||
|
|
||||||
function isAnonymousUser() {
|
function isAnonymousUser() {
|
||||||
return $this->username === "API - ANONYMOUS USER";
|
return $this->id === -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function buildAnonymousUser() {
|
static function buildAnonymousUser() {
|
||||||
|
@ -17,4 +17,5 @@ class UserPrivilege extends \BaseClass {
|
|||||||
const CAN_MANAGE_CATEGORIES = 'can_man_cat';
|
const CAN_MANAGE_CATEGORIES = 'can_man_cat';
|
||||||
const CAN_VIEW_ASSIGNED_TO_OTHER = 'can_view_ass_others';
|
const CAN_VIEW_ASSIGNED_TO_OTHER = 'can_view_ass_others';
|
||||||
const CAN_VIEW_UNASSIGNED = 'can_view_unassigned';
|
const CAN_VIEW_UNASSIGNED = 'can_view_unassigned';
|
||||||
|
const CAN_MANAGE_SERVICE_MESSAGES = 'can_service_msg';
|
||||||
}
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class GetServiceMessagesFilter {
|
||||||
|
/* @var $includeStaffServiceMessages bool */
|
||||||
|
public $includeStaffServiceMessages = true;
|
||||||
|
|
||||||
|
/* @var $includeDrafts bool */
|
||||||
|
public $includeDrafts = true;
|
||||||
|
}
|
39
api/BusinessLogic/ServiceMessages/ServiceMessage.php
Normal file
39
api/BusinessLogic/ServiceMessages/ServiceMessage.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceMessage extends \BaseClass {
|
||||||
|
/* @var $id int */
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/* @var $dateCreated string */
|
||||||
|
public $dateCreated;
|
||||||
|
|
||||||
|
/* @var $createdBy int */
|
||||||
|
public $createdBy;
|
||||||
|
|
||||||
|
/* @var $title string */
|
||||||
|
public $title;
|
||||||
|
|
||||||
|
/* @var $message string */
|
||||||
|
public $message;
|
||||||
|
|
||||||
|
/* @var $style string */
|
||||||
|
public $style;
|
||||||
|
|
||||||
|
/* @var $published bool */
|
||||||
|
public $published;
|
||||||
|
|
||||||
|
/* @var $order int */
|
||||||
|
public $order;
|
||||||
|
|
||||||
|
/* @var $icon string */
|
||||||
|
public $icon;
|
||||||
|
|
||||||
|
/* @var $locations string[] */
|
||||||
|
public $locations;
|
||||||
|
|
||||||
|
/* @var $language string */
|
||||||
|
public $language;
|
||||||
|
}
|
164
api/BusinessLogic/ServiceMessages/ServiceMessageHandler.php
Normal file
164
api/BusinessLogic/ServiceMessages/ServiceMessageHandler.php
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO Test
|
||||||
|
use BusinessLogic\Exceptions\ValidationException;
|
||||||
|
use BusinessLogic\Navigation\Direction;
|
||||||
|
use BusinessLogic\ValidationModel;
|
||||||
|
use DataAccess\ServiceMessages\ServiceMessagesGateway;
|
||||||
|
|
||||||
|
class ServiceMessageHandler extends \BaseClass {
|
||||||
|
/* @var $serviceMessageGateway ServiceMessagesGateway */
|
||||||
|
private $serviceMessageGateway;
|
||||||
|
|
||||||
|
function __construct(ServiceMessagesGateway $serviceMessagesGateway) {
|
||||||
|
$this->serviceMessageGateway = $serviceMessagesGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createServiceMessage($serviceMessage, $heskSettings) {
|
||||||
|
$this->validate($serviceMessage, $heskSettings);
|
||||||
|
|
||||||
|
if ($serviceMessage->icon === null) {
|
||||||
|
switch ($serviceMessage->style) {
|
||||||
|
case ServiceMessageStyle::NONE:
|
||||||
|
$serviceMessage->icon = '';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::INFO:
|
||||||
|
$serviceMessage->icon = 'fa fa-comment';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::NOTICE:
|
||||||
|
$serviceMessage->icon = 'fa fa-exclamation-triangle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::ERROR:
|
||||||
|
$serviceMessage->icon = 'fa fa-times-circle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::SUCCESS:
|
||||||
|
$serviceMessage->icon = 'fa fa-check-circle';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->serviceMessageGateway->createServiceMessage($serviceMessage, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getServiceMessages($heskSettings, $searchFilter) {
|
||||||
|
return $this->serviceMessageGateway->getServiceMessages($heskSettings, $searchFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
function editServiceMessage($serviceMessage, $heskSettings) {
|
||||||
|
$this->validate($serviceMessage, $heskSettings, false);
|
||||||
|
|
||||||
|
if ($serviceMessage->icon === null) {
|
||||||
|
switch ($serviceMessage->style) {
|
||||||
|
case ServiceMessageStyle::NONE:
|
||||||
|
$serviceMessage->icon = '';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::INFO:
|
||||||
|
$serviceMessage->icon = 'fa fa-comment';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::NOTICE:
|
||||||
|
$serviceMessage->icon = 'fa fa-exclamation-triangle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::ERROR:
|
||||||
|
$serviceMessage->icon = 'fa fa-times-circle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::SUCCESS:
|
||||||
|
$serviceMessage->icon = 'fa fa-check-circle';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->serviceMessageGateway->updateServiceMessage($serviceMessage, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteServiceMessage($id, $heskSettings) {
|
||||||
|
$this->serviceMessageGateway->deleteServiceMessage($id, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortServiceMessage($id, $direction, $heskSettings) {
|
||||||
|
$serviceMessages = $this->serviceMessageGateway->getServiceMessages($heskSettings, new GetServiceMessagesFilter());
|
||||||
|
$serviceMessage = null;
|
||||||
|
foreach ($serviceMessages as $innerServiceMessage) {
|
||||||
|
if (intval($innerServiceMessage->id) === intval($id)) {
|
||||||
|
$serviceMessage = $innerServiceMessage;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($serviceMessage === null) {
|
||||||
|
throw new \BaseException("Could not find service message with ID {$id}!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($direction === Direction::UP) {
|
||||||
|
$serviceMessage->order -= 15;
|
||||||
|
} else {
|
||||||
|
$serviceMessage->order += 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->serviceMessageGateway->updateServiceMessage($serviceMessage, $heskSettings);
|
||||||
|
$this->serviceMessageGateway->resortAllServiceMessages($heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $serviceMessage ServiceMessage
|
||||||
|
* @param bool $isNew
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
private function validate($serviceMessage, $heskSettings, $isNew = true) {
|
||||||
|
$validationModel = new ValidationModel();
|
||||||
|
if ($isNew && $serviceMessage->createdBy < 1) {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_CREATOR';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($serviceMessage->message === null || trim($serviceMessage->message) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_MESSAGE';
|
||||||
|
} else {
|
||||||
|
$htmlPurifier = new \HeskHTMLPurifier($heskSettings['cache_dir']);
|
||||||
|
$serviceMessage->message = $htmlPurifier->heskPurify($serviceMessage->message);
|
||||||
|
}
|
||||||
|
if ($serviceMessage->language === null || trim($serviceMessage->language) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_LANGUAGE';
|
||||||
|
}
|
||||||
|
|
||||||
|
$languageFound = false;
|
||||||
|
foreach ($heskSettings['languages'] as $key => $value) {
|
||||||
|
if ($value['folder'] === $serviceMessage->language || $serviceMessage->language === 'ALL') {
|
||||||
|
$languageFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$languageFound && !in_array('MISSING_LANGUAGE', $validationModel->errorKeys)) {
|
||||||
|
$validationModel->errorKeys[] = 'LANGUAGE_NOT_INSTALLED';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($serviceMessage->title === null || trim($serviceMessage->title) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_TITLE';
|
||||||
|
}
|
||||||
|
if ($serviceMessage->style === null || trim($serviceMessage->style) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_STYLE';
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ServiceMessageStyle::getIdForStyle($serviceMessage->style);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_STYLE';
|
||||||
|
}
|
||||||
|
if ($serviceMessage->locations === null || count($serviceMessage->locations) === 0) {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_LOCATIONS';
|
||||||
|
} else {
|
||||||
|
$locations = ServiceMessageLocation::getAll();
|
||||||
|
foreach ($serviceMessage->locations as $location) {
|
||||||
|
if (!in_array($location, $locations)) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_LOCATION';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($validationModel->errorKeys) > 0) {
|
||||||
|
// Validation failed
|
||||||
|
throw new ValidationException($validationModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
api/BusinessLogic/ServiceMessages/ServiceMessageLocation.php
Normal file
34
api/BusinessLogic/ServiceMessages/ServiceMessageLocation.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceMessageLocation {
|
||||||
|
const CUSTOMER_HOME = 'CUSTOMER_HOME';
|
||||||
|
const CUSTOMER_KB_HOME = 'CUSTOMER_KB_HOME';
|
||||||
|
const CUSTOMER_VIEW_KB_ARTICLE = 'CUSTOMER_VIEW_KB_ARTICLE';
|
||||||
|
const CUSTOMER_SUBMIT_TICKET = 'CUSTOMER_SUBMIT_TICKET';
|
||||||
|
const CUSTOMER_VIEW_TICKET = 'CUSTOMER_VIEW_TICKET';
|
||||||
|
const STAFF_LOGIN = 'STAFF_LOGIN';
|
||||||
|
const STAFF_HOME = 'STAFF_HOME';
|
||||||
|
const STAFF_KB_HOME = 'STAFF_KB_HOME';
|
||||||
|
const STAFF_VIEW_KB_ARTICLE = 'STAFF_VIEW_KB_ARTICLE';
|
||||||
|
const STAFF_SUBMIT_TICKET = 'STAFF_SUBMIT_TICKET';
|
||||||
|
const STAFF_VIEW_TICKET = 'STAFF_VIEW_TICKET';
|
||||||
|
|
||||||
|
static function getAll() {
|
||||||
|
return array(
|
||||||
|
self::CUSTOMER_HOME,
|
||||||
|
self::CUSTOMER_KB_HOME,
|
||||||
|
self::CUSTOMER_VIEW_KB_ARTICLE,
|
||||||
|
self::CUSTOMER_SUBMIT_TICKET,
|
||||||
|
self::CUSTOMER_VIEW_TICKET,
|
||||||
|
self::STAFF_LOGIN,
|
||||||
|
self::STAFF_HOME,
|
||||||
|
self::STAFF_KB_HOME,
|
||||||
|
self::STAFF_VIEW_KB_ARTICLE,
|
||||||
|
self::STAFF_SUBMIT_TICKET,
|
||||||
|
self::STAFF_VIEW_TICKET,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
44
api/BusinessLogic/ServiceMessages/ServiceMessageStyle.php
Normal file
44
api/BusinessLogic/ServiceMessages/ServiceMessageStyle.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceMessageStyle {
|
||||||
|
const NONE = 'NONE'; // 0
|
||||||
|
const SUCCESS = 'SUCCESS'; // 1
|
||||||
|
const INFO = 'INFO'; // 2
|
||||||
|
const NOTICE = 'NOTICE'; // 3
|
||||||
|
const ERROR = 'ERROR'; // 4
|
||||||
|
|
||||||
|
static function getStyleById($id) {
|
||||||
|
$styles = array(
|
||||||
|
0 => self::NONE,
|
||||||
|
1 => self::SUCCESS,
|
||||||
|
2 => self::INFO,
|
||||||
|
3 => self::NOTICE,
|
||||||
|
4 => self::ERROR
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($styles[$id])) {
|
||||||
|
throw new \Exception("Style {$id} is not a valid service message style.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $styles[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
static function getIdForStyle($style) {
|
||||||
|
$styles = array(
|
||||||
|
self::NONE => 0,
|
||||||
|
self::SUCCESS => 1,
|
||||||
|
self::INFO => 2,
|
||||||
|
self::NOTICE => 3,
|
||||||
|
self::ERROR => 4
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($styles[$style])) {
|
||||||
|
throw new \Exception("Style {$style} is not a valid service message style.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $styles[$style];
|
||||||
|
}
|
||||||
|
}
|
139
api/Controllers/ServiceMessages/ServiceMessagesController.php
Normal file
139
api/Controllers/ServiceMessages/ServiceMessagesController.php
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Controllers\ServiceMessages;
|
||||||
|
|
||||||
|
use BusinessLogic\Exceptions\ApiFriendlyException;
|
||||||
|
use BusinessLogic\Helpers;
|
||||||
|
use BusinessLogic\Security\UserContext;
|
||||||
|
use BusinessLogic\Security\UserPrivilege;
|
||||||
|
use BusinessLogic\ServiceMessages\GetServiceMessagesFilter;
|
||||||
|
use BusinessLogic\ServiceMessages\ServiceMessage;
|
||||||
|
use BusinessLogic\ServiceMessages\ServiceMessageHandler;
|
||||||
|
use Controllers\ControllerWithSecurity;
|
||||||
|
use Controllers\JsonRetriever;
|
||||||
|
|
||||||
|
class ServiceMessagesController extends \BaseClass {
|
||||||
|
/**
|
||||||
|
* @param $userContext UserContext
|
||||||
|
* @throws ApiFriendlyException
|
||||||
|
*/
|
||||||
|
function checkSecurity($userContext) {
|
||||||
|
if (!$userContext->admin && !in_array(UserPrivilege::CAN_MANAGE_SERVICE_MESSAGES, $userContext->permissions)) {
|
||||||
|
throw new ApiFriendlyException("User does not have permission to access the following URI: " . $_SERVER['REQUEST_URI'], "Access Forbidden", 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function staticCheckSecurity($userContext) {
|
||||||
|
if (!$userContext->admin && !in_array(UserPrivilege::CAN_MANAGE_SERVICE_MESSAGES, $userContext->permissions)) {
|
||||||
|
throw new ApiFriendlyException("User does not have permission to access the following URI: " . $_SERVER['REQUEST_URI'], "Access Forbidden", 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
/* @var $userContext UserContext */
|
||||||
|
/* @var $hesk_settings array */
|
||||||
|
global $applicationContext, $hesk_settings, $userContext;
|
||||||
|
|
||||||
|
$searchFilter = new GetServiceMessagesFilter();
|
||||||
|
if ($userContext->isAnonymousUser()) {
|
||||||
|
$searchFilter->includeDrafts = false;
|
||||||
|
$searchFilter->includeStaffServiceMessages = false;
|
||||||
|
} elseif (!$userContext->admin && !in_array(UserPrivilege::CAN_MANAGE_SERVICE_MESSAGES, $userContext->permissions)) {
|
||||||
|
$searchFilter->includeDrafts = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @var $handler ServiceMessageHandler */
|
||||||
|
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||||
|
|
||||||
|
return output($handler->getServiceMessages($hesk_settings, $searchFilter));
|
||||||
|
}
|
||||||
|
|
||||||
|
function post() {
|
||||||
|
global $applicationContext, $userContext, $hesk_settings;
|
||||||
|
|
||||||
|
$this->checkSecurity($userContext);
|
||||||
|
|
||||||
|
/* @var $handler ServiceMessageHandler */
|
||||||
|
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||||
|
|
||||||
|
$data = JsonRetriever::getJsonData();
|
||||||
|
$element = $handler->createServiceMessage($this->buildElementModel($data, $userContext), $hesk_settings);
|
||||||
|
|
||||||
|
return output($element, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function put($id) {
|
||||||
|
global $applicationContext, $hesk_settings, $userContext;
|
||||||
|
|
||||||
|
$this->checkSecurity($userContext);
|
||||||
|
|
||||||
|
/* @var $handler ServiceMessageHandler */
|
||||||
|
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||||
|
|
||||||
|
$data = JsonRetriever::getJsonData();
|
||||||
|
$serviceMessage = $this->buildElementModel($data, null, false);
|
||||||
|
$serviceMessage->id = $id;
|
||||||
|
$element = $handler->editServiceMessage($serviceMessage, $hesk_settings);
|
||||||
|
|
||||||
|
return output($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($id) {
|
||||||
|
global $applicationContext, $hesk_settings, $userContext;
|
||||||
|
|
||||||
|
$this->checkSecurity($userContext);
|
||||||
|
|
||||||
|
/* @var $handler ServiceMessageHandler */
|
||||||
|
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||||
|
|
||||||
|
$handler->deleteServiceMessage($id, $hesk_settings);
|
||||||
|
|
||||||
|
return http_response_code(204);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $data array
|
||||||
|
* @param $userContext UserContext
|
||||||
|
* @return ServiceMessage
|
||||||
|
*/
|
||||||
|
private function buildElementModel($data, $userContext, $creating = true) {
|
||||||
|
$serviceMessage = new ServiceMessage();
|
||||||
|
|
||||||
|
if (!$creating) {
|
||||||
|
$serviceMessage->order = Helpers::safeArrayGet($data, 'order');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($creating) {
|
||||||
|
$serviceMessage->createdBy = $userContext->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$serviceMessage->title = Helpers::safeArrayGet($data, 'title');
|
||||||
|
$serviceMessage->icon = Helpers::safeArrayGet($data, 'icon');
|
||||||
|
$serviceMessage->message = Helpers::safeArrayGet($data, 'message');
|
||||||
|
$serviceMessage->published = Helpers::safeArrayGet($data, 'published');
|
||||||
|
$serviceMessage->style = Helpers::safeArrayGet($data, 'style');
|
||||||
|
$serviceMessage->language = Helpers::safeArrayGet($data, 'language');
|
||||||
|
|
||||||
|
$jsonLocations = Helpers::safeArrayGet($data, 'locations');
|
||||||
|
|
||||||
|
if ($jsonLocations !== null && !empty($jsonLocations)) {
|
||||||
|
foreach ($jsonLocations as $key => $value) {
|
||||||
|
$serviceMessage->locations[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $serviceMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function sort($id, $direction) {
|
||||||
|
/* @var $userContext UserContext */
|
||||||
|
global $applicationContext, $hesk_settings, $userContext;
|
||||||
|
|
||||||
|
self::staticCheckSecurity($userContext);
|
||||||
|
|
||||||
|
/* @var $handler ServiceMessageHandler */
|
||||||
|
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||||
|
|
||||||
|
$handler->sortServiceMessage(intval($id), $direction, $hesk_settings);
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,11 @@ function print_error($title, $message, $logId = null, $response_code = 500) {
|
|||||||
$error['type'] = 'ERROR';
|
$error['type'] = 'ERROR';
|
||||||
$error['title'] = $title;
|
$error['title'] = $title;
|
||||||
$error['message'] = $message;
|
$error['message'] = $message;
|
||||||
|
|
||||||
|
if ($logId !== null) {
|
||||||
$error['logId'] = $logId;
|
$error['logId'] = $logId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print output($error, $response_code);
|
print output($error, $response_code);
|
||||||
return;
|
return;
|
||||||
|
182
api/DataAccess/ServiceMessages/ServiceMessagesGateway.php
Normal file
182
api/DataAccess/ServiceMessages/ServiceMessagesGateway.php
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DataAccess\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
use BusinessLogic\ServiceMessages\GetServiceMessagesFilter;
|
||||||
|
use BusinessLogic\ServiceMessages\ServiceMessage;
|
||||||
|
use BusinessLogic\ServiceMessages\ServiceMessageLocation;
|
||||||
|
use BusinessLogic\ServiceMessages\ServiceMessageStyle;
|
||||||
|
use DataAccess\CommonDao;
|
||||||
|
|
||||||
|
class ServiceMessagesGateway extends CommonDao {
|
||||||
|
/**
|
||||||
|
* @param $serviceMessage ServiceMessage
|
||||||
|
* @return ServiceMessage
|
||||||
|
*/
|
||||||
|
function createServiceMessage($serviceMessage, $heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
// Get the latest service message order
|
||||||
|
$res = hesk_dbQuery("SELECT `order` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages` ORDER BY `order` DESC LIMIT 1");
|
||||||
|
$row = hesk_dbFetchRow($res);
|
||||||
|
$myOrder = intval($row[0]) + 10;
|
||||||
|
|
||||||
|
$style = ServiceMessageStyle::getIdForStyle($serviceMessage->style);
|
||||||
|
$type = $serviceMessage->published ? 0 : 1;
|
||||||
|
|
||||||
|
// Insert service message into database
|
||||||
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages` (`author`,`title`,`message`,`style`,`type`,`order`, `icon`, `mfh_language`) VALUES (
|
||||||
|
'" . intval($serviceMessage->createdBy) . "',
|
||||||
|
'" . hesk_dbEscape($serviceMessage->title) . "',
|
||||||
|
'" . hesk_dbEscape($serviceMessage->message) . "',
|
||||||
|
'" . hesk_dbEscape($style) . "',
|
||||||
|
'{$type}',
|
||||||
|
'{$myOrder}',
|
||||||
|
'" . hesk_dbEscape($serviceMessage->icon) . "',
|
||||||
|
'" . hesk_dbEscape($serviceMessage->language) . "'
|
||||||
|
)");
|
||||||
|
|
||||||
|
$serviceMessage->id = hesk_dbInsertID();
|
||||||
|
|
||||||
|
foreach ($serviceMessage->locations as $location) {
|
||||||
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
(`service_message_id`, `location`) VALUES (" . intval($serviceMessage->id) . ", '" . hesk_dbEscape($location) . "')");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the autogenerated fields
|
||||||
|
$rs = hesk_dbQuery("SELECT `dt`, `order` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||||
|
WHERE `id` = " . intval($serviceMessage->id));
|
||||||
|
$row = hesk_dbFetchAssoc($rs);
|
||||||
|
$serviceMessage->dateCreated = $row['dt'];
|
||||||
|
$serviceMessage->order = intval($row['order']);
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
|
||||||
|
return $serviceMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $heskSettings
|
||||||
|
* @param $searchFilter GetServiceMessagesFilter
|
||||||
|
* @return ServiceMessage[]
|
||||||
|
*/
|
||||||
|
function getServiceMessages($heskSettings, $searchFilter) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
$serviceMessages = array();
|
||||||
|
|
||||||
|
$sql = "SELECT DISTINCT `service_messages`.* FROM `". hesk_dbEscape($heskSettings['db_pfix']) . "service_messages` AS `service_messages` ";
|
||||||
|
|
||||||
|
if (!$searchFilter->includeStaffServiceMessages) {
|
||||||
|
$sql .= "INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location` AS `location`
|
||||||
|
ON `location`.`service_message_id` = `service_messages`.`id` AND `location`.`location` LIKE 'CUSTOMER%' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$searchFilter->includeDrafts) {
|
||||||
|
$sql .= "WHERE `type` = '0' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= "ORDER BY `order`";
|
||||||
|
|
||||||
|
|
||||||
|
$rs = hesk_dbQuery($sql);
|
||||||
|
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||||
|
$serviceMessage = new ServiceMessage();
|
||||||
|
$serviceMessage->id = $row['id'];
|
||||||
|
$serviceMessage->published = intval($row['type']) !== 1;
|
||||||
|
$serviceMessage->createdBy = intval($row['author']);
|
||||||
|
$serviceMessage->order = intval($row['order']);
|
||||||
|
$serviceMessage->dateCreated = $row['dt'];
|
||||||
|
$serviceMessage->title = $row['title'];
|
||||||
|
$serviceMessage->message = $row['message'];
|
||||||
|
$serviceMessage->style = ServiceMessageStyle::getStyleById($row['style']);
|
||||||
|
$serviceMessage->icon = $row['icon'];
|
||||||
|
$serviceMessage->language = $row['mfh_language'];
|
||||||
|
$serviceMessage->locations = array();
|
||||||
|
|
||||||
|
$locationSql = "SELECT `location` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
WHERE `service_message_id` = " . intval($serviceMessage->id);
|
||||||
|
|
||||||
|
if (!$searchFilter->includeStaffServiceMessages) {
|
||||||
|
$locationSql .= " AND `location` LIKE 'CUSTOMER%'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$locationsRs = hesk_dbQuery($locationSql);
|
||||||
|
while ($innerRow = hesk_dbFetchAssoc($locationsRs)) {
|
||||||
|
$serviceMessage->locations[] = $innerRow['location'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$serviceMessages[] = $serviceMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
|
||||||
|
return $serviceMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateServiceMessage($serviceMessage, $heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
$style = ServiceMessageStyle::getIdForStyle($serviceMessage->style);
|
||||||
|
$type = $serviceMessage->published ? 0 : 1;
|
||||||
|
|
||||||
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||||
|
SET `title` = '" . hesk_dbEscape($serviceMessage->title) . "',
|
||||||
|
`message` = '" . hesk_dbEscape($serviceMessage->message) . "',
|
||||||
|
`style` = '" . intval($style) . "',
|
||||||
|
`type` = '{$type}',
|
||||||
|
`icon` = '" . hesk_dbEscape($serviceMessage->icon) . "',
|
||||||
|
`order` = " . intval($serviceMessage->order) . ",
|
||||||
|
`mfh_language` = '" . hesk_dbEscape($serviceMessage->language) . "'
|
||||||
|
WHERE `id` = " . intval($serviceMessage->id));
|
||||||
|
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
WHERE `service_message_id` = " . intval($serviceMessage->id));
|
||||||
|
foreach ($serviceMessage->locations as $location) {
|
||||||
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
(`service_message_id`, `location`) VALUES (" . intval($serviceMessage->id) . ", '" . hesk_dbEscape($location) . "')");
|
||||||
|
}
|
||||||
|
|
||||||
|
$otherFieldsRs = hesk_dbQuery("SELECT `dt`, `author`, `order` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||||
|
WHERE `id` = " . intval($serviceMessage->id));
|
||||||
|
$otherFields = hesk_dbFetchAssoc($otherFieldsRs);
|
||||||
|
|
||||||
|
$serviceMessage->createdBy = intval($otherFields['author']);
|
||||||
|
$serviceMessage->dateCreated = $otherFields['dt'];
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
|
||||||
|
return $serviceMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteServiceMessage($id, $heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
WHERE `service_message_id` = " . intval($id));
|
||||||
|
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||||
|
WHERE `id` = " . intval($id));
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resortAllServiceMessages($heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
$rs = hesk_dbQuery("SELECT `id` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||||
|
ORDER BY `order` ASC");
|
||||||
|
|
||||||
|
$sortValue = 10;
|
||||||
|
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||||
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||||
|
SET `order` = " . intval($sortValue) . "
|
||||||
|
WHERE `id` = " . intval($row['id']));
|
||||||
|
|
||||||
|
$sortValue += 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ require_once(__DIR__ . '/Core/output.php');
|
|||||||
require_once(__DIR__ . '/../hesk_settings.inc.php');
|
require_once(__DIR__ . '/../hesk_settings.inc.php');
|
||||||
require_once(__DIR__ . '/http_response_code.php');
|
require_once(__DIR__ . '/http_response_code.php');
|
||||||
require_once(__DIR__ . '/../inc/admin_functions.inc.php');
|
require_once(__DIR__ . '/../inc/admin_functions.inc.php');
|
||||||
|
require_once(__DIR__ . '/../inc/htmlpurifier/HeskHTMLPurifier.php');
|
||||||
|
|
||||||
hesk_load_api_database_functions();
|
hesk_load_api_database_functions();
|
||||||
|
|
||||||
|
@ -45,9 +45,16 @@ function internalOrAuthHandler() {
|
|||||||
function publicHandler() {
|
function publicHandler() {
|
||||||
global $userContext;
|
global $userContext;
|
||||||
|
|
||||||
|
// Check if we passed in a X-Auth-Token or X-Internal-Call header. Those take priority
|
||||||
|
if (\BusinessLogic\Helpers::getHeader('X-INTERNAL-CALL') === 'true') {
|
||||||
|
internalHandler();
|
||||||
|
} elseif (\BusinessLogic\Helpers::getHeader('X-AUTH-TOKEN') !== null) {
|
||||||
|
authTokenHandler();
|
||||||
|
} else {
|
||||||
//-- Create an "anonymous" UserContext
|
//-- Create an "anonymous" UserContext
|
||||||
$userContext = \BusinessLogic\Security\UserContext::buildAnonymousUser();
|
$userContext = \BusinessLogic\Security\UserContext::buildAnonymousUser();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function assertApiIsEnabled() {
|
function assertApiIsEnabled() {
|
||||||
global $applicationContext, $hesk_settings;
|
global $applicationContext, $hesk_settings;
|
||||||
@ -105,7 +112,7 @@ function exceptionHandler($exception) {
|
|||||||
/* @var $castedException \BusinessLogic\Exceptions\ApiFriendlyException */
|
/* @var $castedException \BusinessLogic\Exceptions\ApiFriendlyException */
|
||||||
$castedException = $exception;
|
$castedException = $exception;
|
||||||
|
|
||||||
print_error($castedException->title, $castedException->getMessage(), $castedException->httpResponseCode);
|
print_error($castedException->title, $castedException->getMessage(), null, $castedException->httpResponseCode);
|
||||||
} elseif (exceptionIsOfType($exception, \Core\Exceptions\SQLException::clazz())) {
|
} elseif (exceptionIsOfType($exception, \Core\Exceptions\SQLException::clazz())) {
|
||||||
/* @var $castedException \Core\Exceptions\SQLException */
|
/* @var $castedException \Core\Exceptions\SQLException */
|
||||||
$castedException = $exception;
|
$castedException = $exception;
|
||||||
@ -207,6 +214,16 @@ Link::all(array(
|
|||||||
'/v1/calendar/events' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET), SecurityHandler::OPEN),
|
'/v1/calendar/events' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET), SecurityHandler::OPEN),
|
||||||
'/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
'/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
'/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
'/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
|
// Service Messages
|
||||||
|
'/v1/service-messages' => action(\Controllers\ServiceMessages\ServiceMessagesController::clazz(),
|
||||||
|
array(RequestMethod::GET, RequestMethod::POST),
|
||||||
|
SecurityHandler::OPEN),
|
||||||
|
'/v1/service-messages/{i}' => action(\Controllers\ServiceMessages\ServiceMessagesController::clazz(),
|
||||||
|
array(RequestMethod::PUT, RequestMethod::DELETE),
|
||||||
|
SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
|
'/v1-internal/service-messages/{i}/sort/{s}' => action(\Controllers\ServiceMessages\ServiceMessagesController::clazz() . '::sort',
|
||||||
|
array(RequestMethod::POST),
|
||||||
|
SecurityHandler::INTERNAL),
|
||||||
|
|
||||||
/* Internal use only routes */
|
/* Internal use only routes */
|
||||||
// Resend email response
|
// Resend email response
|
||||||
|
@ -185,12 +185,34 @@ function hesk_service_message($sm)
|
|||||||
?>
|
?>
|
||||||
<div class="<?php echo $style; ?>">
|
<div class="<?php echo $style; ?>">
|
||||||
<?php echo $faIcon == '' ? '' : '<i class="' . $faIcon . '"></i> '; ?>
|
<?php echo $faIcon == '' ? '' : '<i class="' . $faIcon . '"></i> '; ?>
|
||||||
<b><?php echo $sm['title']; ?></b><?php echo $sm['message']; ?>
|
<b><?php echo $sm['title']; ?></b><br>
|
||||||
|
<?php echo $sm['message']; ?>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<?php
|
<?php
|
||||||
} // END hesk_service_message()
|
} // END hesk_service_message()
|
||||||
|
|
||||||
|
function mfh_get_service_messages($location) {
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
$language = $hesk_settings['languages'][$hesk_settings['language']]['folder'];
|
||||||
|
|
||||||
|
$res = hesk_dbQuery('SELECT `title`, `message`, `style`, `icon` FROM `'.hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` AS `sm`
|
||||||
|
INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location` AS `location`
|
||||||
|
ON `sm`.`id` = `location`.`service_message_id`
|
||||||
|
AND `location`.`location` = '" . hesk_dbEscape($location) . "'
|
||||||
|
AND `sm`.`mfh_language` IN ('ALL', '" . hesk_dbEscape($language) . "')
|
||||||
|
WHERE `type`='0'
|
||||||
|
ORDER BY `order` ASC");
|
||||||
|
|
||||||
|
$sm = array();
|
||||||
|
while ($row = hesk_dbFetchAssoc($res)) {
|
||||||
|
$sm[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function hesk_isBannedIP($ip)
|
function hesk_isBannedIP($ip)
|
||||||
{
|
{
|
||||||
|
16
index.php
16
index.php
@ -79,7 +79,6 @@ function print_select_category($number_of_categories)
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
|
|
||||||
<h3><?php echo $hesklang['select_category_text']; ?></h3>
|
<h3><?php echo $hesklang['select_category_text']; ?></h3>
|
||||||
|
|
||||||
<div class="select_category">
|
<div class="select_category">
|
||||||
@ -322,6 +321,13 @@ function print_add_ticket()
|
|||||||
<h2><?php hesk_showTopBar($hesklang['submit_ticket']); ?></h2>
|
<h2><?php hesk_showTopBar($hesklang['submit_ticket']); ?></h2>
|
||||||
<small><?php echo $hesklang['use_form_below']; ?></small>
|
<small><?php echo $hesklang['use_form_below']; ?></small>
|
||||||
<div class="blankSpace"></div>
|
<div class="blankSpace"></div>
|
||||||
|
<?php
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('CUSTOMER_SUBMIT_TICKET');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<div align="left" class="h3"><?php echo $hesklang['add_ticket_general_information']; ?></div>
|
<div align="left" class="h3"><?php echo $hesklang['add_ticket_general_information']; ?></div>
|
||||||
<div class="footerWithBorder"></div>
|
<div class="footerWithBorder"></div>
|
||||||
@ -1315,15 +1321,13 @@ function print_start()
|
|||||||
</ol>
|
</ol>
|
||||||
<?php
|
<?php
|
||||||
// Service messages
|
// Service messages
|
||||||
$res = hesk_dbQuery('SELECT `title`, `message`, `style`, `icon` FROM `'.hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` WHERE `type`='0' ORDER BY `order` ASC");
|
$service_messages = mfh_get_service_messages('CUSTOMER_HOME');
|
||||||
if (hesk_dbNumRows($res) > 0)
|
if (count($service_messages) > 0) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<?php
|
<?php
|
||||||
while ($sm=hesk_dbFetchAssoc($res))
|
foreach ($service_messages as $sm) {
|
||||||
{
|
|
||||||
hesk_service_message($sm);
|
hesk_service_message($sm);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -218,5 +218,9 @@ function getAllMigrations() {
|
|||||||
161 => new UpdateMigration('3.2.2', '3.2.1', 161),
|
161 => new UpdateMigration('3.2.2', '3.2.1', 161),
|
||||||
162 => new UpdateMigration('3.2.3', '3.2.2', 162),
|
162 => new UpdateMigration('3.2.3', '3.2.2', 162),
|
||||||
163 => new UpdateMigration('3.2.4', '3.2.3', 163),
|
163 => new UpdateMigration('3.2.4', '3.2.3', 163),
|
||||||
|
// 3.3.0
|
||||||
|
164 => new \v330\ServiceMessagesImprovements\CreateServiceMessageToLocationTable(164),
|
||||||
|
165 => new \v330\ServiceMessagesImprovements\UpdateExistingServiceMessagesLocations(165),
|
||||||
|
166 => new \v330\ServiceMessagesImprovements\AddLanguageColumnToServiceMessages(166),
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace v330\ServiceMessagesImprovements;
|
||||||
|
|
||||||
|
|
||||||
|
class AddLanguageColumnToServiceMessages extends \AbstractUpdatableMigration {
|
||||||
|
|
||||||
|
function innerUp($hesk_settings) {
|
||||||
|
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`
|
||||||
|
ADD COLUMN `mfh_language` VARCHAR(255) NOT NULL DEFAULT 'ALL'");
|
||||||
|
}
|
||||||
|
|
||||||
|
function innerDown($hesk_settings) {
|
||||||
|
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`
|
||||||
|
DROP COLUMN `mfh_language`");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace v330\ServiceMessagesImprovements;
|
||||||
|
|
||||||
|
|
||||||
|
class CreateServiceMessageToLocationTable extends \AbstractUpdatableMigration {
|
||||||
|
|
||||||
|
function innerUp($hesk_settings) {
|
||||||
|
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
(`service_message_id` INT NOT NULL, `location` VARCHAR(100) NOT NULL)");
|
||||||
|
}
|
||||||
|
|
||||||
|
function innerDown($hesk_settings) {
|
||||||
|
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace v330\ServiceMessagesImprovements;
|
||||||
|
|
||||||
|
|
||||||
|
use BusinessLogic\ServiceMessages\ServiceMessageLocation;
|
||||||
|
|
||||||
|
class UpdateExistingServiceMessagesLocations extends \AbstractUpdatableMigration {
|
||||||
|
|
||||||
|
function innerUp($hesk_settings) {
|
||||||
|
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location` (`service_message_id`, `location`)
|
||||||
|
SELECT `id`, '" . hesk_dbEscape(ServiceMessageLocation::CUSTOMER_HOME) . "' FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`");
|
||||||
|
}
|
||||||
|
|
||||||
|
function innerDown($hesk_settings) {
|
||||||
|
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`
|
||||||
|
WHERE `service_message_id` IN (SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`)");
|
||||||
|
}
|
||||||
|
}
|
361
internal-api/js/service-messages.js
Normal file
361
internal-api/js/service-messages.js
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
var serviceMessages = [];
|
||||||
|
|
||||||
|
var g_styles = [];
|
||||||
|
g_styles["ERROR"] = 4;
|
||||||
|
g_styles["NOTICE"] = 3;
|
||||||
|
g_styles["INFO"] = 2;
|
||||||
|
g_styles["SUCCESS"] = 1;
|
||||||
|
g_styles["NONE"] = 0;
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
loadTable();
|
||||||
|
bindEditModal();
|
||||||
|
bindFormSubmit();
|
||||||
|
bindDeleteButton();
|
||||||
|
bindCreateModal();
|
||||||
|
bindSortButtons();
|
||||||
|
bindPreview();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function loadTable() {
|
||||||
|
$('#overlay').show();
|
||||||
|
var heskUrl = $('p#hesk-path').text();
|
||||||
|
var $tableBody = $('#table-body');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'GET',
|
||||||
|
url: heskUrl + 'api/index.php/v1/service-messages',
|
||||||
|
headers: { 'X-Internal-Call': true },
|
||||||
|
success: function(data) {
|
||||||
|
$tableBody.html('');
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
$tableBody.append('<tr><td colspan="4">' + mfhLang.text('no_sm') + '</td></tr>');
|
||||||
|
$('#overlay').hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var first = true;
|
||||||
|
var lastElement = null;
|
||||||
|
$.each(data, function() {
|
||||||
|
var $template = $($('#service-message-template').html());
|
||||||
|
|
||||||
|
$template.find('[data-property="id"]').attr('data-value', this.id);
|
||||||
|
$template.find('span[data-property="title"]').html(
|
||||||
|
getFormattedTitle(this.icon, this.title, this.style));
|
||||||
|
$template.find('span[data-property="author"]').text(users[this.createdBy].name);
|
||||||
|
if (this.published) {
|
||||||
|
$template.find('span[data-property="type"]').text(mfhLang.text('sm_published'));
|
||||||
|
} else {
|
||||||
|
$template.find('span[data-property="type"]').text(mfhLang.text('sm_draft'));
|
||||||
|
}
|
||||||
|
$template.find('[data-property="language"]').text(this.language === 'ALL' ?
|
||||||
|
mfhLang.text('all') :
|
||||||
|
languages[this.language]);
|
||||||
|
|
||||||
|
$tableBody.append($template);
|
||||||
|
|
||||||
|
serviceMessages[this.id] = this;
|
||||||
|
|
||||||
|
lastElement = this;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
$template.find('[data-direction="up"]').css('visibility', 'hidden');
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (lastElement) {
|
||||||
|
//-- Hide the down arrow on the last element
|
||||||
|
$('[data-value="' + lastElement.id + '"]').parent().parent()
|
||||||
|
.find('[data-direction="down"]').css('visibility', 'hidden');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
mfhAlert.errorWithLog(mfhLang.text('error_retrieving_sm'), data.responseJSON);
|
||||||
|
console.error(data);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$('#overlay').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFormattedTitle(icon, title, style) {
|
||||||
|
var $template = $($('#service-message-title-template').html());
|
||||||
|
|
||||||
|
var alertClass = 'none';
|
||||||
|
switch (style) {
|
||||||
|
case 'ERROR':
|
||||||
|
alertClass = 'alert alert-danger';
|
||||||
|
break;
|
||||||
|
case 'NOTICE':
|
||||||
|
alertClass = 'alert alert-warning';
|
||||||
|
break;
|
||||||
|
case 'INFO':
|
||||||
|
alertClass = 'alert alert-info';
|
||||||
|
break;
|
||||||
|
case 'SUCCESS':
|
||||||
|
alertClass = 'alert alert-success';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$template.addClass(alertClass)
|
||||||
|
.find('[data-property="icon"]').addClass(icon).end()
|
||||||
|
.find('[data-property="title"]').text(title);
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getServiceMessagePreview(icon, title, message, style) {
|
||||||
|
var $template = $('#service-message-preview-template').html();
|
||||||
|
|
||||||
|
var alertClass = 'none';
|
||||||
|
switch (style) {
|
||||||
|
case 'ERROR':
|
||||||
|
alertClass = 'alert alert-danger';
|
||||||
|
break;
|
||||||
|
case 'NOTICE':
|
||||||
|
alertClass = 'alert alert-warning';
|
||||||
|
break;
|
||||||
|
case 'INFO':
|
||||||
|
alertClass = 'alert alert-info';
|
||||||
|
break;
|
||||||
|
case 'SUCCESS':
|
||||||
|
alertClass = 'alert alert-success';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$template = $template.replace('none', alertClass)
|
||||||
|
.replace('{{TITLE}}', title)
|
||||||
|
.replace('{{MESSAGE}}', message);
|
||||||
|
$template = $($template);
|
||||||
|
if (icon !== '') {
|
||||||
|
$template.find('i.fa').removeClass('fa').addClass(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEditModal() {
|
||||||
|
$(document).on('click', '[data-action="edit"]', function() {
|
||||||
|
var element = serviceMessages[$(this).parent().parent().find('[data-property="id"]').data('value')];
|
||||||
|
var $modal = $('#service-message-modal');
|
||||||
|
$modal.find('#preview-pane').html('').end()
|
||||||
|
.find('input[name="location[]"]').prop('checked', false);
|
||||||
|
|
||||||
|
$modal.find('#edit-label').show();
|
||||||
|
$modal.find('#create-label').hide();
|
||||||
|
|
||||||
|
$modal.find('input[name="style"][value="' + (g_styles[element.style]) + '"]').prop('checked', 'checked').end()
|
||||||
|
.find('input[name="type"][value="' + (element.published ? 0 : 1) + '"]')
|
||||||
|
.prop('checked', 'checked').end()
|
||||||
|
.find('input[name="title"]').val(element.title).end()
|
||||||
|
.find('input[name="id"]').val(element.id).end()
|
||||||
|
.find('input[name="order"]').val(element.order).end()
|
||||||
|
.find('select[name="language"]').val(element.language).end();
|
||||||
|
setIcon(element.icon);
|
||||||
|
|
||||||
|
$.each(element.locations, function() {
|
||||||
|
$modal.find('input[name="location[]"][value="' + this + '"]').prop('checked', 'checked');
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('input[name="kb_wysiwyg"]').val() === "1") {
|
||||||
|
tinyMCE.get('content').setContent(element.message);
|
||||||
|
} else {
|
||||||
|
$('textarea[name="message"]').val(element.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.tab-pane#sm-contents').addClass('active');
|
||||||
|
$('.tab-pane#properties').removeClass('active');
|
||||||
|
$('.nav-tabs > li').removeClass('active');
|
||||||
|
$('.nav-tabs > li:first').addClass('active');
|
||||||
|
|
||||||
|
|
||||||
|
$modal.modal('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindCreateModal() {
|
||||||
|
$('#create-button').click(function() {
|
||||||
|
var $modal = $('#service-message-modal');
|
||||||
|
$modal.find('#edit-label').hide().end()
|
||||||
|
.find('#create-label').show().end()
|
||||||
|
.find('input[name="style"][value="0"]').prop('checked', 'checked').end() // "None" style
|
||||||
|
.find('input[name="type"][value="0"]').prop('checked', 'checked').end() // Published
|
||||||
|
.find('input[name="title"]').val('').end()
|
||||||
|
.find('input[name="id"]').val(-1).end()
|
||||||
|
.find('input[name="order"]').val('').end()
|
||||||
|
.find('#preview-pane').html('').end()
|
||||||
|
.find('input[name="location[]"]').prop('checked', false)
|
||||||
|
.find('select[name="language"]').val('ALL');
|
||||||
|
setIcon('');
|
||||||
|
|
||||||
|
if ($('input[name="kb_wysiwyg"]').val() === "1") {
|
||||||
|
tinyMCE.get('content').setContent('');
|
||||||
|
} else {
|
||||||
|
$('textarea[name="message"]').val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.tab-pane#sm-contents').addClass('active');
|
||||||
|
$('.tab-pane#properties').removeClass('active');
|
||||||
|
$('.nav-tabs > li').removeClass('active');
|
||||||
|
$('.nav-tabs > li:first').addClass('active');
|
||||||
|
|
||||||
|
$modal.modal('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindFormSubmit() {
|
||||||
|
$('form#service-message').submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var heskUrl = $('p#hesk-path').text();
|
||||||
|
|
||||||
|
var $modal = $('#service-message-modal');
|
||||||
|
|
||||||
|
var styles = [];
|
||||||
|
styles[0] = "NONE";
|
||||||
|
styles[1] = "SUCCESS";
|
||||||
|
styles[2] = "INFO";
|
||||||
|
styles[3] = "NOTICE";
|
||||||
|
styles[4] = "ERROR";
|
||||||
|
|
||||||
|
var domLocations = $modal.find('input[name="location[]"]:checked');
|
||||||
|
|
||||||
|
var locations = [];
|
||||||
|
$.each(domLocations, function() {
|
||||||
|
locations.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
icon: $modal.find('input[name="icon"]').val(),
|
||||||
|
title: $modal.find('input[name="title"]').val(),
|
||||||
|
message: getMessage(),
|
||||||
|
published: $modal.find('input[name="type"]:checked').val() === "0",
|
||||||
|
style: styles[$modal.find('input[name="style"]:checked').val()],
|
||||||
|
order: $modal.find('input[name="order"]').val(),
|
||||||
|
language: $modal.find('select[name="language"]').val(),
|
||||||
|
locations: locations
|
||||||
|
};
|
||||||
|
|
||||||
|
var url = heskUrl + 'api/index.php/v1/service-messages/';
|
||||||
|
var method = 'POST';
|
||||||
|
|
||||||
|
var serviceMessageId = parseInt($modal.find('input[name="id"]').val());
|
||||||
|
if (serviceMessageId !== -1) {
|
||||||
|
url += serviceMessageId;
|
||||||
|
method = 'PUT';
|
||||||
|
}
|
||||||
|
|
||||||
|
$modal.find('#action-buttons').find('.cancel-button').attr('disabled', 'disabled');
|
||||||
|
$modal.find('#action-buttons').find('.save-button').attr('disabled', 'disabled');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: url,
|
||||||
|
headers: {
|
||||||
|
'X-Internal-Call': true,
|
||||||
|
'X-HTTP-Method-Override': method
|
||||||
|
},
|
||||||
|
data: JSON.stringify(data),
|
||||||
|
success: function(data) {
|
||||||
|
if (serviceMessageId === -1) {
|
||||||
|
mfhAlert.success(mfhLang.text('sm_added'));
|
||||||
|
} else {
|
||||||
|
mfhAlert.success(mfhLang.text('sm_mdf'));
|
||||||
|
}
|
||||||
|
$modal.modal('hide');
|
||||||
|
loadTable();
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
mfhAlert.errorWithLog(mfhLang.text('error_saving_updating_sm'), data.responseJSON);
|
||||||
|
console.error(data);
|
||||||
|
},
|
||||||
|
complete: function(data) {
|
||||||
|
$modal.find('#action-buttons').find('.cancel-button').removeAttr('disabled');
|
||||||
|
$modal.find('#action-buttons').find('.save-button').removeAttr('disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindDeleteButton() {
|
||||||
|
$(document).on('click', '[data-action="delete"]', function() {
|
||||||
|
$('#overlay').show();
|
||||||
|
|
||||||
|
var heskUrl = $('p#hesk-path').text();
|
||||||
|
var element = serviceMessages[$(this).parent().parent().find('[data-property="id"]').data('value')];
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: heskUrl + 'api/index.php/v1/service-messages/' + element.id,
|
||||||
|
headers: {
|
||||||
|
'X-Internal-Call': true,
|
||||||
|
'X-HTTP-Method-Override': 'DELETE'
|
||||||
|
},
|
||||||
|
success: function() {
|
||||||
|
mfhAlert.success(mfhLang.text('sm_deleted'));
|
||||||
|
loadTable();
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
$('#overlay').hide();
|
||||||
|
mfhAlert.errorWithLog(mfhLang.text('error_deleting_sm'), data.responseJSON);
|
||||||
|
console.error(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindSortButtons() {
|
||||||
|
$(document).on('click', '[data-action="sort"]', function() {
|
||||||
|
$('#overlay').show();
|
||||||
|
var heskUrl = $('p#hesk-path').text();
|
||||||
|
var direction = $(this).data('direction');
|
||||||
|
var element = serviceMessages[$(this).parent().parent().parent().find('[data-property="id"]').data('value')];
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: heskUrl + 'api/index.php/v1-internal/service-messages/' + element.id + '/sort/' + direction,
|
||||||
|
headers: { 'X-Internal-Call': true },
|
||||||
|
success: function() {
|
||||||
|
loadTable();
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
mfhAlert.errorWithLog(mfhLang.text('error_sorting_categories'), data.responseJSON);
|
||||||
|
console.error(data);
|
||||||
|
$('#overlay').hide();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindPreview() {
|
||||||
|
$('.preview-button').click(function() {
|
||||||
|
var styles = [];
|
||||||
|
styles[0] = "NONE";
|
||||||
|
styles[1] = "SUCCESS";
|
||||||
|
styles[2] = "INFO";
|
||||||
|
styles[3] = "NOTICE";
|
||||||
|
styles[4] = "ERROR";
|
||||||
|
|
||||||
|
var $modal = $('#service-message-modal');
|
||||||
|
var data = {
|
||||||
|
icon: $modal.find('input[name="icon"]').val(),
|
||||||
|
title: $modal.find('input[name="title"]').val(),
|
||||||
|
message: getMessage(),
|
||||||
|
published: $modal.find('input[name="type"]:checked').val() === "0",
|
||||||
|
style: styles[$modal.find('input[name="style"]:checked').val()],
|
||||||
|
order: $modal.find('input[name="order"]').val()
|
||||||
|
};
|
||||||
|
|
||||||
|
var preview = getServiceMessagePreview(data.icon, data.title, data.message, data.style);
|
||||||
|
$('#preview-pane').html(preview);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMessage() {
|
||||||
|
if ($('input[name="kb_wysiwyg"]').val() === "1") {
|
||||||
|
return tinyMCE.get('content').getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $('textarea[name="message"]').val();
|
||||||
|
}
|
@ -254,6 +254,13 @@ if (!$show['show']) {
|
|||||||
require_once(HESK_PATH . 'inc/header.inc.php');
|
require_once(HESK_PATH . 'inc/header.inc.php');
|
||||||
hesk_kb_header($hesk_settings['kb_link']);
|
hesk_kb_header($hesk_settings['kb_link']);
|
||||||
|
|
||||||
|
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('CUSTOMER_VIEW_KB_ARTICLE');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
// Update views by 1 - exclude known bots and reloads because of ratings
|
// Update views by 1 - exclude known bots and reloads because of ratings
|
||||||
if (!isset($_GET['rated']) && !hesk_detect_bots()) {
|
if (!isset($_GET['rated']) && !hesk_detect_bots()) {
|
||||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid}");
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid}");
|
||||||
@ -406,11 +413,11 @@ if (!$show['show']) {
|
|||||||
hesk_kb_header($hesk_settings['kb_link']);
|
hesk_kb_header($hesk_settings['kb_link']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are in "Knowledgebase only" mode show system messages
|
// Display service messages on the default category
|
||||||
if ($catid == 1 && hesk_check_kb_only(false)) {
|
if ($catid == 1) {
|
||||||
// Service messages
|
// Service messages
|
||||||
$res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
|
$service_messages = mfh_get_service_messages('CUSTOMER_KB_HOME');
|
||||||
while ($sm = hesk_dbFetchAssoc($res)) {
|
foreach ($service_messages as $sm) {
|
||||||
hesk_service_message($sm);
|
hesk_service_message($sm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2217,6 +2217,19 @@ $hesklang['audit_unlinked_ticket'] = '%s unlinked ticket %s';
|
|||||||
// Added or modified in Mods for HESK 3.3.0
|
// Added or modified in Mods for HESK 3.3.0
|
||||||
$hesklang['audit_event_created'] = '%s created event';
|
$hesklang['audit_event_created'] = '%s created event';
|
||||||
$hesklang['audit_event_updated'] = '%s updated event';
|
$hesklang['audit_event_updated'] = '%s updated event';
|
||||||
|
$hesklang['error_retrieving_sm'] = 'An error occurred retrieving service messages!';
|
||||||
|
$hesklang['error_saving_updating_sm'] = 'An error occurred creating / saving the service message!';
|
||||||
|
$hesklang['error_deleting_sm'] = 'An error occurred when trying to delete the service message.';
|
||||||
|
$hesklang['error_sorting_sm'] = 'An error occurred sorting service messages!';
|
||||||
|
$hesklang['sm_location'] = 'Location'; // Location for service messages
|
||||||
|
$hesklang['sm_customer_pages'] = 'Customer Pages';
|
||||||
|
$hesklang['sm_staff_pages'] = 'Staff Pages';
|
||||||
|
$hesklang['sm_homepage'] = 'Homepage';
|
||||||
|
$hesklang['sm_kb_home'] = 'Knowledgebase Home';
|
||||||
|
$hesklang['sm_view_kb_article'] = 'View Knowledgebase Article';
|
||||||
|
$hesklang['sm_submit_ticket'] = 'Submit Ticket';
|
||||||
|
$hesklang['sm_view_ticket'] = 'View Ticket';
|
||||||
|
$hesklang['sm_login_page'] = 'Login Page';
|
||||||
|
|
||||||
// DO NOT CHANGE BELOW
|
// DO NOT CHANGE BELOW
|
||||||
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
||||||
|
13
ticket.php
13
ticket.php
@ -215,6 +215,13 @@ if (!$show['show']) {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="<?php echo $columnWidth; ?>">
|
<div class="<?php echo $columnWidth; ?>">
|
||||||
<?php
|
<?php
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('CUSTOMER_VIEW_TICKET');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This will handle error, success and notice messages */
|
/* This will handle error, success and notice messages */
|
||||||
hesk_handle_messages();
|
hesk_handle_messages();
|
||||||
|
|
||||||
@ -478,6 +485,12 @@ function print_form()
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="<?php echo $columnWidth; ?>">
|
<div class="<?php echo $columnWidth; ?>">
|
||||||
<?php
|
<?php
|
||||||
|
// Service messages
|
||||||
|
$service_messages = mfh_get_service_messages('CUSTOMER_VIEW_TICKET');
|
||||||
|
foreach ($service_messages as $sm) {
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
|
||||||
/* This will handle error, success and notice messages */
|
/* This will handle error, success and notice messages */
|
||||||
hesk_handle_messages();
|
hesk_handle_messages();
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user