Pull 3.3.0 from upstream
commit
1017b64913
@ -1,32 +1,90 @@
|
|||||||
image: tetraweb/php
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- validate
|
||||||
- test
|
- test
|
||||||
- deploy
|
- package
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update
|
- bash ci/docker_install.sh > /dev/null
|
||||||
- apt-get install zip unzip
|
|
||||||
- cd api
|
validate:7.2:
|
||||||
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
image: php:7.2
|
||||||
- php composer-setup.php
|
stage: validate
|
||||||
- php -r "unlink('composer-setup.php');"
|
script:
|
||||||
- php composer.phar update
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
test:
|
validate:7.1:
|
||||||
|
image: php:7.1
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
|
validate:7.0:
|
||||||
|
image: php:7.0
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
|
validate:5.6:
|
||||||
|
image: php:5.6
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
|
validate:5.5:
|
||||||
|
image: php:5.5
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
|
validate:5.4:
|
||||||
|
image: php:5.4
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
|
validate:5.3:
|
||||||
|
image: php:5.3
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- bash ci/php_lint.sh ./
|
||||||
|
|
||||||
|
test:7.1:
|
||||||
|
image: php:7.1
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- cd api
|
||||||
|
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
|
- php composer-setup.php
|
||||||
|
- php -r "unlink('composer-setup.php');"
|
||||||
|
- php composer.phar update
|
||||||
|
- php composer.phar install
|
||||||
|
- cd Tests
|
||||||
|
- phpunit
|
||||||
|
|
||||||
|
test:7.2:
|
||||||
|
image: php:7.2
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- composer install
|
- cd api
|
||||||
|
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
|
- php composer-setup.php
|
||||||
|
- php -r "unlink('composer-setup.php');"
|
||||||
|
- php composer.phar update
|
||||||
|
- php composer.phar install
|
||||||
- cd Tests
|
- cd Tests
|
||||||
- phpunit
|
- phpunit
|
||||||
|
|
||||||
deploy:
|
package:
|
||||||
|
image: tetraweb/php
|
||||||
when: manual
|
when: manual
|
||||||
stage: deploy
|
stage: package
|
||||||
script:
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install zip unzip
|
||||||
|
- cd api
|
||||||
- composer install --no-dev
|
- composer install --no-dev
|
||||||
- cd ../ci
|
- cd ../ci
|
||||||
- bash build_zip.sh
|
- bash build_zip.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- release.zip
|
- release.zip
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of HESK - PHP Help Desk Software.
|
||||||
|
*
|
||||||
|
* (c) Copyright Klemen Stirn. All rights reserved.
|
||||||
|
* https://www.hesk.com
|
||||||
|
*
|
||||||
|
* For the full copyright and license agreement information visit
|
||||||
|
* https://www.hesk.com/eula.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_view_tickets');
|
||||||
|
hesk_checkPermission('can_reply_tickets');
|
||||||
|
|
||||||
|
/* A security check */
|
||||||
|
hesk_token_check('POST');
|
||||||
|
|
||||||
|
/* Ticket ID */
|
||||||
|
$trackingID = hesk_cleanID() or die($hesklang['int_error'].': '.$hesklang['no_trackID']);
|
||||||
|
|
||||||
|
$priority = intval( hesk_POST('priority') );
|
||||||
|
if ($priority < 0 || $priority > 3)
|
||||||
|
{
|
||||||
|
hesk_process_messages($hesklang['inpr'],'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999),'NOTICE');
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
0 => '<font class="critical">'.$hesklang['critical'].'</font>',
|
||||||
|
1 => '<font class="important">'.$hesklang['high'].'</font>',
|
||||||
|
2 => '<font class="medium">'.$hesklang['medium'].'</font>',
|
||||||
|
3 => $hesklang['low']
|
||||||
|
);
|
||||||
|
|
||||||
|
$plain_options = array(
|
||||||
|
0 => 'critical',
|
||||||
|
1 => 'high',
|
||||||
|
2 => 'medium',
|
||||||
|
3 => 'low'
|
||||||
|
);
|
||||||
|
|
||||||
|
$ticketRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE `trackid` = '" . hesk_dbEscape($trackingID) . "'");
|
||||||
|
$ticket = hesk_dbFetchAssoc($ticketRs);
|
||||||
|
|
||||||
|
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `priority`='{$priority}' WHERE `trackid`='".hesk_dbEscape($trackingID)."'");
|
||||||
|
|
||||||
|
mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_priority', hesk_date(), array(
|
||||||
|
0 => $_SESSION['name'].' ('.$_SESSION['user'].')',
|
||||||
|
1 => $plain_options[$priority]
|
||||||
|
));
|
||||||
|
|
||||||
|
if (hesk_dbAffectedRows() != 1)
|
||||||
|
{
|
||||||
|
hesk_process_messages($hesklang['inpr'],'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999),'NOTICE');
|
||||||
|
}
|
||||||
|
|
||||||
|
hesk_process_messages(sprintf($hesklang['chpri2'],$options[$priority]),'admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999),'SUCCESS');
|
||||||
|
?>
|
@ -1,142 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// Responsible for loading in all necessary classes. AKA a poor man's DI solution.
|
|
||||||
use BusinessLogic\Attachments\AttachmentHandler;
|
|
||||||
use BusinessLogic\Attachments\AttachmentRetriever;
|
|
||||||
use BusinessLogic\Categories\CategoryRetriever;
|
|
||||||
use BusinessLogic\Emails\BasicEmailSender;
|
|
||||||
use BusinessLogic\Emails\EmailSenderHelper;
|
|
||||||
use BusinessLogic\Emails\EmailTemplateParser;
|
|
||||||
use BusinessLogic\Emails\EmailTemplateRetriever;
|
|
||||||
use BusinessLogic\Emails\MailgunEmailSender;
|
|
||||||
use BusinessLogic\Navigation\CustomNavElementHandler;
|
|
||||||
use BusinessLogic\Security\BanRetriever;
|
|
||||||
use BusinessLogic\Security\UserContextBuilder;
|
|
||||||
use BusinessLogic\Security\UserToTicketChecker;
|
|
||||||
use BusinessLogic\Settings\ApiChecker;
|
|
||||||
use BusinessLogic\Settings\SettingsRetriever;
|
|
||||||
use BusinessLogic\Statuses\StatusRetriever;
|
|
||||||
use BusinessLogic\Tickets\Autoassigner;
|
|
||||||
use BusinessLogic\Tickets\TicketDeleter;
|
|
||||||
use BusinessLogic\Tickets\TicketEditor;
|
|
||||||
use BusinessLogic\Tickets\TicketRetriever;
|
|
||||||
use BusinessLogic\Tickets\TicketCreator;
|
|
||||||
use BusinessLogic\Tickets\NewTicketValidator;
|
|
||||||
use BusinessLogic\Tickets\TicketValidators;
|
|
||||||
use BusinessLogic\Tickets\TrackingIdGenerator;
|
|
||||||
use BusinessLogic\Tickets\VerifiedEmailChecker;
|
|
||||||
use DataAccess\Attachments\AttachmentGateway;
|
|
||||||
use DataAccess\Categories\CategoryGateway;
|
|
||||||
use DataAccess\Files\FileDeleter;
|
|
||||||
use DataAccess\Files\FileReader;
|
|
||||||
use DataAccess\Files\FileWriter;
|
|
||||||
use DataAccess\Logging\LoggingGateway;
|
|
||||||
use DataAccess\Navigation\CustomNavElementGateway;
|
|
||||||
use DataAccess\Security\BanGateway;
|
|
||||||
use DataAccess\Security\UserGateway;
|
|
||||||
use DataAccess\Settings\ModsForHeskSettingsGateway;
|
|
||||||
use DataAccess\Statuses\StatusGateway;
|
|
||||||
use DataAccess\Tickets\TicketGateway;
|
|
||||||
use DataAccess\Tickets\VerifiedEmailGateway;
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationContext {
|
|
||||||
public $get;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ApplicationContext constructor.
|
|
||||||
*/
|
|
||||||
function __construct() {
|
|
||||||
$this->get = array();
|
|
||||||
|
|
||||||
// Settings
|
|
||||||
$this->get[ModsForHeskSettingsGateway::class] = new ModsForHeskSettingsGateway();
|
|
||||||
|
|
||||||
// API Checker
|
|
||||||
$this->get[ApiChecker::class] = new ApiChecker($this->get[ModsForHeskSettingsGateway::class]);
|
|
||||||
|
|
||||||
// Custom Navigation
|
|
||||||
$this->get[CustomNavElementGateway::class] = new CustomNavElementGateway();
|
|
||||||
$this->get[CustomNavElementHandler::class] = new CustomNavElementHandler($this->get[CustomNavElementGateway::class]);
|
|
||||||
|
|
||||||
// Logging
|
|
||||||
$this->get[LoggingGateway::class] = new LoggingGateway();
|
|
||||||
|
|
||||||
// Verified Email Checker
|
|
||||||
$this->get[VerifiedEmailGateway::class] = new VerifiedEmailGateway();
|
|
||||||
$this->get[VerifiedEmailChecker::class] = new VerifiedEmailChecker($this->get[VerifiedEmailGateway::class]);
|
|
||||||
|
|
||||||
// Users
|
|
||||||
$this->get[UserGateway::class] = new UserGateway();
|
|
||||||
$this->get[UserContextBuilder::class] = new UserContextBuilder($this->get[UserGateway::class]);
|
|
||||||
|
|
||||||
// Categories
|
|
||||||
$this->get[CategoryGateway::class] = new CategoryGateway();
|
|
||||||
$this->get[CategoryRetriever::class] = new CategoryRetriever($this->get[CategoryGateway::class]);
|
|
||||||
|
|
||||||
// Bans
|
|
||||||
$this->get[BanGateway::class] = new BanGateway();
|
|
||||||
$this->get[BanRetriever::class] = new BanRetriever($this->get[BanGateway::class]);
|
|
||||||
|
|
||||||
// Statuses
|
|
||||||
$this->get[StatusGateway::class] = new StatusGateway();
|
|
||||||
|
|
||||||
// Email Sender
|
|
||||||
$this->get[EmailTemplateRetriever::class] = new EmailTemplateRetriever();
|
|
||||||
$this->get[EmailTemplateParser::class] = new EmailTemplateParser($this->get[StatusGateway::class],
|
|
||||||
$this->get[CategoryGateway::class],
|
|
||||||
$this->get[UserGateway::class],
|
|
||||||
$this->get[EmailTemplateRetriever::class]);
|
|
||||||
$this->get[BasicEmailSender::class] = new BasicEmailSender();
|
|
||||||
$this->get[MailgunEmailSender::class] = new MailgunEmailSender();
|
|
||||||
$this->get[EmailSenderHelper::class] = new EmailSenderHelper($this->get[EmailTemplateParser::class],
|
|
||||||
$this->get[BasicEmailSender::class],
|
|
||||||
$this->get[MailgunEmailSender::class]);
|
|
||||||
|
|
||||||
// Tickets
|
|
||||||
$this->get[UserToTicketChecker::class] = new UserToTicketChecker($this->get[UserGateway::class]);
|
|
||||||
$this->get[TicketGateway::class] = new TicketGateway();
|
|
||||||
$this->get[TicketRetriever::class] = new TicketRetriever($this->get[TicketGateway::class],
|
|
||||||
$this->get[UserToTicketChecker::class]);
|
|
||||||
$this->get[TicketValidators::class] = new TicketValidators($this->get[TicketGateway::class]);
|
|
||||||
$this->get[TrackingIdGenerator::class] = new TrackingIdGenerator($this->get[TicketGateway::class]);
|
|
||||||
$this->get[Autoassigner::class] = new Autoassigner($this->get[CategoryGateway::class], $this->get[UserGateway::class]);
|
|
||||||
$this->get[NewTicketValidator::class] = new NewTicketValidator($this->get[CategoryRetriever::class],
|
|
||||||
$this->get[BanRetriever::class],
|
|
||||||
$this->get[TicketValidators::class]);
|
|
||||||
$this->get[TicketCreator::class] = new TicketCreator($this->get[NewTicketValidator::class],
|
|
||||||
$this->get[TrackingIdGenerator::class],
|
|
||||||
$this->get[Autoassigner::class],
|
|
||||||
$this->get[StatusGateway::class],
|
|
||||||
$this->get[TicketGateway::class],
|
|
||||||
$this->get[VerifiedEmailChecker::class],
|
|
||||||
$this->get[EmailSenderHelper::class],
|
|
||||||
$this->get[UserGateway::class],
|
|
||||||
$this->get[ModsForHeskSettingsGateway::class]);
|
|
||||||
$this->get[FileWriter::class] = new FileWriter();
|
|
||||||
$this->get[FileReader::class] = new FileReader();
|
|
||||||
$this->get[FileDeleter::class] = new FileDeleter();
|
|
||||||
$this->get[AttachmentGateway::class] = new AttachmentGateway();
|
|
||||||
$this->get[AttachmentHandler::class] = new AttachmentHandler($this->get[TicketGateway::class],
|
|
||||||
$this->get[AttachmentGateway::class],
|
|
||||||
$this->get[FileWriter::class],
|
|
||||||
$this->get[UserToTicketChecker::class],
|
|
||||||
$this->get[FileDeleter::class]);
|
|
||||||
$this->get[AttachmentRetriever::class] = new AttachmentRetriever($this->get[AttachmentGateway::class],
|
|
||||||
$this->get[FileReader::class],
|
|
||||||
$this->get[TicketGateway::class],
|
|
||||||
$this->get[UserToTicketChecker::class]);
|
|
||||||
$this->get[TicketDeleter::class] =
|
|
||||||
new TicketDeleter($this->get[TicketGateway::class],
|
|
||||||
$this->get[UserToTicketChecker::class],
|
|
||||||
$this->get[AttachmentHandler::class]);
|
|
||||||
$this->get[TicketEditor::class] =
|
|
||||||
new TicketEditor($this->get[TicketGateway::class], $this->get[UserToTicketChecker::class]);
|
|
||||||
|
|
||||||
// Statuses
|
|
||||||
$this->get[StatusRetriever::class] = new StatusRetriever($this->get[StatusGateway::class]);
|
|
||||||
|
|
||||||
// Settings
|
|
||||||
$this->get[SettingsRetriever::class] = new SettingsRetriever($this->get[ModsForHeskSettingsGateway::class]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class BaseClass {
|
||||||
|
static function clazz() {
|
||||||
|
return get_called_class();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class BaseException extends Exception {
|
||||||
|
static function clazz() {
|
||||||
|
return get_called_class();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractEvent {
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
public $startTime;
|
||||||
|
|
||||||
|
public $title;
|
||||||
|
|
||||||
|
public $categoryId;
|
||||||
|
|
||||||
|
public $categoryName;
|
||||||
|
|
||||||
|
public $backgroundColor;
|
||||||
|
|
||||||
|
public $foregroundColor;
|
||||||
|
|
||||||
|
public $displayBorder;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
class BusinessHours {
|
||||||
|
/* @var $dayOfWeek int */
|
||||||
|
public $dayOfWeek;
|
||||||
|
|
||||||
|
/* @var $startTime string */
|
||||||
|
public $startTime;
|
||||||
|
|
||||||
|
/* @var $endTime string */
|
||||||
|
public $endTime;
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
use BusinessLogic\Tickets\AuditTrail;
|
||||||
|
|
||||||
|
class CalendarEvent extends AbstractEvent {
|
||||||
|
public $type = 'CALENDAR';
|
||||||
|
|
||||||
|
public $endTime;
|
||||||
|
|
||||||
|
/* @var $allDay bool */
|
||||||
|
public $allDay;
|
||||||
|
|
||||||
|
public $location;
|
||||||
|
|
||||||
|
public $comments;
|
||||||
|
|
||||||
|
public $reminderValue;
|
||||||
|
|
||||||
|
public $reminderUnits;
|
||||||
|
|
||||||
|
/* @var $auditTrail AuditTrail[] */
|
||||||
|
public $auditTrail = array();
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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,
|
||||||
|
AuditTrailGateway $auditTrailGateway) {
|
||||||
|
$this->calendarGateway = $calendarGateway;
|
||||||
|
$this->auditTrailGateway = $auditTrailGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEventsForStaff($searchEventsFilter, $heskSettings) {
|
||||||
|
return $this->calendarGateway->getEventsForStaff($searchEventsFilter, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $calendarEvent CalendarEvent
|
||||||
|
* @param $userContext UserContext
|
||||||
|
* @param $heskSettings array
|
||||||
|
* @return CalendarEvent
|
||||||
|
* @throws \Exception If more than one event is returned for the given ID
|
||||||
|
*/
|
||||||
|
public function 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->eventId = $calendarEvent->id;
|
||||||
|
$eventFilter->reminderUserId = $userContext->id;
|
||||||
|
|
||||||
|
$events = $this->calendarGateway->getEventsForStaff($eventFilter, $heskSettings);
|
||||||
|
|
||||||
|
if (count($events) !== 1) {
|
||||||
|
throw new \Exception("Expected exactly 1 event, found: " . count($events));
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = $events[0];
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
$eventFilter = new SearchEventsFilter();
|
||||||
|
$eventFilter->eventId = $calendarEvent->id;
|
||||||
|
$eventFilter->reminderUserId = $userContext->id;
|
||||||
|
|
||||||
|
$events = $this->calendarGateway->getEventsForStaff($eventFilter, $heskSettings);
|
||||||
|
|
||||||
|
if (count($events) !== 1) {
|
||||||
|
throw new \Exception("Expected exactly 1 event, found: " . count($events));
|
||||||
|
}
|
||||||
|
|
||||||
|
$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) {
|
||||||
|
$this->calendarGateway->deleteEvent($id, $userContext, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBusinessHours($heskSettings) {
|
||||||
|
return $this->calendarGateway->getBusinessHours($heskSettings);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
class ReminderUnit {
|
||||||
|
const MINUTE = 0;
|
||||||
|
const HOUR = 1;
|
||||||
|
const DAY = 2;
|
||||||
|
const WEEK = 3;
|
||||||
|
|
||||||
|
static function getByValue($value) {
|
||||||
|
switch ($value) {
|
||||||
|
case 0:
|
||||||
|
return 'MINUTE';
|
||||||
|
case 1:
|
||||||
|
return 'HOUR';
|
||||||
|
case 2:
|
||||||
|
return 'DAY';
|
||||||
|
case 3:
|
||||||
|
return 'WEEK';
|
||||||
|
default:
|
||||||
|
return 'UNKNOWN';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function getByName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case 'MINUTE':
|
||||||
|
return self::MINUTE;
|
||||||
|
case 'HOUR':
|
||||||
|
return self::HOUR;
|
||||||
|
case 'DAY':
|
||||||
|
return self::DAY;
|
||||||
|
case 'WEEK':
|
||||||
|
return self::WEEK;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
class SearchEventsFilter {
|
||||||
|
/* @var $startTime int|null */
|
||||||
|
public $startTime;
|
||||||
|
|
||||||
|
/* @var $endTime int|null */
|
||||||
|
public $endTime;
|
||||||
|
|
||||||
|
/* @var $id int|null */
|
||||||
|
public $eventId;
|
||||||
|
|
||||||
|
/* @var $categories int[]|null */
|
||||||
|
public $categories;
|
||||||
|
|
||||||
|
/* @var $reminderUserId int|null */
|
||||||
|
public $reminderUserId;
|
||||||
|
|
||||||
|
/* @var $includeTickets bool */
|
||||||
|
public $includeTickets;
|
||||||
|
|
||||||
|
/* @var $includeUnassignedTickets bool */
|
||||||
|
public $includeUnassignedTickets;
|
||||||
|
|
||||||
|
/* @var $includeTicketsAssignedToOthers bool */
|
||||||
|
public $includeTicketsAssignedToOthers;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
class TicketEvent extends AbstractEvent {
|
||||||
|
public $type = 'TICKET';
|
||||||
|
|
||||||
|
public $trackingId;
|
||||||
|
|
||||||
|
public $subject;
|
||||||
|
|
||||||
|
public $url;
|
||||||
|
|
||||||
|
public $owner;
|
||||||
|
|
||||||
|
public $priority;
|
||||||
|
|
||||||
|
public $status;
|
||||||
|
}
|
@ -0,0 +1,203 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Categories;
|
||||||
|
|
||||||
|
|
||||||
|
use BusinessLogic\Exceptions\AccessViolationException;
|
||||||
|
use BusinessLogic\Exceptions\ValidationException;
|
||||||
|
use BusinessLogic\Navigation\Direction;
|
||||||
|
use BusinessLogic\Security\PermissionChecker;
|
||||||
|
use BusinessLogic\Security\UserPrivilege;
|
||||||
|
use BusinessLogic\ValidationModel;
|
||||||
|
use DataAccess\Categories\CategoryGateway;
|
||||||
|
use DataAccess\Settings\ModsForHeskSettingsGateway;
|
||||||
|
use DataAccess\Tickets\TicketGateway;
|
||||||
|
|
||||||
|
class CategoryHandler extends \BaseClass {
|
||||||
|
/* @var $categoryGateway CategoryGateway */
|
||||||
|
private $categoryGateway;
|
||||||
|
|
||||||
|
/* @var $ticketGateway TicketGateway */
|
||||||
|
private $ticketGateway;
|
||||||
|
|
||||||
|
/* @var $permissionChecker PermissionChecker */
|
||||||
|
private $permissionChecker;
|
||||||
|
|
||||||
|
/* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */
|
||||||
|
private $modsForHeskSettingsGateway;
|
||||||
|
|
||||||
|
function __construct(CategoryGateway $categoryGateway,
|
||||||
|
TicketGateway $ticketGateway,
|
||||||
|
PermissionChecker $permissionChecker,
|
||||||
|
ModsForHeskSettingsGateway $modsForHeskSettingsGateway) {
|
||||||
|
$this->categoryGateway = $categoryGateway;
|
||||||
|
$this->ticketGateway = $ticketGateway;
|
||||||
|
$this->permissionChecker = $permissionChecker;
|
||||||
|
$this->modsForHeskSettingsGateway = $modsForHeskSettingsGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $category Category
|
||||||
|
* @param $userContext
|
||||||
|
* @param $heskSettings array
|
||||||
|
* @return Category The newly created category with ID
|
||||||
|
* @throws ValidationException When validation fails
|
||||||
|
* @throws \Exception When the newly created category was not retrieved
|
||||||
|
*/
|
||||||
|
//TODO Test
|
||||||
|
function createCategory($category, $userContext, $heskSettings) {
|
||||||
|
$modsForHeskSettings = $this->modsForHeskSettingsGateway->getAllSettings($heskSettings);
|
||||||
|
|
||||||
|
$validationModel = $this->validate($category, $userContext);
|
||||||
|
|
||||||
|
if (count($validationModel->errorKeys) > 0) {
|
||||||
|
throw new ValidationException($validationModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->categoryGateway->createCategory($category, $heskSettings);
|
||||||
|
|
||||||
|
$allCategories = $this->categoryGateway->getAllCategories($heskSettings, $modsForHeskSettings);
|
||||||
|
|
||||||
|
foreach ($allCategories as $innerCategory) {
|
||||||
|
if ($innerCategory->id === $id) {
|
||||||
|
return $innerCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \BaseException("Newly created category {$id} lost! :O");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $category Category
|
||||||
|
* @param $userContext
|
||||||
|
* @param $creating bool
|
||||||
|
* @return ValidationModel
|
||||||
|
* @throws AccessViolationException
|
||||||
|
*/
|
||||||
|
//TODO Test
|
||||||
|
private function validate($category, $userContext, $creating = true) {
|
||||||
|
$validationModel = new ValidationModel();
|
||||||
|
|
||||||
|
if (!$this->permissionChecker->doesUserHavePermission($userContext, UserPrivilege::CAN_MANAGE_CATEGORIES)) {
|
||||||
|
throw new AccessViolationException('User cannot manage categories!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$creating && $category->id < 1) {
|
||||||
|
$validationModel->errorKeys[] = 'ID_MISSING';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->backgroundColor === null || trim($category->backgroundColor) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'BACKGROUND_COLOR_MISSING';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->foregroundColor === null || trim($category->foregroundColor) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'FOREGROUND_COLOR_MISSING';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->name === null || trim($category->name) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'NAME_MISSING';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->priority === null || intval($category->priority) < 0 || intval($category->priority) > 3) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_PRIORITY';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->autoAssign === null || !is_bool($category->autoAssign)) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_AUTOASSIGN';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->displayBorder === null || !is_bool($category->displayBorder)) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_DISPLAY_BORDER';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category->type === null || (intval($category->type) !== 0 && intval($category->type) !== 1)) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_TYPE';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $validationModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $category Category
|
||||||
|
* @param $userContext
|
||||||
|
* @param $heskSettings array
|
||||||
|
* @return Category
|
||||||
|
* @throws ValidationException
|
||||||
|
* @throws \Exception When the category is missing
|
||||||
|
*/
|
||||||
|
function editCategory($category, $userContext, $heskSettings) {
|
||||||
|
$modsForHeskSettings = $this->modsForHeskSettingsGateway->getAllSettings($heskSettings);
|
||||||
|
|
||||||
|
$validationModel = $this->validate($category, $userContext, false);
|
||||||
|
|
||||||
|
if (count($validationModel->errorKeys) > 0) {
|
||||||
|
throw new ValidationException($validationModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->categoryGateway->updateCategory($category, $heskSettings);
|
||||||
|
$this->categoryGateway->resortAllCategories($heskSettings);
|
||||||
|
|
||||||
|
$allCategories = $this->categoryGateway->getAllCategories($heskSettings, $modsForHeskSettings);
|
||||||
|
|
||||||
|
foreach ($allCategories as $innerCategory) {
|
||||||
|
if ($innerCategory->id === $category->id) {
|
||||||
|
return $innerCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \BaseException("Category {$category->id} vanished! :O");
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCategory($id, $userContext, $heskSettings) {
|
||||||
|
if (!$this->permissionChecker->doesUserHavePermission($userContext, UserPrivilege::CAN_MANAGE_CATEGORIES)) {
|
||||||
|
throw new AccessViolationException('User cannot manage categories!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id === 1) {
|
||||||
|
throw new \BaseException("Category 1 cannot be deleted!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ticketGateway->moveTicketsToDefaultCategory($id, $heskSettings);
|
||||||
|
$this->categoryGateway->deleteCategory($id, $heskSettings);
|
||||||
|
$this->categoryGateway->resortAllCategories($heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortCategory($id, $direction, $heskSettings) {
|
||||||
|
$modsForHeskSettings = $this->modsForHeskSettingsGateway->getAllSettings($heskSettings);
|
||||||
|
|
||||||
|
$categories = $this->categoryGateway->getAllCategories($heskSettings, $modsForHeskSettings);
|
||||||
|
$category = null;
|
||||||
|
foreach ($categories as $innerCategory) {
|
||||||
|
if ($innerCategory->id === intval($id)) {
|
||||||
|
$category = $innerCategory;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category === null) {
|
||||||
|
throw new \BaseException("Could not find category with ID {$id}!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($direction === Direction::UP) {
|
||||||
|
$category->catOrder -= 15;
|
||||||
|
} else {
|
||||||
|
$category->catOrder += 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->categoryGateway->updateCategory($category, $heskSettings);
|
||||||
|
$this->categoryGateway->resortAllCategories($heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPublicCategories($heskSettings) {
|
||||||
|
$allCategories = $this->categoryGateway->getAllCategories($heskSettings, $this->modsForHeskSettingsGateway->getAllSettings($heskSettings));
|
||||||
|
|
||||||
|
$publicCategories = array();
|
||||||
|
foreach ($allCategories as $category) {
|
||||||
|
if ($category->type === 0) {
|
||||||
|
$publicCategories[] = $category;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $publicCategories;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic;
|
||||||
|
|
||||||
|
|
||||||
|
class DateTimeHelpers {
|
||||||
|
static function heskDate($heskSettings, $dt = '', $isStr = true, $return_str = true) {
|
||||||
|
|
||||||
|
if (!$dt) {
|
||||||
|
$dt = time();
|
||||||
|
} elseif ($isStr) {
|
||||||
|
$dt = strtotime($dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return formatted date
|
||||||
|
return $return_str ? date($heskSettings['timeformat'], $dt) : $dt;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Security;
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionChecker extends \BaseClass {
|
||||||
|
/**
|
||||||
|
* @param $userContext UserContext
|
||||||
|
* @param $permission string
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function doesUserHavePermission($userContext, $permission) {
|
||||||
|
if ($userContext->admin) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($permission, $userContext->permissions)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class GetServiceMessagesFilter {
|
||||||
|
/* @var $includeStaffServiceMessages bool */
|
||||||
|
public $includeStaffServiceMessages = true;
|
||||||
|
|
||||||
|
/* @var $includeDrafts bool */
|
||||||
|
public $includeDrafts = true;
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceMessage extends \BaseClass {
|
||||||
|
/* @var $id int */
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/* @var $dateCreated string */
|
||||||
|
public $dateCreated;
|
||||||
|
|
||||||
|
/* @var $createdBy int */
|
||||||
|
public $createdBy;
|
||||||
|
|
||||||
|
/* @var $title string */
|
||||||
|
public $title;
|
||||||
|
|
||||||
|
/* @var $message string */
|
||||||
|
public $message;
|
||||||
|
|
||||||
|
/* @var $style string */
|
||||||
|
public $style;
|
||||||
|
|
||||||
|
/* @var $published bool */
|
||||||
|
public $published;
|
||||||
|
|
||||||
|
/* @var $order int */
|
||||||
|
public $order;
|
||||||
|
|
||||||
|
/* @var $icon string */
|
||||||
|
public $icon;
|
||||||
|
|
||||||
|
/* @var $locations string[] */
|
||||||
|
public $locations;
|
||||||
|
|
||||||
|
/* @var $language string */
|
||||||
|
public $language;
|
||||||
|
}
|
@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO Test
|
||||||
|
use BusinessLogic\Exceptions\ValidationException;
|
||||||
|
use BusinessLogic\Navigation\Direction;
|
||||||
|
use BusinessLogic\ValidationModel;
|
||||||
|
use DataAccess\ServiceMessages\ServiceMessagesGateway;
|
||||||
|
|
||||||
|
class ServiceMessageHandler extends \BaseClass {
|
||||||
|
/* @var $serviceMessageGateway ServiceMessagesGateway */
|
||||||
|
private $serviceMessageGateway;
|
||||||
|
|
||||||
|
function __construct(ServiceMessagesGateway $serviceMessagesGateway) {
|
||||||
|
$this->serviceMessageGateway = $serviceMessagesGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createServiceMessage($serviceMessage, $heskSettings) {
|
||||||
|
$this->validate($serviceMessage, $heskSettings);
|
||||||
|
|
||||||
|
if ($serviceMessage->icon === null) {
|
||||||
|
switch ($serviceMessage->style) {
|
||||||
|
case ServiceMessageStyle::NONE:
|
||||||
|
$serviceMessage->icon = '';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::INFO:
|
||||||
|
$serviceMessage->icon = 'fa fa-comment';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::NOTICE:
|
||||||
|
$serviceMessage->icon = 'fa fa-exclamation-triangle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::ERROR:
|
||||||
|
$serviceMessage->icon = 'fa fa-times-circle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::SUCCESS:
|
||||||
|
$serviceMessage->icon = 'fa fa-check-circle';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->serviceMessageGateway->createServiceMessage($serviceMessage, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getServiceMessages($heskSettings, $searchFilter) {
|
||||||
|
return $this->serviceMessageGateway->getServiceMessages($heskSettings, $searchFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
function editServiceMessage($serviceMessage, $heskSettings) {
|
||||||
|
$this->validate($serviceMessage, $heskSettings, false);
|
||||||
|
|
||||||
|
if ($serviceMessage->icon === null) {
|
||||||
|
switch ($serviceMessage->style) {
|
||||||
|
case ServiceMessageStyle::NONE:
|
||||||
|
$serviceMessage->icon = '';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::INFO:
|
||||||
|
$serviceMessage->icon = 'fa fa-comment';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::NOTICE:
|
||||||
|
$serviceMessage->icon = 'fa fa-exclamation-triangle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::ERROR:
|
||||||
|
$serviceMessage->icon = 'fa fa-times-circle';
|
||||||
|
break;
|
||||||
|
case ServiceMessageStyle::SUCCESS:
|
||||||
|
$serviceMessage->icon = 'fa fa-check-circle';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->serviceMessageGateway->updateServiceMessage($serviceMessage, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteServiceMessage($id, $heskSettings) {
|
||||||
|
$this->serviceMessageGateway->deleteServiceMessage($id, $heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortServiceMessage($id, $direction, $heskSettings) {
|
||||||
|
$serviceMessages = $this->serviceMessageGateway->getServiceMessages($heskSettings, new GetServiceMessagesFilter());
|
||||||
|
$serviceMessage = null;
|
||||||
|
foreach ($serviceMessages as $innerServiceMessage) {
|
||||||
|
if (intval($innerServiceMessage->id) === intval($id)) {
|
||||||
|
$serviceMessage = $innerServiceMessage;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($serviceMessage === null) {
|
||||||
|
throw new \BaseException("Could not find service message with ID {$id}!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($direction === Direction::UP) {
|
||||||
|
$serviceMessage->order -= 15;
|
||||||
|
} else {
|
||||||
|
$serviceMessage->order += 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->serviceMessageGateway->updateServiceMessage($serviceMessage, $heskSettings);
|
||||||
|
$this->serviceMessageGateway->resortAllServiceMessages($heskSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $serviceMessage ServiceMessage
|
||||||
|
* @param bool $isNew
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
private function validate($serviceMessage, $heskSettings, $isNew = true) {
|
||||||
|
$validationModel = new ValidationModel();
|
||||||
|
if ($isNew && $serviceMessage->createdBy < 1) {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_CREATOR';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($serviceMessage->message === null || trim($serviceMessage->message) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_MESSAGE';
|
||||||
|
} else {
|
||||||
|
$htmlPurifier = new \HeskHTMLPurifier($heskSettings['cache_dir']);
|
||||||
|
$serviceMessage->message = $htmlPurifier->heskPurify($serviceMessage->message);
|
||||||
|
}
|
||||||
|
if ($serviceMessage->language === null || trim($serviceMessage->language) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_LANGUAGE';
|
||||||
|
}
|
||||||
|
|
||||||
|
$languageFound = false;
|
||||||
|
foreach ($heskSettings['languages'] as $key => $value) {
|
||||||
|
if ($value['folder'] === $serviceMessage->language || $serviceMessage->language === 'ALL') {
|
||||||
|
$languageFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$languageFound && !in_array('MISSING_LANGUAGE', $validationModel->errorKeys)) {
|
||||||
|
$validationModel->errorKeys[] = 'LANGUAGE_NOT_INSTALLED';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($serviceMessage->title === null || trim($serviceMessage->title) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_TITLE';
|
||||||
|
}
|
||||||
|
if ($serviceMessage->style === null || trim($serviceMessage->style) === '') {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_STYLE';
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ServiceMessageStyle::getIdForStyle($serviceMessage->style);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_STYLE';
|
||||||
|
}
|
||||||
|
if ($serviceMessage->locations === null || count($serviceMessage->locations) === 0) {
|
||||||
|
$validationModel->errorKeys[] = 'MISSING_LOCATIONS';
|
||||||
|
} else {
|
||||||
|
$locations = ServiceMessageLocation::getAll();
|
||||||
|
foreach ($serviceMessage->locations as $location) {
|
||||||
|
if (!in_array($location, $locations)) {
|
||||||
|
$validationModel->errorKeys[] = 'INVALID_LOCATION';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($validationModel->errorKeys) > 0) {
|
||||||
|
// Validation failed
|
||||||
|
throw new ValidationException($validationModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceMessageLocation {
|
||||||
|
const CUSTOMER_HOME = 'CUSTOMER_HOME';
|
||||||
|
const CUSTOMER_KB_HOME = 'CUSTOMER_KB_HOME';
|
||||||
|
const CUSTOMER_VIEW_KB_ARTICLE = 'CUSTOMER_VIEW_KB_ARTICLE';
|
||||||
|
const CUSTOMER_SUBMIT_TICKET = 'CUSTOMER_SUBMIT_TICKET';
|
||||||
|
const CUSTOMER_VIEW_TICKET = 'CUSTOMER_VIEW_TICKET';
|
||||||
|
const STAFF_LOGIN = 'STAFF_LOGIN';
|
||||||
|
const STAFF_HOME = 'STAFF_HOME';
|
||||||
|
const STAFF_KB_HOME = 'STAFF_KB_HOME';
|
||||||
|
const STAFF_VIEW_KB_ARTICLE = 'STAFF_VIEW_KB_ARTICLE';
|
||||||
|
const STAFF_SUBMIT_TICKET = 'STAFF_SUBMIT_TICKET';
|
||||||
|
const STAFF_VIEW_TICKET = 'STAFF_VIEW_TICKET';
|
||||||
|
|
||||||
|
static function getAll() {
|
||||||
|
return array(
|
||||||
|
self::CUSTOMER_HOME,
|
||||||
|
self::CUSTOMER_KB_HOME,
|
||||||
|
self::CUSTOMER_VIEW_KB_ARTICLE,
|
||||||
|
self::CUSTOMER_SUBMIT_TICKET,
|
||||||
|
self::CUSTOMER_VIEW_TICKET,
|
||||||
|
self::STAFF_LOGIN,
|
||||||
|
self::STAFF_HOME,
|
||||||
|
self::STAFF_KB_HOME,
|
||||||
|
self::STAFF_VIEW_KB_ARTICLE,
|
||||||
|
self::STAFF_SUBMIT_TICKET,
|
||||||
|
self::STAFF_VIEW_TICKET,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\ServiceMessages;
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceMessageStyle {
|
||||||
|
const NONE = 'NONE'; // 0
|
||||||
|
const SUCCESS = 'SUCCESS'; // 1
|
||||||
|
const INFO = 'INFO'; // 2
|
||||||
|
const NOTICE = 'NOTICE'; // 3
|
||||||
|
const ERROR = 'ERROR'; // 4
|
||||||
|
|
||||||
|
static function getStyleById($id) {
|
||||||
|
$styles = array(
|
||||||
|
0 => self::NONE,
|
||||||
|
1 => self::SUCCESS,
|
||||||
|
2 => self::INFO,
|
||||||
|
3 => self::NOTICE,
|
||||||
|
4 => self::ERROR
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($styles[$id])) {
|
||||||
|
throw new \Exception("Style {$id} is not a valid service message style.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $styles[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
static function getIdForStyle($style) {
|
||||||
|
$styles = array(
|
||||||
|
self::NONE => 0,
|
||||||
|
self::SUCCESS => 1,
|
||||||
|
self::INFO => 2,
|
||||||
|
self::NOTICE => 3,
|
||||||
|
self::ERROR => 4
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($styles[$style])) {
|
||||||
|
throw new \Exception("Style {$style} is not a valid service message style.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $styles[$style];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Tickets;
|
||||||
|
|
||||||
|
|
||||||
|
class AuditTrail extends \BaseClass {
|
||||||
|
/* @var $id int */
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/* @var $entityId int */
|
||||||
|
public $entityId;
|
||||||
|
|
||||||
|
/* @var $entityType string */
|
||||||
|
public $entityType;
|
||||||
|
|
||||||
|
/* @var $languageKey string */
|
||||||
|
public $languageKey;
|
||||||
|
|
||||||
|
/* @var $date string */
|
||||||
|
public $date;
|
||||||
|
|
||||||
|
/* @var $replacementValues string[] */
|
||||||
|
public $replacementValues;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Tickets;
|
||||||
|
|
||||||
|
|
||||||
|
class AuditTrailEntityType extends \BaseClass {
|
||||||
|
const TICKET = 'TICKET';
|
||||||
|
const CALENDAR_EVENT = 'CALENDAR_EVENT';
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Tickets;
|
||||||
|
|
||||||
|
|
||||||
|
class AuditTrailEvent extends \BaseClass {
|
||||||
|
const DUE_DATE_REMOVED = 'audit_due_date_removed';
|
||||||
|
const DUE_DATE_CHANGED = 'audit_due_date_changed';
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
namespace BusinessLogic\Tickets\CustomFields;
|
||||||
|
|
||||||
|
|
||||||
|
class CustomField {
|
||||||
|
/* @var $id int */
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/* @var $name string */
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
/* @var $type string */
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
/* @var $properties array */
|
||||||
|
public $properties;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue