@ -15,6 +15,7 @@ define('IN_SCRIPT', 1);
define('HESK_PATH', '../');
define('PAGE_TITLE', 'ADMIN_SERVICE_MESSAGES');
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 */
require(HESK_PATH . 'hesk_settings.inc.php');
@ -31,26 +32,8 @@ hesk_isLoggedIn();
hesk_checkPermission('can_service_msg');
// Define required constants
define('LOAD_TABS', 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 */
require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
@ -60,9 +43,23 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
< div class = "content-wrapper" >
< section class = "content" >
< 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 = "nav-tabs-custom" >
< ul class = "nav nav-tabs" role = "tablist" >
< 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" >
<?php
// Show a link to banned_emails.php if user has permission to do so
if (hesk_checkPermission('can_ban_emails', 0)) {
@ -149,558 +146,297 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
< 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 {
// List of staff
if (!isset($admins)) {
$admins = array();
$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" >
< thead >
< tr >
< th > <?php echo $hesklang [ 'sm_mtitle' ]; ?> </ th >
< th > <?php echo $hesklang [ 'sm_author' ]; ?> </ th >
< th > <?php echo $hesklang [ 'sm_type' ]; ?> </ th >
< th > <?php echo $hesklang [ 'opt' ]; ?> </ th >
< / tr >
< / thead >
< tbody >
<?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 >
< / table >
<?php
}
?>
< div class = "col-md-10" >
< textarea placeholder = " <?php echo htmlspecialchars ( $hesklang [ 'sm_msg' ]); ?> "
class="form-control" name="message" id="content">< / textarea >
< / 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 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 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 class = "form-group" >
< div class = "row" style = "padding-bottom: 10px;" >
< label for = "style"
class="col-md-2 control-label"><?php echo $hesklang [ 'sm_style' ]; ?> </ label >
< div class = "col-md-3" >
< div class = "radio alert pad-5" style = "box-shadow: none; border-radius: 4px;" >
< label >
< input type = "radio" name = "style" value = "0" onclick = "setIcon('')" >
<?php echo $hesklang [ 'sm_none' ]; ?>
< / label >
< / div >
< div class = "form-group" >
< label for = "icon" class = "col-md-2 control-label" > <?php echo $hesklang [ 'sm_icon' ]; ?> </ label >
<?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 >
< / 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="footer-icon"><?php echo $hesklang [ 'sm_iconpicker_footer_label' ]; ?> </ p >
< p style = "display:none" id = "search-icon" > <?php echo $hesklang [ 'sm_search_icon' ]; ?> </ p >
< div name = "icon" class = "btn btn-default iconpicker-container" data-toggle = "iconpicker"
data-icon="<?php echo $icon ; ?> "></ div >
< / div >
< / div >
< div class = "form-group" >
< label for = "type" class = "col-md-2 control-label" > <?php echo $hesklang [ 'sm_type' ]; ?> </ label >
< p style = "display:none"
id="footer-icon"><?php echo $hesklang [ 'sm_iconpicker_footer_label' ]; ?> </ p >
< 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 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 class = "form-group" >
< label for = "title"
class="col-md-2 control-label"><?php echo $hesklang [ 'sm_mtitle' ]; ?> </ label >
< div class = "col-md-10" >
< input class = "form-control"
placeholder="<?php echo htmlspecialchars ( $hesklang [ 'sm_mtitle' ]); ?> "
type="text" name="title" size="70" maxlength="255"
<?php if ( isset ( $_SESSION [ 'new_sm' ][ 'title' ])) {
echo 'value="' . $_SESSION['new_sm']['title'] . '"';
} ?> data-error="<?php echo htmlspecialchars ( $hesklang [ 'sm_e_title' ]); ?> " required>
< div class = "help-block with-errors" > < / div >
< / div >
< div data-deselect-all = "customer-location" class = "btn btn-default" >
<?php echo $hesklang [ 'deselect_all_title_case' ]; ?>
< / div >
< div class = "form-group" >
< label for = "message"
class="col-md-2 control-label"><?php echo $hesklang [ 'sm_msg' ]; ?> </ label >
< div class = "col-md-10" >
< textarea placeholder = " <?php echo htmlspecialchars ( $hesklang [ 'sm_msg' ]); ?> "
class="form-control" name="message" rows="25" cols="70" id="content">
<?php if ( isset ( $_SESSION [ 'new_sm' ][ 'message' ])) {
echo $_SESSION['new_sm']['message'];
} ?>
< / textarea >
< / 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 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" />' ; ?>
< input type = "hidden" name = "token" value = " <?php hesk_token_echo (); ?> " />
< div class = "col-md-10 col-md-offset-2" >
< div class = "btn-group" role = "group" >
< input type = "submit" name = "sm_save" value = " <?php echo $hesklang [ 'sm_save' ]; ?> "
class="btn btn-primary">
< input type = "submit" name = "sm_preview"
value="<?php echo $hesklang [ 'sm_preview' ]; ?> " class="btn btn-default">
< / div >
< / div >
< div data-deselect-all = "staff-location" class = "btn btn-default" >
<?php echo $hesklang [ 'deselect_all_title_case' ]; ?>
< / div >
< / form >
< / 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 >
< / div >
< / div >
< / section >
< / 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 > v a r u s e r s = [ ] ; ' ;
$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 >
< / script >
< script type = "text/html" id = "service-message-preview-template" >
<?php
$sm = array(
'icon' => 'fa',
'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 >
hesk_cleanSessionVars(array('new_sm', 'preview_sm', 'edit_sm'));
<?php
require_once(HESK_PATH . 'inc/footer.inc.php');
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()
?>