Merge pull request #254 from mkoch227/permission-groups
Permission groups
This commit is contained in:
commit
84b0932042
@ -56,7 +56,7 @@ hesk_dbConnect();
|
||||
hesk_isLoggedIn();
|
||||
|
||||
// Check permissions for this feature
|
||||
hesk_checkPermission('can_manage_settings');
|
||||
hesk_checkPermission('can_man_settings');
|
||||
|
||||
// Test languages function
|
||||
if (isset($_GET['test_languages']))
|
||||
|
452
admin/manage_permission_templates.php
Normal file
452
admin/manage_permission_templates.php
Normal file
@ -0,0 +1,452 @@
|
||||
<?php
|
||||
/*******************************************************************************
|
||||
* Title: Help Desk Software HESK
|
||||
* Version: 2.6.2 from 18th March 2015
|
||||
* Author: Klemen Stirn
|
||||
* Website: http://www.hesk.com
|
||||
********************************************************************************
|
||||
* COPYRIGHT AND TRADEMARK NOTICE
|
||||
* Copyright 2005-2015 Klemen Stirn. All Rights Reserved.
|
||||
* HESK is a registered trademark of Klemen Stirn.
|
||||
|
||||
* The HESK may be used and modified free of charge by anyone
|
||||
* AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
|
||||
* By using this code you agree to indemnify Klemen Stirn from any
|
||||
* liability that might arise from it's use.
|
||||
|
||||
* Selling the code for this program, in part or full, without prior
|
||||
* written consent is expressly forbidden.
|
||||
|
||||
* Using this code, in part or full, to create derivate work,
|
||||
* new scripts or products is expressly forbidden. Obtain permission
|
||||
* before redistributing this software over the Internet or in
|
||||
* any other medium. In all cases copyright and header must remain intact.
|
||||
* This Copyright is in full effect in any country that has International
|
||||
* Trade Agreements with the United States of America or
|
||||
* with the European Union.
|
||||
|
||||
* Removing any of the copyright notices without purchasing a license
|
||||
* is expressly forbidden. To remove HESK copyright notice you must purchase
|
||||
* a license for this script. For more information on how to obtain
|
||||
* a license please visit the page below:
|
||||
* https://www.hesk.com/buy.php
|
||||
*******************************************************************************/
|
||||
|
||||
define('IN_SCRIPT',1);
|
||||
define('HESK_PATH','../');
|
||||
|
||||
/* Get all the required files and functions */
|
||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||
require(HESK_PATH . 'inc/common.inc.php');
|
||||
require(HESK_PATH . 'inc/admin_functions.inc.php');
|
||||
hesk_load_database_functions();
|
||||
|
||||
hesk_session_start();
|
||||
hesk_dbConnect();
|
||||
hesk_isLoggedIn();
|
||||
|
||||
/* Check permissions for this feature */
|
||||
hesk_checkPermission('can_man_permission_tpl');
|
||||
|
||||
/* What should we do? */
|
||||
if ( $action = hesk_REQUEST('a') )
|
||||
{
|
||||
if ($action == 'save') {save();}
|
||||
elseif ($action == 'create') {create();}
|
||||
elseif ($action == 'delete') {deleteTemplate();}
|
||||
elseif ($action == 'addadmin') {toggleAdmin(true);}
|
||||
elseif ($action == 'deladmin') {toggleAdmin(false);}
|
||||
}
|
||||
|
||||
/* Print header */
|
||||
require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
|
||||
|
||||
/* Print main manage users page */
|
||||
require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
||||
?>
|
||||
|
||||
<script language="Javascript" type="text/javascript"><!--
|
||||
function confirm_delete()
|
||||
{
|
||||
if (confirm('<?php echo hesk_makeJsString($hesklang['confirm_del_cat']); ?>')) {return true;}
|
||||
else {return false;}
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` ORDER BY `name` ASC");
|
||||
$templates = array();
|
||||
while ($row = hesk_dbFetchAssoc($res)) {
|
||||
array_push($templates, $row);
|
||||
}
|
||||
$featureArray = hesk_getFeatureArray();
|
||||
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `name` ASC");
|
||||
$categories = array();
|
||||
while ($row = hesk_dbFetchAssoc($res)) {
|
||||
array_push($categories, $row);
|
||||
}
|
||||
?>
|
||||
<div class="row" style="margin-top: 20px">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<h3><?php echo $hesklang['manage_permission_templates']; ?> <i class="fa fa-question-circle settingsquestionmark"></i></h3>
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php
|
||||
hesk_handle_messages();
|
||||
?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal-template-new" class="btn btn-success">
|
||||
<i class="fa fa-plus-circle"></i> <?php echo $hesklang['create_new_template']; ?>
|
||||
</a>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th><?php echo $hesklang['name']; ?></th>
|
||||
<th><?php echo $hesklang['number_of_users']; ?></th>
|
||||
<th><?php echo $hesklang['actions']; ?></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($templates as $row): ?>
|
||||
<tr>
|
||||
<td><?php echo $row['name']; ?></td>
|
||||
<td><?php echo getNumberOfUsersWithPermissionGroup($row['id']); ?></td>
|
||||
<td>
|
||||
<a href="#" data-toggle="modal" data-target="#modal-template-<?php echo $row['id'] ?>">
|
||||
<i class="fa fa-pencil icon-link" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['view_permissions_for_this_template'] ?>"></i></a>
|
||||
<?php if ($row['id'] == 1) { ?>
|
||||
<i class="fa fa-star icon-link orange" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['admin_cannot_be_staff']; ?>"></i></a>
|
||||
<?php } elseif ($row['heskprivileges'] == 'ALL' && $row['categories'] == 'ALL'){ ?>
|
||||
<a href="manage_permission_templates.php?a=deladmin&id=<?php echo $row['id']; ?>">
|
||||
<i class="fa fa-star icon-link orange" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['template_has_admin_privileges']; ?>"></i></a>
|
||||
<?php } elseif ($row['id'] != 2) { ?>
|
||||
<a href="manage_permission_templates.php?a=addadmin&id=<?php echo $row['id']; ?>">
|
||||
<i class="fa fa-star-o icon-link gray" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['template_has_no_admin_privileges']; ?>"></i></a>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<i class="fa fa-star-o icon-link gray" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['staff_cannot_be_admin']; ?>"></i>
|
||||
<?php
|
||||
}
|
||||
if ($row['id'] != 1 && $row['id'] != 2):
|
||||
?>
|
||||
<a href="manage_permission_templates.php?a=delete&id=<?php echo $row['id']; ?>">
|
||||
<i class="fa fa-times icon-link red" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['delete']; ?>"></i></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
foreach ($templates as $template) {
|
||||
createEditModal($template, $featureArray, $categories);
|
||||
}
|
||||
buildCreateModal($featureArray, $categories);
|
||||
|
||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||
exit();
|
||||
|
||||
|
||||
/*** START FUNCTIONS ***/
|
||||
function getNumberOfUsersWithPermissionGroup($templateId) {
|
||||
global $hesk_settings;
|
||||
|
||||
$res = hesk_dbQuery("SELECT 1 FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `permission_template` = ".intval($templateId));
|
||||
return hesk_dbNumRows($res);
|
||||
}
|
||||
|
||||
function createEditModal($template, $features, $categories) {
|
||||
global $hesklang;
|
||||
|
||||
$showNotice = true;
|
||||
$disabled = 'checked="checked" disabled';
|
||||
$enabledFeatures = array();
|
||||
$enabledCategories = array();
|
||||
if ($template['heskprivileges'] != 'ALL') {
|
||||
$showNotice = false;
|
||||
$disabled = '';
|
||||
$enabledFeatures = explode(',', $template['heskprivileges']);
|
||||
$enabledCategories = explode(',', $template['categories']);
|
||||
}
|
||||
?>
|
||||
<div class="modal fade" id="modal-template-<?php echo $template['id'] ?>" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<form action="manage_permission_templates.php" role="form" method="post">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><?php echo sprintf($hesklang['permissions_for_template'], $template['name']); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<label for="name" class="control-label"><?php echo $hesklang['template_name']; ?></label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="name" value="<?php echo $template['name']; ?>"
|
||||
placeholder="<?php echo $hesklang['template_name']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php if ($showNotice): ?>
|
||||
<div class="alert alert-info">
|
||||
<i class="fa fa-info-circle"></i> <?php echo $hesklang['template_is_admin_cannot_change']; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['menu_cat']; ?></h4>
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<?php
|
||||
$checked = '';
|
||||
if (in_array($category['id'], $enabledCategories) && !$showNotice){
|
||||
$checked = 'checked';
|
||||
} ?>
|
||||
<input type="checkbox" name="categories[]" value="<?php echo $category['id']; ?>" <?php echo $checked.$disabled; ?>>
|
||||
<?php echo $category['name']; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['allow_feat']; ?></h4>
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label><?php
|
||||
$checked = '';
|
||||
if (in_array($feature, $enabledFeatures) && !$showNotice){
|
||||
$checked = 'checked';
|
||||
} ?>
|
||||
<input type="checkbox" name="features[]" value="<?php echo $feature; ?>" <?php echo $checked.$disabled; ?>>
|
||||
<?php echo $hesklang[$feature]; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input type="hidden" name="a" value="save">
|
||||
<input type="hidden" name="template_id" value="<?php echo $template['id']; ?>">
|
||||
<div class="btn-group">
|
||||
<?php if (!$showNotice): ?>
|
||||
<input type="submit" class="btn btn-success" value="<?php echo $hesklang['save_changes']; ?>">
|
||||
<?php endif; ?>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $hesklang['close_modal_without_saving']; ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function buildCreateModal($features, $categories) {
|
||||
global $hesklang;
|
||||
?>
|
||||
<div class="modal fade" id="modal-template-new" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<form action="manage_permission_templates.php" role="form" method="post">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><?php echo $hesklang['create_new_template_title']; ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<label for="name" class="control-label"><?php echo $hesklang['template_name']; ?></label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="name" placeholder="<?php echo $hesklang['template_name']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['menu_cat']; ?></h4>
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="categories[]" value="<?php echo $category['id']; ?>">
|
||||
<?php echo $category['name']; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['allow_feat']; ?></h4>
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="features[]" value="<?php echo $feature; ?>">
|
||||
<?php echo $hesklang[$feature]; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input type="hidden" name="a" value="create">
|
||||
<div class="btn-group">
|
||||
<input type="submit" class="btn btn-success" value="<?php echo $hesklang['save_changes']; ?>">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $hesklang['close_modal_without_saving']; ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function save() {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
$templateId = hesk_POST('template_id');
|
||||
$res = hesk_dbQuery("SELECT `heskprivileges`, `categories` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`
|
||||
WHERE `id` = ".intval($templateId));
|
||||
$row = hesk_dbFetchAssoc($res);
|
||||
|
||||
// Add 'can ban emails' if 'can unban emails' is set (but not added). Same with 'can ban ips'
|
||||
$catArray = hesk_POST_array('categories');
|
||||
$featArray = hesk_POST_array('features');
|
||||
validate($featArray, $catArray);
|
||||
if (in_array('can_unban_emails', $featArray) && !in_array('can_ban_emails', $featArray)) {
|
||||
array_push($catArray, 'can_ban_emails');
|
||||
}
|
||||
if (in_array('can_unban_ips', $featArray) && !in_array('can_ban_ips', $featArray)) {
|
||||
array_push($featArray, 'can_ban_ips');
|
||||
}
|
||||
$categories = implode(',', $catArray);
|
||||
$features = implode(',', $featArray);
|
||||
$name = hesk_POST('name');
|
||||
|
||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`
|
||||
SET `categories` = '".hesk_dbEscape($categories)."', `heskprivileges` = '".hesk_dbEscape($features)."',
|
||||
`name` = '".hesk_dbEscape($name)."'
|
||||
WHERE `id` = ".intval($templateId));
|
||||
|
||||
if ($row['categories'] != $categories || $row['heskprivileges'] != $features) {
|
||||
// Any users with this template should be switched to "custom"
|
||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `permission_template` = NULL
|
||||
WHERE `permission_template` = ".intval($templateId));
|
||||
}
|
||||
|
||||
hesk_process_messages( $hesklang['permission_template_updated'],$_SERVER['PHP_SELF'],'SUCCESS');
|
||||
}
|
||||
|
||||
function create() {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
// Add 'can ban emails' if 'can unban emails' is set (but not added). Same with 'can ban ips'
|
||||
$catArray = hesk_POST_array('categories');
|
||||
$featArray = hesk_POST_array('features');
|
||||
$name = hesk_POST('name');
|
||||
validate($featArray, $catArray, true, $name);
|
||||
if (in_array('can_unban_emails', $featArray) && !in_array('can_ban_emails', $featArray)) {
|
||||
array_push($catArray, 'can_ban_emails');
|
||||
}
|
||||
if (in_array('can_unban_ips', $featArray) && !in_array('can_ban_ips', $featArray)) {
|
||||
array_push($featArray, 'can_ban_ips');
|
||||
}
|
||||
|
||||
$categories = implode(',', $catArray);
|
||||
$features = implode(',', $featArray);
|
||||
|
||||
hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`name`, `heskprivileges`, `categories`)
|
||||
VALUES ('".hesk_dbEscape($name)."', '".hesk_dbEscape($features)."', '".hesk_dbEscape($categories)."')");
|
||||
|
||||
hesk_process_messages( $hesklang['template_created'],$_SERVER['PHP_SELF'],'SUCCESS');
|
||||
}
|
||||
|
||||
function validate($features, $categories, $create = false, $name = '') {
|
||||
global $hesklang;
|
||||
|
||||
$errorMarkup = '<ul>';
|
||||
$isValid = true;
|
||||
if ($create && $name == '') {
|
||||
$errorMarkup .= '<li>'.$hesklang['template_name_required'].'</li>';
|
||||
$isValid = false;
|
||||
}
|
||||
if (count($features) == 0) {
|
||||
$errorMarkup .= '<li>'.$hesklang['you_must_select_a_feature'].'</li>';
|
||||
$isValid = false;
|
||||
}
|
||||
if (count($categories) == 0) {
|
||||
$errorMarkup .= '<li>'.$hesklang['you_must_select_a_category'].'</li>';
|
||||
$isValid = false;
|
||||
}
|
||||
$errorMarkup .= '</ul>';
|
||||
|
||||
if (!$isValid) {
|
||||
$error = sprintf($hesklang['permission_template_error'], $errorMarkup);
|
||||
hesk_process_messages($error, $_SERVER['PHP_SELF']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function deleteTemplate() {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
$id = hesk_GET('id');
|
||||
|
||||
// Admin/Staff templates cannot be deleted!
|
||||
if ($id == 1 || $id == 2) {
|
||||
hesk_process_messages($hesklang['cannot_delete_admin_or_staff'], $_SERVER['PHP_SELF']);
|
||||
}
|
||||
|
||||
// Otherwise delete the template
|
||||
hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` WHERE `id` = ".intval($id));
|
||||
if (hesk_dbAffectedRows() != 1) {
|
||||
hesk_process_messages($hesklang['no_templates_were_deleted'], $_SERVER['PHP_SELF']);
|
||||
}
|
||||
hesk_process_messages($hesklang['permission_template_deleted'], $_SERVER['PHP_SELF'],'SUCCESS');
|
||||
}
|
||||
|
||||
function toggleAdmin($admin) {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
$id = hesk_GET('id');
|
||||
|
||||
if ($id == 1 || $id == 2) {
|
||||
hesk_process_messages($hesklang['cannot_change_admin_staff'], $_SERVER['PHP_SELF']);
|
||||
}
|
||||
|
||||
if ($admin) {
|
||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` SET `heskprivileges` = 'ALL',
|
||||
`categories` = 'ALL' WHERE `id` = ".intval($id));
|
||||
hesk_process_messages($hesklang['permission_template_now_admin'], $_SERVER['PHP_SELF'],'SUCCESS');
|
||||
} else {
|
||||
// Get default privileges
|
||||
$res = hesk_dbQuery("SELECT `heskprivileges`, `categories` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`
|
||||
WHERE `id` = 2");
|
||||
$row = hesk_dbFetchAssoc($res);
|
||||
|
||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`
|
||||
SET `heskprivileges` = '".hesk_dbEscape($row['heskprivileges'])."',
|
||||
`categories` = '".hesk_dbEscape($row['categories'])."' WHERE `id` = ".intval($id));
|
||||
hesk_process_messages($hesklang['permission_template_no_longer_admin'], $_SERVER['PHP_SELF'],'SUCCESS');
|
||||
}
|
||||
}
|
||||
?>
|
@ -50,37 +50,7 @@ hesk_isLoggedIn();
|
||||
hesk_checkPermission('can_man_users');
|
||||
|
||||
/* Possible user features */
|
||||
$hesk_settings['features'] = array(
|
||||
'can_view_tickets', /* User can read tickets */
|
||||
'can_reply_tickets', /* User can reply to tickets */
|
||||
'can_del_tickets', /* User can delete tickets */
|
||||
'can_edit_tickets', /* User can edit tickets */
|
||||
'can_merge_tickets', /* User can merge tickets */
|
||||
'can_del_notes', /* User can delete ticket notes posted by other staff members */
|
||||
'can_change_cat', /* User can move ticke to a new category/department */
|
||||
'can_man_kb', /* User can manage knowledgebase articles and categories */
|
||||
'can_man_users', /* User can create and edit staff accounts */
|
||||
'can_man_cat', /* User can manage categories/departments */
|
||||
'can_man_canned', /* User can manage canned responses */
|
||||
'can_man_ticket_tpl', /* User can manage ticket templates */
|
||||
'can_add_archive', /* User can mark tickets as "Tagged" */
|
||||
'can_assign_self', /* User can assign tickets to himself/herself */
|
||||
'can_assign_others', /* User can assign tickets to other staff members */
|
||||
'can_view_unassigned', /* User can view unassigned tickets */
|
||||
'can_view_ass_others', /* User can view tickets that are assigned to other staff */
|
||||
'can_run_reports', /* User can run reports and see statistics (only allowed categories and self) */
|
||||
'can_run_reports_full', /* User can run reports and see statistics (unrestricted) */
|
||||
'can_export', /* User can export own tickets to Excel */
|
||||
'can_view_online', /* User can view what staff members are currently online */
|
||||
'can_ban_emails', /* User can ban email addresses */
|
||||
'can_unban_emails', /* User can delete email address bans. Also enables "can_ban_emails" */
|
||||
'can_ban_ips', /* User can ban IP addresses */
|
||||
'can_unban_ips', /* User can delete IP bans. Also enables "can_ban_ips" */
|
||||
'can_service_msg', /* User can manage service messages shown in customer interface */
|
||||
'can_man_email_tpl', /* User can manage email templates */
|
||||
'can_man_ticket_statuses', /* User can manage ticket statuses */
|
||||
'can_set_manager', /* User can set category managers */
|
||||
);
|
||||
$hesk_settings['features'] = hesk_getFeatureArray();
|
||||
|
||||
/* Set default values */
|
||||
$default_userdata = array(
|
||||
@ -100,7 +70,6 @@ $default_userdata = array(
|
||||
'active' => 1,
|
||||
'categories' => array('1'),
|
||||
'features' => array('can_view_tickets','can_reply_tickets','can_change_cat','can_assign_self','can_view_unassigned','can_view_online'),
|
||||
'can_manage_settings' => 0,
|
||||
|
||||
// Preferences
|
||||
'afterreply' => 0,
|
||||
@ -229,7 +198,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
||||
<th><b><i><?php echo $hesklang['name']; ?></i></b></th>
|
||||
<th><b><i><?php echo $hesklang['email']; ?></i></b></th>
|
||||
<th><b><i><?php echo $hesklang['username']; ?></i></b></th>
|
||||
<th><b><i><?php echo $hesklang['administrator']; ?></i></b></th>
|
||||
<th><b><i><?php echo $hesklang['permission_template']; ?></i></b></th>
|
||||
<?php
|
||||
/* Is user rating enabled? */
|
||||
if ($hesk_settings['rating'])
|
||||
@ -341,12 +310,20 @@ while ($myuser = hesk_dbFetchAssoc($res))
|
||||
}
|
||||
}
|
||||
|
||||
$templateName = $hesklang['custom'];
|
||||
if ($myuser['permission_template'] != -1) {
|
||||
$result = hesk_dbQuery("SELECT `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` WHERE `id` = ".intval($myuser['permission_template']));
|
||||
$row = hesk_dbFetchAssoc($result);
|
||||
$templateName = $row['name'];
|
||||
}
|
||||
|
||||
|
||||
echo <<<EOC
|
||||
<tr>
|
||||
<td>$myuser[name]</td>
|
||||
<td><a href="mailto:$myuser[email]">$myuser[email]</a></td>
|
||||
<td>$myuser[user]</td>
|
||||
<td>$myuser[isadmin]</td>
|
||||
<td>$templateName</td>
|
||||
|
||||
EOC;
|
||||
|
||||
@ -463,7 +440,7 @@ function edit_user()
|
||||
|
||||
if ( ! isset($_SESSION['save_userdata']))
|
||||
{
|
||||
$res = hesk_dbQuery("SELECT *,`heskprivileges` AS `features`, `can_manage_settings`, `active`, `can_change_notification_settings`
|
||||
$res = hesk_dbQuery("SELECT *,`heskprivileges` AS `features`, `active`
|
||||
FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`='".intval($id)."' LIMIT 1");
|
||||
$_SESSION['userdata'] = hesk_dbFetchAssoc($res);
|
||||
|
||||
@ -566,8 +543,6 @@ function new_user()
|
||||
`categories`,
|
||||
`autoassign`,
|
||||
`heskprivileges`,
|
||||
`can_manage_settings`,
|
||||
`can_change_notification_settings`,
|
||||
`afterreply`,
|
||||
`autostart`,
|
||||
`notify_customer_new`,
|
||||
@ -581,7 +556,8 @@ function new_user()
|
||||
`notify_pm`,
|
||||
`notify_note`,
|
||||
`notify_note_unassigned`,
|
||||
`autorefresh`) VALUES (
|
||||
`autorefresh`,
|
||||
`permission_template`) VALUES (
|
||||
'".hesk_dbEscape($myuser['user'])."',
|
||||
'".hesk_dbEscape($myuser['pass'])."',
|
||||
'".intval($myuser['isadmin'])."',
|
||||
@ -591,8 +567,6 @@ function new_user()
|
||||
'".hesk_dbEscape($myuser['categories'])."',
|
||||
'".intval($myuser['autoassign'])."',
|
||||
'".hesk_dbEscape($myuser['features'])."',
|
||||
'".hesk_dbEscape($myuser['can_manage_settings'])."',
|
||||
'".hesk_dbEscape($myuser['can_change_notification_settings'])."',
|
||||
'".($myuser['afterreply'])."' ,
|
||||
'".($myuser['autostart'])."' ,
|
||||
'".($myuser['notify_customer_new'])."' ,
|
||||
@ -606,7 +580,8 @@ function new_user()
|
||||
'".($myuser['notify_pm'])."',
|
||||
'".($myuser['notify_note'])."',
|
||||
'".($myuser['notify_note_unassigned'])."',
|
||||
".intval($myuser['autorefresh']).")" );
|
||||
".intval($myuser['autorefresh']).",
|
||||
".intval($myuser['template']).")" );
|
||||
|
||||
$_SESSION['seluser'] = hesk_dbInsertID();
|
||||
|
||||
@ -722,8 +697,6 @@ function update_user()
|
||||
`active`='".intval($myuser['active'])."',
|
||||
`autoassign`='".intval($myuser['autoassign'])."',
|
||||
`heskprivileges`='".hesk_dbEscape($myuser['features'])."',
|
||||
`can_manage_settings`='".hesk_dbEscape($myuser['can_manage_settings'])."',
|
||||
`can_change_notification_settings`='".hesk_dbEscape($myuser['can_change_notification_settings'])."',
|
||||
`afterreply`='".($myuser['afterreply'])."' ,
|
||||
`autostart`='".($myuser['autostart'])."' ,
|
||||
`notify_customer_new`='".($myuser['notify_customer_new'])."' ,
|
||||
@ -737,7 +710,8 @@ function update_user()
|
||||
`notify_pm`='".($myuser['notify_pm'])."',
|
||||
`notify_note`='".($myuser['notify_note'])."',
|
||||
`notify_note_unassigned`='".($myuser['notify_note_unassigned'])."',
|
||||
`autorefresh`=".intval($myuser['autorefresh'])."
|
||||
`autorefresh`=".intval($myuser['autorefresh']).",
|
||||
`permission_template`=".intval($myuser['template'])."
|
||||
WHERE `id`='".intval($myuser['id'])."' LIMIT 1");
|
||||
|
||||
// If they are now inactive, remove any manager rights
|
||||
@ -763,16 +737,12 @@ function hesk_validateUserInfo($pass_required = 1, $redirect_to = './manage_user
|
||||
$myuser['name'] = hesk_input( hesk_POST('name') ) or $hesk_error_buffer .= '<li>' . $hesklang['enter_real_name'] . '</li>';
|
||||
$myuser['email'] = hesk_validateEmail( hesk_POST('email'), 'ERR', 0) or $hesk_error_buffer .= '<li>' . $hesklang['enter_valid_email'] . '</li>';
|
||||
$myuser['user'] = hesk_input( hesk_POST('user') ) or $hesk_error_buffer .= '<li>' . $hesklang['enter_username'] . '</li>';
|
||||
$myuser['isadmin'] = empty($_POST['isadmin']) ? 0 : 1;
|
||||
$myuser['can_manage_settings'] = isset($_POST['manage_settings']) ? 1 : 0;
|
||||
$myuser['isadmin'] = hesk_POST('template') == '1' ? 1 : 0;
|
||||
$myuser['template'] = hesk_POST('template');
|
||||
$myuser['signature'] = hesk_input( hesk_POST('signature') );
|
||||
$myuser['autoassign'] = hesk_POST('autoassign') == 'Y' ? 1 : 0;
|
||||
$myuser['active'] = empty($_POST['active']) ? 0 : 1;
|
||||
$myuser['can_change_notification_settings'] = empty($_POST['can_change_notification_settings']) ? 0 : 1;
|
||||
if ($myuser['isadmin'])
|
||||
{
|
||||
$myuser['can_change_notification_settings'] = 1;
|
||||
}
|
||||
|
||||
/* If it's not admin at least one category and fature is required */
|
||||
$myuser['categories'] = array();
|
||||
|
@ -383,4 +383,20 @@ button.dropdown-submit {
|
||||
|
||||
.default-row-margins {
|
||||
margin: 0 -15px;
|
||||
}
|
||||
|
||||
.icon-link {
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
||||
.orange {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.gray {
|
||||
color: gray;
|
||||
}
|
@ -377,4 +377,20 @@ button.dropdown-submit {
|
||||
|
||||
.default-row-margins {
|
||||
margin: 0 -15px;
|
||||
}
|
||||
|
||||
.icon-link {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.orange {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.gray {
|
||||
color: gray;
|
||||
}
|
@ -715,38 +715,12 @@ function hesk_okCategory($cat,$error=1,$user_isadmin=false,$user_cat=false)
|
||||
function hesk_checkPermission($feature,$showerror=1) {
|
||||
global $hesklang;
|
||||
|
||||
/* Check if this is for managing settings */
|
||||
if ($feature == 'can_manage_settings')
|
||||
{
|
||||
if ($_SESSION['can_manage_settings']) {
|
||||
return true;
|
||||
} else {
|
||||
if ($showerror) {
|
||||
hesk_error($hesklang['no_permission'].'<p> </p><p align="center"><a href="index.php">'.$hesklang['click_login'].'</a>');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Admins have full access to all features */
|
||||
if ($_SESSION['isadmin'])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($feature == 'can_manage_email_templates') {
|
||||
if ($_SESSION['can_manage_email_templates']) {
|
||||
return true;
|
||||
} else {
|
||||
if ($showerror) {
|
||||
hesk_error($hesklang['no_permission'].'<p> </p><p align="center"><a href="index.php">'.$hesklang['click_login'].'</a>');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check other staff for permissions */
|
||||
if (strpos($_SESSION['heskprivileges'], $feature) === false)
|
||||
{
|
||||
|
@ -1911,3 +1911,40 @@ function hesk_dateToString($dt, $returnName=1, $returnTime=0, $returnMonth=0, $f
|
||||
|
||||
return "$m $n, $y";
|
||||
} // End hesk_dateToString()
|
||||
|
||||
function hesk_getFeatureArray() {
|
||||
return array(
|
||||
'can_view_tickets', /* User can read tickets */
|
||||
'can_reply_tickets', /* User can reply to tickets */
|
||||
'can_del_tickets', /* User can delete tickets */
|
||||
'can_edit_tickets', /* User can edit tickets */
|
||||
'can_merge_tickets', /* User can merge tickets */
|
||||
'can_del_notes', /* User can delete ticket notes posted by other staff members */
|
||||
'can_change_cat', /* User can move ticke to a new category/department */
|
||||
'can_man_kb', /* User can manage knowledgebase articles and categories */
|
||||
'can_man_users', /* User can create and edit staff accounts */
|
||||
'can_man_cat', /* User can manage categories/departments */
|
||||
'can_man_canned', /* User can manage canned responses */
|
||||
'can_man_ticket_tpl', /* User can manage ticket templates */
|
||||
'can_add_archive', /* User can mark tickets as "Tagged" */
|
||||
'can_assign_self', /* User can assign tickets to himself/herself */
|
||||
'can_assign_others', /* User can assign tickets to other staff members */
|
||||
'can_view_unassigned', /* User can view unassigned tickets */
|
||||
'can_view_ass_others', /* User can view tickets that are assigned to other staff */
|
||||
'can_run_reports', /* User can run reports and see statistics (only allowed categories and self) */
|
||||
'can_run_reports_full', /* User can run reports and see statistics (unrestricted) */
|
||||
'can_export', /* User can export own tickets to Excel */
|
||||
'can_view_online', /* User can view what staff members are currently online */
|
||||
'can_ban_emails', /* User can ban email addresses */
|
||||
'can_unban_emails', /* User can delete email address bans. Also enables "can_ban_emails" */
|
||||
'can_ban_ips', /* User can ban IP addresses */
|
||||
'can_unban_ips', /* User can delete IP bans. Also enables "can_ban_ips" */
|
||||
'can_service_msg', /* User can manage service messages shown in customer interface */
|
||||
'can_man_email_tpl', /* User can manage email templates */
|
||||
'can_man_ticket_statuses', /* User can manage ticket statuses */
|
||||
'can_set_manager', /* User can set category managers */
|
||||
'can_man_permission_tpl', /* User can manage permission templates */
|
||||
'can_man_settings', /* User can manage helpdesk settings */
|
||||
'can_change_notification_settings', /* User can change notification settings */
|
||||
);
|
||||
}
|
@ -125,15 +125,6 @@ function hesk_profile_tab($session_array='new',$is_profile_page=true,$action='pr
|
||||
echo 'checked="checked"';
|
||||
} ?> /> <?php echo $hesklang['user_aa']; ?></label>
|
||||
</div>
|
||||
<?php }
|
||||
if ($_SESSION['can_manage_settings']) { ?>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox"
|
||||
name="manage_settings" <?php if (!isset($_SESSION[$session_array]['autoassign']) || $_SESSION[$session_array]['can_manage_settings'] == 1) {
|
||||
echo 'checked="checked"';
|
||||
} ?>> <?php echo $hesklang['can_man_settings']; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -146,32 +137,35 @@ function hesk_profile_tab($session_array='new',$is_profile_page=true,$action='pr
|
||||
?>
|
||||
<div role="tabpanel" class="tab-pane fade" id="permissions">
|
||||
<div class="form-group">
|
||||
<label for="administrator" class="col-md-3 control-label"><?php echo $hesklang['administrator']; ?>: <font class="important">*</font></label>
|
||||
<label for="administrator" class="col-md-3 control-label"><?php echo $hesklang['permission_template_colon']; ?></label>
|
||||
<div class="col-md-9">
|
||||
<?php
|
||||
/* Only administrators can create new administrator accounts */
|
||||
if ($_SESSION['isadmin'])
|
||||
{
|
||||
?>
|
||||
<div class="radio"><label><input type="radio" name="isadmin" value="1" onchange="Javascript:hesk_toggleLayerDisplay('options')" <?php if ($_SESSION[$session_array]['isadmin']) echo 'checked="checked"'; ?> /> <b><?php echo $hesklang['administrator'].'</b> '.$hesklang['admin_can']; ?></label></div>
|
||||
<div class="radio"><label><input type="radio" name="isadmin" value="0" onchange="Javascript:hesk_toggleLayerDisplay('options')" <?php if (!$_SESSION[$session_array]['isadmin']) echo 'checked="checked"'; ?> /> <b><?php echo $hesklang['astaff'].'</b> '.$hesklang['staff_can']; ?></label></div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<b>'.$hesklang['astaff'].'</b> '.$hesklang['staff_can'];
|
||||
// Get list of permission templates. If current user is not admin, exclude permission tpl 1
|
||||
$excludeSql = $_SESSION['isadmin'] ? '' : " WHERE `heskprivileges` <> 'ALL'";
|
||||
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`".$excludeSql);
|
||||
$templates = array();
|
||||
echo '<select name="template" id="permission-tpl" class="form-control" onchange="updateCheckboxes()">';
|
||||
while ($row = hesk_dbFetchAssoc($res)) {
|
||||
array_push($templates, $row);
|
||||
$selected = $_SESSION[$session_array]['permission_template'] == $row['id'] ? 'selected' : '';
|
||||
echo '<option value="'.$row['id'].'" '.$selected.'>'.htmlspecialchars($row['name']).'</option>';
|
||||
}
|
||||
$selected = $_SESSION[$session_array]['permission_template'] == '-1' ? 'selected' : '';
|
||||
echo '<option value="-1" '.$selected.'>'.htmlspecialchars($hesklang['custom']).'</option>';
|
||||
echo '</select>';
|
||||
outputCheckboxJavascript();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="options" style="display: <?php echo ($_SESSION['isadmin'] && $_SESSION[$session_array]['isadmin']) ? 'none' : 'block'; ?>">
|
||||
<div id="options">
|
||||
<div class="form-group">
|
||||
<label for="categories" class="col-md-3 control-label"><?php echo $hesklang['allowed_cat']; ?>: <font class="important">*</font></label>
|
||||
<label for="categories[]" class="col-md-3 control-label"><?php echo $hesklang['allowed_cat']; ?>: <font class="important">*</font></label>
|
||||
<div class="col-md-9">
|
||||
<?php
|
||||
foreach ($hesk_settings['categories'] as $catid => $catname)
|
||||
{
|
||||
echo '<div class="checkbox"><label><input type="checkbox" name="categories[]" value="' . $catid . '" ';
|
||||
echo '<div class="checkbox"><label><input id="cat-'.$catid.'" class="cat-checkbox"
|
||||
type="checkbox" name="categories[]" onchange="setTemplateToCustom()" value="' . $catid . '" ';
|
||||
if ( in_array($catid,$_SESSION[$session_array]['categories']) )
|
||||
{
|
||||
echo ' checked="checked" ';
|
||||
@ -182,12 +176,13 @@ function hesk_profile_tab($session_array='new',$is_profile_page=true,$action='pr
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="permissions" class="col-md-3 control-label"><?php echo $hesklang['allow_feat']; ?>: <font class="important">*</font></label>
|
||||
<label for="features[]" class="col-md-3 control-label"><?php echo $hesklang['allow_feat']; ?>: <font class="important">*</font></label>
|
||||
<div class="col-md-9">
|
||||
<?php
|
||||
foreach ($hesk_settings['features'] as $k)
|
||||
{
|
||||
echo '<div class="checkbox"><label><input type="checkbox" name="features[]" value="' . $k . '" ';
|
||||
echo '<div class="checkbox"><label><input id="feat-'.$k.'" class="feat-checkbox"
|
||||
type="checkbox" name="features[]" onchange="setTemplateToCustom()" value="' . $k . '" ';
|
||||
if (in_array($k,$_SESSION[$session_array]['features']))
|
||||
{
|
||||
echo ' checked="checked" ';
|
||||
@ -195,9 +190,6 @@ function hesk_profile_tab($session_array='new',$is_profile_page=true,$action='pr
|
||||
echo ' />' . $hesklang[$k] . '</label></div> ';
|
||||
}
|
||||
?>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" name="can_change_notification_settings" <?php if (!isset($_SESSION[$session_array]['can_change_notification_settings']) || $_SESSION[$session_array]['can_change_notification_settings']) { echo 'checked'; } ?>> <?php echo $hesklang['can_change_notification_settings']; ?> </label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -268,7 +260,9 @@ function hesk_profile_tab($session_array='new',$is_profile_page=true,$action='pr
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane fade" id="notifications">
|
||||
<?php $disabledText = isset($_SESSION[$session_array]['can_change_notification_settings']) && $_SESSION[$session_array]['can_change_notification_settings'] ? '' : 'disabled';
|
||||
<?php $disabledText =
|
||||
(!$_SESSION[$session_array]['isadmin'] && strpos($_SESSION[$session_array]['heskprivileges'],'can_change_notification_settings') === false)
|
||||
? 'disabled' : '';
|
||||
if (!$is_profile_page) {
|
||||
$disabledText = '';
|
||||
}
|
||||
@ -383,3 +377,66 @@ function hesk_profile_tab($session_array='new',$is_profile_page=true,$action='pr
|
||||
|
||||
<?php
|
||||
} // END hesk_profile_tab()
|
||||
|
||||
function outputCheckboxJavascript() {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
// Get categories and features for each template
|
||||
$res = hesk_dbQuery("SELECT `categories`, `heskprivileges`, `id` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`");
|
||||
$templates = array();
|
||||
$finalCatMarkup = "var categories = [];\n";
|
||||
$finalFeatMarkup = "var features = [];\n";
|
||||
while ($row = hesk_dbFetchAssoc($res)) {
|
||||
$templates[$row['id']]['features'] = explode(',', $row['heskprivileges']);
|
||||
$templates[$row['id']]['categories'] = explode(',', $row['categories']);
|
||||
$jsFeatureArray = array();
|
||||
$jsCategoryArray = array();
|
||||
foreach ($templates[$row['id']]['features'] as $array) {
|
||||
$goodText = "'".$array."'";
|
||||
array_push($jsFeatureArray, $goodText);
|
||||
}
|
||||
foreach ($templates[$row['id']]['categories'] as $array) {
|
||||
$goodText = "'".$array."'";
|
||||
array_push($jsCategoryArray, $goodText);
|
||||
}
|
||||
$builtFeatureArray = implode(',', $jsFeatureArray);
|
||||
$builtCategoryArray = implode(',', $jsCategoryArray);
|
||||
$finalCatMarkup .= "categories[".$row['id']."] = [".$builtCategoryArray."];\n";
|
||||
$finalFeatMarkup .= "features[".$row['id']."] = [".$builtFeatureArray."];\n";
|
||||
}
|
||||
|
||||
echo "<script>
|
||||
".$finalCatMarkup."
|
||||
".$finalFeatMarkup."
|
||||
function updateCheckboxes() {
|
||||
// Get the value from the dropdown
|
||||
var dropdownValue = $('#permission-tpl').val();
|
||||
updateCategoriesAndFeatures(dropdownValue);
|
||||
}
|
||||
function updateCategoriesAndFeatures(dropdownValue) {
|
||||
// Get the category array
|
||||
var newCats = categories[dropdownValue];
|
||||
var newFeats = features[dropdownValue];
|
||||
// Uncheck everything
|
||||
$('.cat-checkbox').prop('checked', false);
|
||||
$('.feat-checkbox').prop('checked', false);
|
||||
newCats.forEach(function(entry) {
|
||||
if (entry == 'ALL') {
|
||||
$('.cat-checkbox').prop('checked', true);
|
||||
} else {
|
||||
$('#cat-'+entry).prop('checked', true);
|
||||
}
|
||||
});
|
||||
newFeats.forEach(function(entry) {
|
||||
if (entry == 'ALL') {
|
||||
$('.feat-checkbox').prop('checked', true);
|
||||
} else {
|
||||
$('#feat-'+entry).prop('checked', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
function setTemplateToCustom() {
|
||||
$('#permission-tpl').val('-1');
|
||||
}
|
||||
</script>";
|
||||
}
|
@ -68,8 +68,21 @@ if ( hesk_check_kb_only(false) )
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="admin_main.php"><i class="fa fa-home" <?php echo $iconDisplay; ?>></i> <?php echo $hesklang['main_page']; ?></a></li>
|
||||
<?php if (hesk_checkPermission('can_man_users',0)) {
|
||||
<?php if (hesk_checkPermission('can_man_users', 0) && hesk_checkPermission('can_man_permission_tpl', 0)) {
|
||||
echo '<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<i class="fa fa-users" '.$iconDisplay.'></i> '.$hesklang['menu_users'].'<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="manage_users.php">'.$hesklang['manage_users'].'</a></li>
|
||||
<li><a href="manage_permission_templates.php">'.$hesklang['permission_tpl_man'].'</a></li>
|
||||
</ul>
|
||||
</li>';
|
||||
} elseif (hesk_checkPermission('can_man_users',0)) {
|
||||
echo '<li><a href="manage_users.php"><i class="fa fa-users" '.$iconDisplay.'></i> '.$hesklang['menu_users'].'</a></li>';
|
||||
} elseif (hesk_checkPermission('can_man_permission_tpl', 0)) {
|
||||
echo '<li><a href="manage_permission_templates.php">
|
||||
<i class="fa fa-users" '.$iconDisplay.'></i> '.$hesklang['permission_templates'].'</a></li>';
|
||||
}
|
||||
if (hesk_checkPermission('can_man_cat',0)) {
|
||||
echo '<li><a href="manage_categories.php"><i class="fa fa-pie-chart" '.$iconDisplay.'></i> '.$hesklang['menu_cat'].'</a></li>';
|
||||
@ -112,7 +125,7 @@ if ( hesk_check_kb_only(false) )
|
||||
} elseif (hesk_checkPermission('can_man_ticket_statuses',0)) {
|
||||
echo '<li><a href="manage_statuses.php"><i class="fa fa-wrench" '.$iconDisplay.'></i> '.$hesklang['tools'].'</a> </li>';
|
||||
}
|
||||
if (hesk_checkPermission('can_manage_settings',0)) {
|
||||
if (hesk_checkPermission('can_man_settings',0)) {
|
||||
echo '<li><a href="admin_settings.php"><i class="fa fa-cog" '.$iconDisplay.'></i> '.$hesklang['settings'].'</a></li>';
|
||||
}
|
||||
?>
|
||||
|
@ -9,32 +9,8 @@ require('../sql/uninstallSql.php');
|
||||
$task = $_POST['task'];
|
||||
if ($task == 'status-change') {
|
||||
replaceStatusColumn();
|
||||
} elseif ($task == 'autorefresh') {
|
||||
removeAutorefresh();
|
||||
} elseif ($task == 'parent-child') {
|
||||
removeParentColumn();
|
||||
} elseif ($task == 'settings-access') {
|
||||
removeHelpDeskSettingsPermission();
|
||||
} elseif ($task == 'activate-user') {
|
||||
removeActiveColumn();
|
||||
} elseif ($task == 'notify-note-unassigned') {
|
||||
removeNotifyNoteUnassigned();
|
||||
} elseif ($task == 'user-manage-notification-settings') {
|
||||
removeUserManageOwnNotificationSettingsColumn();
|
||||
} elseif ($task == 'settings-table') {
|
||||
removeSettingsTable();
|
||||
} elseif ($task == 'verified-emails-table') {
|
||||
removeVerifiedEmailsTable();
|
||||
} elseif ($task == 'pending-verification-emails-table') {
|
||||
removePendingVerificationEmailsTable();
|
||||
} elseif ($task == 'pending-verification-tickets-table') {
|
||||
removeTicketsPendingVerificationTable();
|
||||
} elseif ($task == 'service-message-icon') {
|
||||
removeServiceMessageCustomIcon();
|
||||
} elseif ($task == 'location') {
|
||||
removeTicketLocation();
|
||||
} elseif ($task == 'miscellaneous') {
|
||||
executeMiscellaneousSql();
|
||||
} elseif ($task == 'drop-columns') {
|
||||
removeOtherColumns();
|
||||
} else {
|
||||
http_response_code(400);
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
function getTasks() {
|
||||
return ['status-change', 'autorefresh', 'parent-child', 'settings-access', 'activate-user',
|
||||
'notify-note-unassigned', 'user-manage-notification-settings', 'settings-table', 'verified-emails-table',
|
||||
'pending-verification-emails-table', 'pending-verification-tickets-table', 'service-message-icon', 'location',
|
||||
'miscellaneous'];
|
||||
return ['status-change', 'drop-columns'];
|
||||
}
|
||||
|
||||
function processUninstallation() {
|
||||
|
@ -453,6 +453,49 @@ function execute230Scripts() {
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ADD COLUMN `permission_template` INT");
|
||||
executeQuery("CREATE TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`heskprivileges` VARCHAR(1000),
|
||||
`categories` VARCHAR(500))");
|
||||
executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`name`, `heskprivileges`, `categories`)
|
||||
VALUES ('Administrator', 'ALL', 'ALL')");
|
||||
executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`name`, `heskprivileges`, `categories`)
|
||||
VALUES ('Staff', 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online', '1')");
|
||||
executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `permission_template` = 1 WHERE `isadmin` = '1'");
|
||||
|
||||
// Move can_manage_settings and can_change_notification_settings into the heskprivileges list
|
||||
$res = executeQuery("SELECT `id`, `heskprivileges` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `isadmin` = '0'
|
||||
AND `can_manage_settings` = '1'");
|
||||
while ($row = hesk_dbFetchAssoc($res)) {
|
||||
if ($row['heskprivileges'] != '') {
|
||||
$currentPrivileges = explode(',', $row['heskprivileges']);
|
||||
array_push($currentPrivileges, 'can_man_settings');
|
||||
$newPrivileges = implode(',', $currentPrivileges);
|
||||
executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `heskprivileges = '".hesk_dbEscape($newPrivileges)."'
|
||||
WHERE `id` = ".intval($row['id']));
|
||||
} else {
|
||||
executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `heskprivileges = 'can_man_settings'
|
||||
WHERE `id` = ".intval($row['id']));
|
||||
}
|
||||
}
|
||||
$res = executeQuery("SELECT `id`, `heskprivileges` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `isadmin` = '0'
|
||||
AND `can_change_notification_settings` = '1'");
|
||||
while ($row = hesk_dbFetchAssoc($res)) {
|
||||
if ($row['heskprivileges'] != '') {
|
||||
$currentPrivileges = explode(',', $row['heskprivileges']);
|
||||
array_push($currentPrivileges, 'can_change_notification_settings');
|
||||
$newPrivileges = implode(',', $currentPrivileges);
|
||||
executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `heskprivileges = '".hesk_dbEscape($newPrivileges)."'
|
||||
WHERE `id` = ".intval($row['id']));
|
||||
} else {
|
||||
executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `heskprivileges = 'can_change_notification_settings'
|
||||
WHERE `id` = ".intval($row['id']));
|
||||
}
|
||||
}
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `can_manage_settings`");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `can_change_notification_settings`");
|
||||
|
||||
executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'");
|
||||
}
|
||||
|
||||
|
@ -59,97 +59,27 @@ function replaceStatusColumn() {
|
||||
executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`");
|
||||
}
|
||||
|
||||
function removeAutorefresh() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
function removeOtherColumns() {
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `autorefresh`");
|
||||
}
|
||||
|
||||
function removeParentColumn() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `parent`");
|
||||
}
|
||||
|
||||
function removeHelpDeskSettingsPermission() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `can_manage_settings`");
|
||||
}
|
||||
|
||||
function removeActiveColumn() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `active`");
|
||||
}
|
||||
|
||||
function removeNotifyNoteUnassigned() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `notify_note_unassigned`");
|
||||
}
|
||||
|
||||
function removeUserManageOwnNotificationSettingsColumn() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `can_change_notification_settings`");
|
||||
}
|
||||
|
||||
function removeSettingsTable() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings`");
|
||||
}
|
||||
|
||||
function removeVerifiedEmailsTable() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."verified_emails`");
|
||||
}
|
||||
|
||||
function removePendingVerificationEmailsTable() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."pending_verification_emails`");
|
||||
}
|
||||
|
||||
function removeTicketsPendingVerificationTable() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets`");
|
||||
}
|
||||
|
||||
function removeServiceMessageCustomIcon() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` DROP COLUMN `icon`");
|
||||
}
|
||||
|
||||
function removeTicketLocation() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `latitude`");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` DROP COLUMN `longitude`");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` DROP COLUMN `latitude`");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` DROP COLUMN `longitude`");
|
||||
}
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` DROP COLUMN `manager`");
|
||||
executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `permission_template`");
|
||||
executeQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`");
|
||||
|
||||
function executeMiscellaneousSql() {
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
// These queries are ran in case someone used an unfortunate installation they may have not properly cleaned up tables
|
||||
executeQuery('DROP TABLE IF EXISTS `'.hesk_dbEscape($hesk_settings['db_pfix']).'denied_ips`');
|
||||
executeQuery('DROP TABLE IF EXISTS `'.hesk_dbEscape($hesk_settings['db_pfix']).'denied_emails`');
|
||||
|
@ -5,20 +5,8 @@ require(HESK_PATH . 'install/install_functions.inc.php');
|
||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||
|
||||
function echoTaskRows() {
|
||||
printUninstallRow('Change status column to default HESK values', 'status-change');
|
||||
printUninstallRow('Remove autorefresh feature', 'autorefresh');
|
||||
printUninstallRow('Remove parent-child ticket relationships', 'parent-child');
|
||||
printUninstallRow('Remove explicit help desk settings permission', 'settings-access');
|
||||
printUninstallRow('Remove activate/deactivate users settings', 'activate-user');
|
||||
printUninstallRow('Remove Mods for HESK-added notification settings', 'notify-note-unassigned');
|
||||
printUninstallRow('Remove "user can manage notification settings" feature', 'user-manage-notification-settings');
|
||||
printUninstallRow('Remove settings table', 'settings-table');
|
||||
printUninstallRow('Remove verified emails table', 'verified-emails-table');
|
||||
printUninstallRow('Remove pending verification emails table', 'pending-verification-emails-table');
|
||||
printUninstallRow('Remove tickets pending verification table', 'pending-verification-tickets-table');
|
||||
printUninstallRow('Remove custom service messages icon', 'service-message-icon');
|
||||
printUninstallRow('Remove ticket location', 'location');
|
||||
printUninstallRow('Miscellaneous database cleanup changes', 'miscellaneous');
|
||||
printUninstallRow('Remove custom statuses', 'status-change');
|
||||
printUninstallRow('Reset other tables', 'drop-columns');
|
||||
}
|
||||
|
||||
function printUninstallRow($text, $id) {
|
||||
|
@ -70,6 +70,38 @@ $hesklang['manager'] = 'Manager';
|
||||
$hesklang['manager_updated'] = 'Category manager has been updated.';
|
||||
$hesklang['can_set_manager'] = 'Can set category managers';
|
||||
$hesklang['no_manager'] = 'No manager';
|
||||
$hesklang['manage_permission_templates'] = 'Manage Permission Templates';
|
||||
$hesklang['number_of_users'] = 'Number of Users';
|
||||
$hesklang['actions'] = 'Actions';
|
||||
$hesklang['view_permissions_for_this_template'] = 'View/edit permissions for this template';
|
||||
$hesklang['permission'] = 'Permission';
|
||||
$hesklang['permissions_for_template'] = 'Permissions for template <code>%s</code>'; // %s template name
|
||||
$hesklang['template_has_admin_privileges'] = 'Permission template has admin privileges. Click to set as non-admin';
|
||||
$hesklang['template_has_no_admin_privileges'] = 'Permission template does not have admin privileges. Click to set as admin';
|
||||
$hesklang['staff_cannot_be_admin'] = 'Staff permission group does not have admin access, and cannot be set as an admin';
|
||||
$hesklang['admin_cannot_be_staff'] = 'Administrator permission group has admin access, and cannot be set as non-admin';
|
||||
$hesklang['template_is_admin_cannot_change'] = 'The permission group currently has admin privileges, so you cannot set specific permissions here.';
|
||||
$hesklang['permission_template_updated'] = 'Permission template has been updated!';
|
||||
$hesklang['create_new_template'] = 'Create new permission template';
|
||||
$hesklang['create_new_template_title'] = 'Create New Permission Template'; // same as create_new_template, but in Title Case
|
||||
$hesklang['template_name'] = 'Template name';
|
||||
$hesklang['template_name_required'] = 'Template name required.';
|
||||
$hesklang['you_must_select_a_category'] = 'You must select at least one category.';
|
||||
$hesklang['you_must_select_a_feature'] = 'You must select at least one feature.';
|
||||
$hesklang['permission_template_error'] = 'The permission template could not be completed due to the following error(s): %s'; // %s: error list
|
||||
$hesklang['template_created'] = 'Permission template successfully created!';
|
||||
$hesklang['cannot_delete_admin_or_staff'] = 'The <b>Administrator</b> and <b>Staff</b> permission groups cannot be deleted!';
|
||||
$hesklang['no_templates_were_deleted'] = 'No templates were deleted!';
|
||||
$hesklang['permission_template_deleted'] = 'Permission template deleted!';
|
||||
$hesklang['permission_template_now_admin'] = 'Permission template is now designed as an admin template';
|
||||
$hesklang['permission_template_no_longer_admin'] = 'Permission template is no longer designated as an admin template';
|
||||
$hesklang['cannot_change_admin_staff'] = 'You cannot change admin/non-admin status for the <b>Administrator</b> and <b>Staff</b> templates!';
|
||||
$hesklang['permission_tpl_man'] = 'Manage permission templates'; // Menu link
|
||||
$hesklang['permission_templates'] = 'Permission Templates';
|
||||
$hesklang['can_man_permission_tpl'] = 'Can manage permission templates';
|
||||
$hesklang['permission_template_colon'] = 'Permission Template:';
|
||||
$hesklang['permission_template'] = 'Permission Template';
|
||||
$hesklang['custom'] = 'Custom';
|
||||
|
||||
// ADDED OR MODIFIED IN Mods for HESK 2.2.1
|
||||
$hesklang['popart_no_colon']='Top Knowledgebase Articles'; // same as $hesklang['popart'] but without a colon (:)
|
||||
|
Loading…
x
Reference in New Issue
Block a user