Browse Source

Add readonly option and security group

merge-requests/1/head
Mike Koch 6 years ago
parent
commit
a989911864
  1. 12
      admin/calendar.php
  2. 1
      inc/common.inc.php
  3. 2
      inc/header.inc.php
  4. 9
      inc/headerAdmin.inc.php
  5. 15
      internal-api/js/core-admin.php
  6. 6
      internal-api/js/core.php
  7. 0
      js/calendar/mods-for-hesk-calendar-admin-readonly.js
  8. 147
      js/calendar/mods-for-hesk-calendar-readonly.js
  9. 1
      language/en/text.php

12
admin/calendar.php

@ -47,7 +47,11 @@ hesk_isLoggedIn();
//hesk_checkPermission('can_service_msg');
// Define required constants
define('MFH_CALENDAR', 1);
if (hesk_checkPermission('can_man_calendar', 0)) {
define('MFH_CALENDAR', 1);
} else {
define('MFH_CALENDAR_READONLY', 1);
}
// Get categories for the dropdown
$rs = hesk_dbQuery("SELECT `id`, `name`, `color` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` WHERE `usage` <> 1 ORDER BY `cat_order`");
@ -90,13 +94,17 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
<div class="panel panel-default">
<div class="panel-heading">
<h4>
<?php echo $hesklang['calendar_title_case']; ?>
<?php
echo $hesklang['calendar_title_case'];
if (hesk_checkPermission('can_man_calendar', 0)):
?>
<span class="nu-floatRight panel-button">
<button class="btn btn-success" id="create-event-button">
<i class="fa fa-plus-circle"></i>
<?php echo $hesklang['new_event']; ?>
</button>
</span>
<?php endif; ?>
</h4>
</div>
<div class="panel-body">

1
inc/common.inc.php

@ -1762,6 +1762,7 @@ function hesk_getFeatureArray()
'can_man_settings', /* User can manage helpdesk settings */
'can_change_notification_settings', /* User can change notification settings */
'can_view_logs', /* User can view the message logs */
'can_man_calendar', /* User can manage calendar events */
);
}

2
inc/header.inc.php

@ -249,7 +249,7 @@ if (is_dir(HESK_PATH . 'install')) {
?>
<script src="<?php echo HESK_PATH; ?>js/calendar/moment.js"></script>
<script src="<?php echo HESK_PATH; ?>js/calendar/fullcalendar.min.js"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/calendar/mods-for-hesk-customer-calendar.js"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/calendar/mods-for-hesk-calendar-readonly.js"></script>
<?php
}
?>

9
inc/headerAdmin.inc.php

@ -95,7 +95,7 @@ $modsForHesk_settings = mfh_getSettings();
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/platform.js"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-validator.min.js"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/core.php"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/core-admin.php"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/jquery.jgrowl.min.js"></script>
<?php
if (defined('EXTRA_JS')) {
@ -224,8 +224,11 @@ $modsForHesk_settings = mfh_getSettings();
<script src="<?php echo HESK_PATH; ?>js/calendar/moment.js"></script>
<script src="<?php echo HESK_PATH; ?>js/calendar/fullcalendar.min.js"></script>
<script src="<?php echo HESK_PATH; ?>js/calendar/mods-for-hesk-calendar.js"></script>
<?php }
?>
<?php } else if (defined('MFH_CALENDAR_READONLY')) { ?>
<script src="<?php echo HESK_PATH; ?>js/calendar/moment.js"></script>
<script src="<?php echo HESK_PATH; ?>js/calendar/fullcalendar.min.js"></script>
<script src="<?php echo HESK_PATH; ?>js/calendar/mods-for-hesk-calendar-admin-readonly.js"></script>
<?php } ?>
</head>
<body onload="<?php echo $onload;

15
internal-api/js/core-admin.php

@ -0,0 +1,15 @@
<?php
define('IN_SCRIPT', 1);
require_once('../../hesk_settings.inc.php');
header('Content-Type: application/javascript');
echo "
var g_isInAdmin = true;
function getHelpdeskUrl() {
return '".$hesk_settings['hesk_url']."';
}
function getAdminDirectory() {
return '".$hesk_settings['admin_dir']."';
}
";

6
internal-api/js/core.php

@ -3,11 +3,9 @@ define('IN_SCRIPT', 1);
require_once('../../hesk_settings.inc.php');
header('Content-Type: application/javascript');
echo "
var g_isInAdmin = false;
function getHelpdeskUrl() {
return '".$hesk_settings['hesk_url']."';
}
function getAdminDirectory() {
return '".$hesk_settings['admin_dir']."';
}
";

0
js/calendar/mods-for-hesk-customer-calendar.js → js/calendar/mods-for-hesk-calendar-admin-readonly.js

147
js/calendar/mods-for-hesk-calendar-readonly.js

@ -0,0 +1,147 @@
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prevYear,prev,next,nextYear today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,
eventLimit: true,
timeFormat: 'H:mm',
axisFormat: 'H:mm',
events: function(start, end, timezone, callback) {
$.ajax({
url: getHelpdeskUrl() + '/internal-api/calendar/?start=' + start + '&end=' + end,
method: 'GET',
dataType: 'json',
success: function(data) {
var events = [];
$(data).each(function() {
events.push(buildEvent(this.id, this));
});
callback(events);
},
error: function(data) {
console.error(data);
$.jGrowl($('#lang_error_loading_events').text(), { theme: 'alert-danger', closeTemplate: '' });
}
});
},
eventMouseover: function(event) {
if (event.type === 'TICKET') {
// Don't build a popover for tickets
return;
}
var contents = $('.popover-template').html();
var $contents = $(contents);
var format = 'dddd, MMMM Do YYYY';
var endDate = event.end == null ? event.start : event.end;
if (!event.allDay) {
format += ', HH:mm';
}
if (event.location === '') {
$contents.find('.popover-location').hide();
}
$contents.find('.popover-category span').text(event.categoryName).end()
.find('.popover-location span').text(event.location).end()
.find('.popover-from span').text(event.start.format(format)).end()
.find('.popover-to span').text(endDate.format(format));
var $eventMarkup = $(this);
$eventMarkup.popover({
title: event.title,
html: true,
content: $contents,
animation: true,
container: 'body',
placement: 'auto'
}).popover('show');
},
eventMouseout: function(event) {
if (event.type === 'TICKET') {
// There's no popover to destroy
return;
}
$(this).popover('destroy');
}
});
$('input[name="category-toggle"]').change(updateCategoryVisibility);
});
function buildEvent(id, dbObject) {
if (dbObject.type == 'TICKET') {
return {
title: dbObject.title,
trackingId: dbObject.trackingId,
start: moment(dbObject.startTime),
url: dbObject.url,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
allDay: true,
type: dbObject.type,
categoryId: dbObject.categoryId,
className: 'category-' + dbObject.categoryId,
textColor: calculateTextColor(dbObject.categoryColor)
};
}
return {
id: id,
title: dbObject.title,
allDay: dbObject.allDay,
start: moment(dbObject.startTime),
end: moment(dbObject.endTime),
comments: dbObject.comments,
location: dbObject.location,
type: dbObject.type,
categoryId: dbObject.categoryId,
categoryName: dbObject.categoryName,
className: 'category-' + dbObject.categoryId,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
textColor: calculateTextColor(dbObject.categoryColor),
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
reminderUnits: dbObject.reminderUnits
};
}
function calculateTextColor(color) {
if (color === null || color === '') {
return 'black';
}
var red = 0;
var green = 0;
var blue = 0;
// If hex value is 3 characters, take each value and concatenate it to itself
if (color.length === 3) {
red = parseInt(color.substring(1, 2), 16);
green = parseInt(color.substring(2, 3), 16);
blue = parseInt(color.substring(3, 4), 16);
} else {
red = parseInt(color.substring(1, 3), 16);
green = parseInt(color.substring(3, 5), 16);
blue = parseInt(color.substring(5, 7), 16);
}
var gray = red * 0.299 + green * 0.587 + blue * 0.114;
return gray > 186 ? 'black' : 'white';
}
function updateCategoryVisibility() {
$('input[name="category-toggle"]').each(function() {
$this = $(this);
if ($this.is(':checked')) {
$('.category-' + $this.val()).show();
} else {
$('.category-' + $this.val()).hide();
}
});
}

1
language/en/text.php

@ -81,6 +81,7 @@ $hesklang['event_updated'] = 'Event successfully updated';
$hesklang['error_updating_event'] = 'An error occurred when trying to update the event';
$hesklang['calendar_title_case'] = 'Calendar';
$hesklang['calendar_categories'] = 'Categories';
$hesklang['can_man_calendar'] = 'Can manage calendar events';
// ADDED OR MODIFIED IN Mods for HESK 2.5.2
$hesklang['manage_statuses'] = 'Manage Statuses';

Loading…
Cancel
Save