|
|
|
@ -3,14 +3,20 @@
|
|
|
|
|
namespace BusinessLogic\Calendar;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use BusinessLogic\DateTimeHelpers;
|
|
|
|
|
use BusinessLogic\Security\UserContext;
|
|
|
|
|
use BusinessLogic\Tickets\AuditTrailEntityType;
|
|
|
|
|
use DataAccess\AuditTrail\AuditTrailGateway;
|
|
|
|
|
use DataAccess\Calendar\CalendarGateway;
|
|
|
|
|
|
|
|
|
|
class CalendarHandler extends \BaseClass {
|
|
|
|
|
private $calendarGateway;
|
|
|
|
|
private $auditTrailGateway;
|
|
|
|
|
|
|
|
|
|
public function __construct(CalendarGateway $calendarGateway) {
|
|
|
|
|
public function __construct(CalendarGateway $calendarGateway,
|
|
|
|
|
AuditTrailGateway $auditTrailGateway) {
|
|
|
|
|
$this->calendarGateway = $calendarGateway;
|
|
|
|
|
$this->auditTrailGateway = $auditTrailGateway;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getEventsForStaff($searchEventsFilter, $heskSettings) {
|
|
|
|
@ -37,10 +43,25 @@ class CalendarHandler extends \BaseClass {
|
|
|
|
|
throw new \Exception("Expected exactly 1 event, found: " . count($events));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $calendarEvent CalendarEvent
|
|
|
|
|
* @param $userContext UserContext
|
|
|
|
|
* @param $heskSettings array
|
|
|
|
|
* @return AbstractEvent
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
*/
|
|
|
|
|
public function createEvent($calendarEvent, $userContext, $heskSettings) {
|
|
|
|
|
$this->calendarGateway->createEvent($calendarEvent, $userContext, $heskSettings);
|
|
|
|
|
|
|
|
|
@ -54,7 +75,15 @@ class CalendarHandler extends \BaseClass {
|
|
|
|
|
throw new \Exception("Expected exactly 1 event, found: " . count($events));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $events[0];
|
|
|
|
|
$event = $events[0];
|
|
|
|
|
|
|
|
|
|
$this->auditTrailGateway->insertAuditTrailRecord($event->id,
|
|
|
|
|
AuditTrailEntityType::CALENDAR_EVENT,
|
|
|
|
|
'audit_event_created',
|
|
|
|
|
DateTimeHelpers::heskDate($heskSettings),
|
|
|
|
|
array(0 => $userContext->name . ' (' . $userContext->username . ')'), $heskSettings);
|
|
|
|
|
|
|
|
|
|
return $event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteEvent($id, $userContext, $heskSettings) {
|
|
|
|
|