Audit trail now displays for users who can manage calendar
This commit is contained in:
parent
401e335e5f
commit
624267fe45
@ -334,11 +334,11 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
</div>
|
</div>
|
||||||
<form id="edit-form" class="form-horizontal" data-toggle="validator">
|
<form id="edit-form" class="form-horizontal" data-toggle="validator">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist" id="edit-modal-tabs">
|
||||||
<li role="presentation" class="active"><a href="#edit-contents" aria-controls="home" role="tab" data-toggle="tab">Information [!]</a></li>
|
<li role="presentation" class="active"><a href="#edit-contents" aria-controls="home" role="tab" data-toggle="tab"><?php echo $hesklang['information']; ?></a></li>
|
||||||
<li role="presentation"><a href="#edit-history" aria-controls="profile" role="tab" data-toggle="tab">History [!]</a></li>
|
<li role="presentation"><a href="#edit-history" aria-controls="profile" role="tab" data-toggle="tab"><?php echo $hesklang['thist']; ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content" id="information-tab">
|
||||||
<div role="tabpanel" class="tab-pane active" id="edit-contents">
|
<div role="tabpanel" class="tab-pane active" id="edit-contents">
|
||||||
<br>
|
<br>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -490,18 +490,12 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date[!]</th>
|
<th><?php echo $hesklang['date']; ?></th>
|
||||||
<th>Description[!]</th>
|
<th><?php echo $hesklang['description']; ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody id="history-table"></tbody>
|
||||||
<tr>
|
|
||||||
<td>2018-01-24</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
<p>Fill this in</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -595,7 +589,9 @@ echo mfh_get_hidden_fields_for_language(array('error_loading_events',
|
|||||||
'critical',
|
'critical',
|
||||||
'high',
|
'high',
|
||||||
'medium',
|
'medium',
|
||||||
'low'));
|
'low',
|
||||||
|
'audit_event_created',
|
||||||
|
'audit_event_updated'));
|
||||||
?>
|
?>
|
||||||
<div style="display: none">
|
<div style="display: none">
|
||||||
<p id="setting_first_day_of_week"><?php echo $modsForHesk_settings['first_day_of_week']; ?></p>
|
<p id="setting_first_day_of_week"><?php echo $modsForHesk_settings['first_day_of_week']; ?></p>
|
||||||
@ -610,6 +606,12 @@ echo mfh_get_hidden_fields_for_language(array('error_loading_events',
|
|||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/html" id="audit-trail-template">
|
||||||
|
<tr>
|
||||||
|
<td data-property="date"></td>
|
||||||
|
<td data-property="description"></td>
|
||||||
|
</tr>
|
||||||
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||||
|
@ -33,6 +33,12 @@ class CalendarHandler extends \BaseClass {
|
|||||||
public function updateEvent($calendarEvent, $userContext, $heskSettings) {
|
public function updateEvent($calendarEvent, $userContext, $heskSettings) {
|
||||||
$this->calendarGateway->updateEvent($calendarEvent, $userContext, $heskSettings);
|
$this->calendarGateway->updateEvent($calendarEvent, $userContext, $heskSettings);
|
||||||
|
|
||||||
|
$this->auditTrailGateway->insertAuditTrailRecord($calendarEvent->id,
|
||||||
|
AuditTrailEntityType::CALENDAR_EVENT,
|
||||||
|
'audit_event_updated',
|
||||||
|
DateTimeHelpers::heskDate($heskSettings),
|
||||||
|
array(0 => $userContext->name . ' (' . $userContext->username . ')'), $heskSettings);
|
||||||
|
|
||||||
$eventFilter = new SearchEventsFilter();
|
$eventFilter = new SearchEventsFilter();
|
||||||
$eventFilter->eventId = $calendarEvent->id;
|
$eventFilter->eventId = $calendarEvent->id;
|
||||||
$eventFilter->reminderUserId = $userContext->id;
|
$eventFilter->reminderUserId = $userContext->id;
|
||||||
@ -45,12 +51,6 @@ class CalendarHandler extends \BaseClass {
|
|||||||
|
|
||||||
$event = $events[0];
|
$event = $events[0];
|
||||||
|
|
||||||
$this->auditTrailGateway->insertAuditTrailRecord($event->id,
|
|
||||||
AuditTrailEntityType::CALENDAR_EVENT,
|
|
||||||
'audit_event_updated',
|
|
||||||
DateTimeHelpers::heskDate($heskSettings),
|
|
||||||
array(0 => $userContext->name . ' (' . $userContext->username . ')'), $heskSettings);
|
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ use BusinessLogic\Tickets\AuditTrail;
|
|||||||
use BusinessLogic\Tickets\AuditTrailEntityType;
|
use BusinessLogic\Tickets\AuditTrailEntityType;
|
||||||
use Core\Constants\Priority;
|
use Core\Constants\Priority;
|
||||||
use DataAccess\CommonDao;
|
use DataAccess\CommonDao;
|
||||||
use DataAccess\Logging\LoggingGateway;
|
|
||||||
|
|
||||||
class CalendarGateway extends CommonDao {
|
class CalendarGateway extends CommonDao {
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +78,7 @@ header('X-UA-Compatible: IE=edge');
|
|||||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/lang.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/lang.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/clipboard.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/clipboard.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||||
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-select.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-select.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/sprintf.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
|
||||||
<?php
|
<?php
|
||||||
if (defined('EXTRA_JS')) {
|
if (defined('EXTRA_JS')) {
|
||||||
echo EXTRA_JS;
|
echo EXTRA_JS;
|
||||||
|
@ -262,7 +262,7 @@ $(document).ready(function() {
|
|||||||
displayBorder: $form.find('select[name="category"] :selected').attr('data-display-border'),
|
displayBorder: $form.find('select[name="category"] :selected').attr('data-display-border'),
|
||||||
categoryName: $form.find('select[name="category"] :selected').text().trim(),
|
categoryName: $form.find('select[name="category"] :selected').text().trim(),
|
||||||
reminderValue: reminderValue === "" ? null : reminderValue,
|
reminderValue: reminderValue === "" ? null : reminderValue,
|
||||||
reminderUnits: reminderValue === "" ? null : reminderUnits
|
reminderUnits: reminderValue === "" ? null : reminderUnits,
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -274,7 +274,8 @@ $(document).ready(function() {
|
|||||||
'X-Internal-Call': true,
|
'X-Internal-Call': true,
|
||||||
'X-HTTP-Method-Override': 'PUT'
|
'X-HTTP-Method-Override': 'PUT'
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function(updatedEvent) {
|
||||||
|
data.auditTrail = updatedEvent.auditTrail;
|
||||||
removeFromCalendar(data.id);
|
removeFromCalendar(data.id);
|
||||||
addToCalendar(data.id, data, $('#lang_event_updated').text());
|
addToCalendar(data.id, data, $('#lang_event_updated').text());
|
||||||
$('#edit-event-modal').modal('hide');
|
$('#edit-event-modal').modal('hide');
|
||||||
@ -352,7 +353,8 @@ function buildEvent(id, dbObject) {
|
|||||||
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
|
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
|
||||||
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
|
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
|
||||||
reminderUnits: dbObject.reminderUnits,
|
reminderUnits: dbObject.reminderUnits,
|
||||||
fontIconMarkup: '<i class="fa fa-calendar"></i>'
|
fontIconMarkup: '<i class="fa fa-calendar"></i>',
|
||||||
|
auditTrail: dbObject.auditTrail
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,6 +474,24 @@ function displayEditModal(date) {
|
|||||||
|
|
||||||
$form.find('select[name="category"] option[value="' + date.categoryId + '"]').prop('selected', true);
|
$form.find('select[name="category"] option[value="' + date.categoryId + '"]').prop('selected', true);
|
||||||
|
|
||||||
|
var $auditTrail = $('#edit-history');
|
||||||
|
if (date.auditTrail.length === 0) {
|
||||||
|
$('.nav-tabs[role="tablist"]').hide();
|
||||||
|
} else {
|
||||||
|
$('.nav-tabs[role="tablist"]').show();
|
||||||
|
|
||||||
|
var $historyTable = $('#history-table');
|
||||||
|
$historyTable.html('');
|
||||||
|
$.each(date.auditTrail, function() {
|
||||||
|
var $template = $($('#audit-trail-template').html());
|
||||||
|
$template.find('[data-property="date"]').text(this.date).end()
|
||||||
|
.find('[data-property="description"]').text(vsprintf(mfhLang.text(this.languageKey), this.replacementValues));
|
||||||
|
|
||||||
|
$historyTable.append($template);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('#edit-modal-tabs').find('a:first').tab('show');
|
||||||
|
|
||||||
$('#edit-event-modal').modal('show');
|
$('#edit-event-modal').modal('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,6 +556,7 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
|||||||
end += ' ' + event.end.format('HH:mm:ss');
|
end += ' ' + event.end.format('HH:mm:ss');
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
|
id: event.id,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
location: event.location,
|
location: event.location,
|
||||||
startTime: start,
|
startTime: start,
|
||||||
@ -557,8 +578,9 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
|||||||
'X-Internal-Call': true,
|
'X-Internal-Call': true,
|
||||||
'X-HTTP-Method-Override': 'PUT'
|
'X-HTTP-Method-Override': 'PUT'
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function(updatedEvent) {
|
||||||
mfhAlert.success(mfhLang.text('event_updated'));
|
removeFromCalendar(updatedEvent.id);
|
||||||
|
addToCalendar(updatedEvent.id, updatedEvent, $('#lang_event_updated').text());
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
mfhAlert.error(mfhLang.text('error_updating_event'));
|
mfhAlert.error(mfhLang.text('error_updating_event'));
|
||||||
|
3
js/sprintf.min.js
vendored
Normal file
3
js/sprintf.min.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/*! sprintf-js v1.1.0 | Copyright (c) 2007-present, Alexandru Marasteanu <hello@alexei.ro> | BSD-3-Clause */
|
||||||
|
!function(e){"use strict";function t(){var e=arguments[0],r=t.cache;return r[e]||(r[e]=t.parse(e)),t.format.call(null,r[e],arguments)}function r(e){return"number"==typeof e?"number":"string"==typeof e?"string":Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e,t){return t>=0&&t<=7&&i[e]?i[e][t]:Array(t+1).join(e)}var s={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};t.format=function(e,a){var i,o,l,c,p,f,u,g=1,_=e.length,d="",b=[],h=!0,x="";for(o=0;o<_;o++)if("string"===(d=r(e[o])))b[b.length]=e[o];else if("array"===d){if(c=e[o],c[2])for(i=a[g],l=0;l<c[2].length;l++){if(!i.hasOwnProperty(c[2][l]))throw new Error(t('[sprintf] property "%s" does not exist',c[2][l]));i=i[c[2][l]]}else i=c[1]?a[c[1]]:a[g++];if(s.not_type.test(c[8])&&s.not_primitive.test(c[8])&&"function"==r(i)&&(i=i()),s.numeric_arg.test(c[8])&&"number"!=r(i)&&isNaN(i))throw new TypeError(t("[sprintf] expecting number but found %s",r(i)));switch(s.number.test(c[8])&&(h=i>=0),c[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,c[6]?parseInt(c[6]):0);break;case"e":i=c[7]?parseFloat(i).toExponential(c[7]):parseFloat(i).toExponential();break;case"f":i=c[7]?parseFloat(i).toFixed(c[7]):parseFloat(i);break;case"g":i=c[7]?parseFloat(i).toPrecision(c[7]):parseFloat(i);break;case"o":i=i.toString(8);break;case"s":i=String(i),i=c[7]?i.substring(0,c[7]):i;break;case"t":i=String(!!i),i=c[7]?i.substring(0,c[7]):i;break;case"T":i=r(i),i=c[7]?i.substring(0,c[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=c[7]?i.substring(0,c[7]):i;break;case"x":i=parseInt(i,10).toString(16);break;case"X":i=parseInt(i,10).toString(16).toUpperCase()}s.json.test(c[8])?b[b.length]=i:(!s.number.test(c[8])||h&&!c[3]?x="":(x=h?"+":"-",i=i.toString().replace(s.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",u=c[6]-(x+i).length,p=c[6]&&u>0?n(f,u):"",b[b.length]=c[5]?x+i+p:"0"===f?x+p+i:p+x+i)}return b.join("")},t.cache=Object.create(null),t.parse=function(e){for(var t=e,r=[],n=[],a=0;t;){if(null!==(r=s.text.exec(t)))n[n.length]=r[0];else if(null!==(r=s.modulo.exec(t)))n[n.length]="%";else{if(null===(r=s.placeholder.exec(t)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){a|=1;var i=[],o=r[2],l=[];if(null===(l=s.key.exec(o)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(i[i.length]=l[1];""!==(o=o.substring(l[0].length));)if(null!==(l=s.key_access.exec(o)))i[i.length]=l[1];else{if(null===(l=s.index_access.exec(o)))throw new SyntaxError("[sprintf] failed to parse named argument key");i[i.length]=l[1]}r[2]=i}else a|=2;if(3===a)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}t=t.substring(r[0].length)}return n};var a=function(e,r,n){return n=(r||[]).slice(0),n.splice(0,0,e),t.apply(null,n)},i={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," "," "," "," "," "," "," "],_:["","_","__","___","____","_____","______","_______"]};"undefined"!=typeof exports&&(exports.sprintf=t,exports.vsprintf=a),void 0!==e&&(e.sprintf=t,e.vsprintf=a,"function"==typeof define&&define.amd&&define(function(){return{sprintf:t,vsprintf:a}}))}("undefined"==typeof window?this:window);
|
||||||
|
//# sourceMappingURL=sprintf.min.js.map
|
Loading…
x
Reference in New Issue
Block a user