#196 Can now update permission templates
This commit is contained in:
parent
8328d206fc
commit
82896346ec
@ -52,8 +52,7 @@ hesk_checkPermission('can_man_cat');
|
||||
/* What should we do? */
|
||||
if ( $action = hesk_REQUEST('a') )
|
||||
{
|
||||
if ($action == 'linkcode') {generate_link_code();}
|
||||
elseif ( defined('HESK_DEMO') ) {hesk_process_messages($hesklang['ddemo'], 'manage_categories.php', 'NOTICE');}
|
||||
if ($action == 'save') {save();}
|
||||
}
|
||||
|
||||
/* Print header */
|
||||
@ -89,6 +88,9 @@ else {return false;}
|
||||
<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();
|
||||
?>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th><?php echo $hesklang['name']; ?></th>
|
||||
@ -110,9 +112,13 @@ else {return false;}
|
||||
<?php else: ?>
|
||||
<i class="fa fa-star-o icon-link gray" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['template_has_no_admin_privileges']; ?>"></i>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif;
|
||||
if ($row['id'] != 1 && $row['id'] != 2):
|
||||
?>
|
||||
<i class="fa fa-times icon-link red" data-toggle="tooltip"
|
||||
title="<?php echo $hesklang['delete']; ?>"></i>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@ -120,10 +126,9 @@ else {return false;}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
foreach ($templates as $template) {
|
||||
createModal($template, $featureArray, $categories);
|
||||
createEditModal($template, $featureArray, $categories);
|
||||
}
|
||||
|
||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||
@ -138,7 +143,7 @@ function getNumberOfUsersWithPermissionGroup($templateId) {
|
||||
return hesk_dbNumRows($res);
|
||||
}
|
||||
|
||||
function createModal($template, $features, $categories) {
|
||||
function createEditModal($template, $features, $categories) {
|
||||
global $hesklang;
|
||||
|
||||
$showNotice = true;
|
||||
@ -155,7 +160,7 @@ function createModal($template, $features, $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">
|
||||
<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>
|
||||
@ -174,7 +179,12 @@ function createModal($template, $features, $categories) {
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="cat-<?php echo $category['id']; ?>" <?php echo $disabled; ?>>
|
||||
<?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>
|
||||
@ -187,8 +197,12 @@ function createModal($template, $features, $categories) {
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="<?php echo $feature; ?>" <?php echo $disabled; ?>>
|
||||
<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>
|
||||
@ -198,8 +212,12 @@ function createModal($template, $features, $categories) {
|
||||
</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-primary" value="<?php echo $hesklang['save_changes']; ?>">
|
||||
<?php endif; ?>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $hesklang['close_modal']; ?></button>
|
||||
</div>
|
||||
</div>
|
||||
@ -209,4 +227,18 @@ function createModal($template, $features, $categories) {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function save() {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
$categories = implode(',', hesk_POST_array('categories'));
|
||||
$features = implode(',', hesk_POST_array('features'));
|
||||
$templateId = hesk_POST('template_id');
|
||||
|
||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates`
|
||||
SET `categories` = '".hesk_dbEscape($categories)."', `heskprivileges` = '".hesk_dbEscape($features)."' WHERE
|
||||
`id` = ".intval($templateId));
|
||||
|
||||
hesk_process_messages( $hesklang['permission_template_updated'],$_SERVER['PHP_SELF'],'SUCCESS');
|
||||
}
|
||||
?>
|
||||
|
@ -79,6 +79,7 @@ $hesklang['permissions_for_template'] = 'Permissions for template <code>%s</code
|
||||
$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['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!';
|
||||
|
||||
// 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