Merge branch '3-3-0' into 'master'
Mods for HESK 3.3.0 Update Closes #599 See merge request mike-koch/Mods-for-HESK!95master
commit
e56ef4d608
@ -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,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,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;
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Controllers\Calendar;
|
||||
|
||||
|
||||
use BusinessLogic\Calendar\CalendarEvent;
|
||||
use BusinessLogic\Calendar\CalendarHandler;
|
||||
use BusinessLogic\Calendar\RecurringRule;
|
||||
use BusinessLogic\Calendar\ReminderUnit;
|
||||
use BusinessLogic\Calendar\SearchEventsFilter;
|
||||
use BusinessLogic\Categories\CategoryHandler;
|
||||
use BusinessLogic\Exceptions\ValidationException;
|
||||
use BusinessLogic\Helpers;
|
||||
use BusinessLogic\Security\UserContext;
|
||||
use BusinessLogic\Security\UserPrivilege;
|
||||
use BusinessLogic\ValidationModel;
|
||||
use Controllers\JsonRetriever;
|
||||
use DataAccess\Settings\ModsForHeskSettingsGateway;
|
||||
use RRule\RRule;
|
||||
use RRule\RSet;
|
||||
|
||||
class CalendarController extends \BaseClass {
|
||||
function get() {
|
||||
/* @var $userContext UserContext */
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
if (!isset($_GET['start']) || !isset($_GET['end'])) {
|
||||
$validationModel = new ValidationModel();
|
||||
$validationModel->errorKeys = array('START_AND_END_TIMES_REQUIRED');
|
||||
throw new ValidationException($validationModel);
|
||||
}
|
||||
|
||||
$startTime = $_GET['start'];
|
||||
$endTime = $_GET['end'];
|
||||
|
||||
/* @var $calendarHandler CalendarHandler */
|
||||
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||
|
||||
$searchEventsFilter = new SearchEventsFilter();
|
||||
$searchEventsFilter->startTime = $startTime;
|
||||
$searchEventsFilter->endTime = $endTime;
|
||||
$searchEventsFilter->reminderUserId = $userContext->id;
|
||||
|
||||
if ($userContext->isAnonymousUser()) {
|
||||
$searchEventsFilter->includeTicketsAssignedToOthers = false;
|
||||
$searchEventsFilter->includeUnassignedTickets = false;
|
||||
$searchEventsFilter->includeTickets = false;
|
||||
|
||||
/* @var $categoryHandler CategoryHandler */
|
||||
$categoryHandler = $applicationContext->get(CategoryHandler::clazz());
|
||||
|
||||
$publicCategories = $categoryHandler->getPublicCategories($hesk_settings);
|
||||
$ids = array();
|
||||
foreach ($publicCategories as $category) {
|
||||
$ids[] = $category->id;
|
||||
}
|
||||
$searchEventsFilter->categories = $ids;
|
||||
} else {
|
||||
$searchEventsFilter->includeTicketsAssignedToOthers = in_array(UserPrivilege::CAN_VIEW_ASSIGNED_TO_OTHER, $userContext->permissions);
|
||||
$searchEventsFilter->includeUnassignedTickets = in_array(UserPrivilege::CAN_VIEW_UNASSIGNED, $userContext->permissions);
|
||||
$searchEventsFilter->includeTickets = true;
|
||||
$searchEventsFilter->categories = $userContext->admin ? null : $userContext->categories;
|
||||
}
|
||||
|
||||
$events = $calendarHandler->getEventsForStaff($searchEventsFilter, $hesk_settings);
|
||||
|
||||
return output($events);
|
||||
}
|
||||
|
||||
function post() {
|
||||
/* @var $userContext UserContext */
|
||||
/* @var $hesk_settings array */
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
$json = JsonRetriever::getJsonData();
|
||||
|
||||
$event = $this->transformJson($json);
|
||||
|
||||
/* @var $calendarHandler CalendarHandler */
|
||||
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||
|
||||
return output($calendarHandler->createEvent($event, $userContext, $hesk_settings), 201);
|
||||
}
|
||||
|
||||
function put($id) {
|
||||
/* @var $userContext UserContext */
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
$json = JsonRetriever::getJsonData();
|
||||
|
||||
$event = $this->transformJson($json, $id);
|
||||
|
||||
/* @var $calendarHandler CalendarHandler */
|
||||
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||
|
||||
return output($calendarHandler->updateEvent($event, $userContext, $hesk_settings));
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
/* @var $userContext UserContext */
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
/* @var $calendarHandler CalendarHandler */
|
||||
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||
|
||||
$calendarHandler->deleteEvent($id, $userContext, $hesk_settings);
|
||||
|
||||
return http_response_code(204);
|
||||
}
|
||||
|
||||
private function transformJson($json, $id = null) {
|
||||
$event = new CalendarEvent();
|
||||
|
||||
$event->id = $id;
|
||||
$event->startTime = date('Y-m-d H:i:s', strtotime(Helpers::safeArrayGet($json, 'startTime')));
|
||||
$event->endTime = date('Y-m-d H:i:s', strtotime(Helpers::safeArrayGet($json, 'endTime')));
|
||||
$event->allDay = Helpers::safeArrayGet($json, 'allDay');
|
||||
$event->title = Helpers::safeArrayGet($json, 'title');
|
||||
$event->location = Helpers::safeArrayGet($json, 'location');
|
||||
$event->comments = Helpers::safeArrayGet($json, 'comments');
|
||||
$event->categoryId = Helpers::safeArrayGet($json, 'categoryId');
|
||||
$event->reminderValue = Helpers::safeArrayGet($json, 'reminderValue');
|
||||
$event->reminderUnits = ReminderUnit::getByName(Helpers::safeArrayGet($json, 'reminderUnits'));
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
static function getBusinessHours() {
|
||||
global $applicationContext, $hesk_settings;
|
||||
|
||||
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||
|
||||
return output($calendarHandler->getBusinessHours($hesk_settings));
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Controllers\ServiceMessages;
|
||||
|
||||
use BusinessLogic\Exceptions\ApiFriendlyException;
|
||||
use BusinessLogic\Helpers;
|
||||
use BusinessLogic\Security\UserContext;
|
||||
use BusinessLogic\Security\UserPrivilege;
|
||||
use BusinessLogic\ServiceMessages\GetServiceMessagesFilter;
|
||||
use BusinessLogic\ServiceMessages\ServiceMessage;
|
||||
use BusinessLogic\ServiceMessages\ServiceMessageHandler;
|
||||
use Controllers\ControllerWithSecurity;
|
||||
use Controllers\JsonRetriever;
|
||||
|
||||
class ServiceMessagesController extends \BaseClass {
|
||||
/**
|
||||
* @param $userContext UserContext
|
||||
* @throws ApiFriendlyException
|
||||
*/
|
||||
function checkSecurity($userContext) {
|
||||
if (!$userContext->admin && !in_array(UserPrivilege::CAN_MANAGE_SERVICE_MESSAGES, $userContext->permissions)) {
|
||||
throw new ApiFriendlyException("User does not have permission to access the following URI: " . $_SERVER['REQUEST_URI'], "Access Forbidden", 403);
|
||||
}
|
||||
}
|
||||
|
||||
static function staticCheckSecurity($userContext) {
|
||||
if (!$userContext->admin && !in_array(UserPrivilege::CAN_MANAGE_SERVICE_MESSAGES, $userContext->permissions)) {
|
||||
throw new ApiFriendlyException("User does not have permission to access the following URI: " . $_SERVER['REQUEST_URI'], "Access Forbidden", 403);
|
||||
}
|
||||
}
|
||||
|
||||
function get() {
|
||||
/* @var $userContext UserContext */
|
||||
/* @var $hesk_settings array */
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
$searchFilter = new GetServiceMessagesFilter();
|
||||
if ($userContext->isAnonymousUser()) {
|
||||
$searchFilter->includeDrafts = false;
|
||||
$searchFilter->includeStaffServiceMessages = false;
|
||||
} elseif (!$userContext->admin && !in_array(UserPrivilege::CAN_MANAGE_SERVICE_MESSAGES, $userContext->permissions)) {
|
||||
$searchFilter->includeDrafts = false;
|
||||
}
|
||||
|
||||
/* @var $handler ServiceMessageHandler */
|
||||
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||
|
||||
return output($handler->getServiceMessages($hesk_settings, $searchFilter));
|
||||
}
|
||||
|
||||
function post() {
|
||||
global $applicationContext, $userContext, $hesk_settings;
|
||||
|
||||
$this->checkSecurity($userContext);
|
||||
|
||||
/* @var $handler ServiceMessageHandler */
|
||||
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||
|
||||
$data = JsonRetriever::getJsonData();
|
||||
$element = $handler->createServiceMessage($this->buildElementModel($data, $userContext), $hesk_settings);
|
||||
|
||||
return output($element, 201);
|
||||
}
|
||||
|
||||
function put($id) {
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
$this->checkSecurity($userContext);
|
||||
|
||||
/* @var $handler ServiceMessageHandler */
|
||||
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||
|
||||
$data = JsonRetriever::getJsonData();
|
||||
$serviceMessage = $this->buildElementModel($data, null, false);
|
||||
$serviceMessage->id = $id;
|
||||
$element = $handler->editServiceMessage($serviceMessage, $hesk_settings);
|
||||
|
||||
return output($element);
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
$this->checkSecurity($userContext);
|
||||
|
||||
/* @var $handler ServiceMessageHandler */
|
||||
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||
|
||||
$handler->deleteServiceMessage($id, $hesk_settings);
|
||||
|
||||
return http_response_code(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data array
|
||||
* @param $userContext UserContext
|
||||
* @return ServiceMessage
|
||||
*/
|
||||
private function buildElementModel($data, $userContext, $creating = true) {
|
||||
$serviceMessage = new ServiceMessage();
|
||||
|
||||
if (!$creating) {
|
||||
$serviceMessage->order = Helpers::safeArrayGet($data, 'order');
|
||||
}
|
||||
|
||||
if ($creating) {
|
||||
$serviceMessage->createdBy = $userContext->id;
|
||||
}
|
||||
|
||||
$serviceMessage->title = Helpers::safeArrayGet($data, 'title');
|
||||
$serviceMessage->icon = Helpers::safeArrayGet($data, 'icon');
|
||||
$serviceMessage->message = Helpers::safeArrayGet($data, 'message');
|
||||
$serviceMessage->published = Helpers::safeArrayGet($data, 'published');
|
||||
$serviceMessage->style = Helpers::safeArrayGet($data, 'style');
|
||||
$serviceMessage->language = Helpers::safeArrayGet($data, 'language');
|
||||
|
||||
$jsonLocations = Helpers::safeArrayGet($data, 'locations');
|
||||
|
||||
if ($jsonLocations !== null && !empty($jsonLocations)) {
|
||||
foreach ($jsonLocations as $key => $value) {
|
||||
$serviceMessage->locations[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $serviceMessage;
|
||||
}
|
||||
|
||||
static function sort($id, $direction) {
|
||||
/* @var $userContext UserContext */
|
||||
global $applicationContext, $hesk_settings, $userContext;
|
||||
|
||||
self::staticCheckSecurity($userContext);
|
||||
|
||||
/* @var $handler ServiceMessageHandler */
|
||||
$handler = $applicationContext->get(ServiceMessageHandler::clazz());
|
||||
|
||||
$handler->sortServiceMessage(intval($id), $direction, $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
namespace DataAccess\Calendar;
|
||||
|
||||
|
||||
use BusinessLogic\Calendar\AbstractEvent;
|
||||
use BusinessLogic\Calendar\BusinessHours;
|
||||
use BusinessLogic\Calendar\CalendarEvent;
|
||||
use BusinessLogic\Calendar\ReminderUnit;
|
||||
use BusinessLogic\Calendar\SearchEventsFilter;
|
||||
use BusinessLogic\Calendar\TicketEvent;
|
||||
use BusinessLogic\Helpers;
|
||||
use BusinessLogic\Security\UserContext;
|
||||
use BusinessLogic\Tickets\AuditTrail;
|
||||
use BusinessLogic\Tickets\AuditTrailEntityType;
|
||||
use Core\Constants\Priority;
|
||||
use DataAccess\CommonDao;
|
||||
|
||||
class CalendarGateway extends CommonDao {
|
||||
/**
|
||||
* @param $searchEventsFilter SearchEventsFilter
|
||||
* @param $heskSettings array
|
||||
* @return AbstractEvent[]
|
||||
*/
|
||||
public function getEventsForStaff($searchEventsFilter, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$events = array();
|
||||
|
||||
// EVENTS
|
||||
$sql = "SELECT `events`.*, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
|
||||
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border`,
|
||||
`reminders`.`amount` AS `reminder_value`, `reminders`.`unit` AS `reminder_unit`
|
||||
FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event` AS `events`
|
||||
INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "categories` AS `categories`
|
||||
ON `events`.`category` = `categories`.`id`
|
||||
LEFT JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event_reminder` AS `reminders`
|
||||
ON `reminders`.`user_id` = " . intval($searchEventsFilter->reminderUserId) . "
|
||||
AND `reminders`.`event_id` = `events`.`id`
|
||||
WHERE 1=1";
|
||||
|
||||
if ($searchEventsFilter->startTime !== null && $searchEventsFilter->endTime !== null) {
|
||||
$startTimeSql = "CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($searchEventsFilter->startTime) . " / 1000), @@session.time_zone, '+00:00')";
|
||||
$endTimeSql = "CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($searchEventsFilter->endTime) . " / 1000), @@session.time_zone, '+00:00')";
|
||||
|
||||
|
||||
$sql .= " AND NOT (`end` < {$startTimeSql} OR `start` > {$endTimeSql})
|
||||
AND `categories`.`usage` <> 1";
|
||||
}
|
||||
|
||||
if ($searchEventsFilter->eventId !== null) {
|
||||
$sql .= " AND `events`.`id` = " . intval($searchEventsFilter->eventId);
|
||||
}
|
||||
|
||||
if (!empty($searchEventsFilter->categories)) {
|
||||
$categoriesAsString = implode(',', $searchEventsFilter->categories);
|
||||
$sql .= " AND `events`.`category` IN (" . $categoriesAsString . ")";
|
||||
}
|
||||
|
||||
$rs = hesk_dbQuery($sql);
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$event = new CalendarEvent();
|
||||
$event->id = intval($row['id']);
|
||||
$event->startTime = $row['start'];
|
||||
$event->endTime = $row['end'];
|
||||
$event->allDay = Helpers::boolval($row['all_day']);
|
||||
$event->title = $row['name'];
|
||||
$event->location = $row['location'];
|
||||
$event->comments = $row['comments'];
|
||||
$event->categoryId = intval($row['category']);
|
||||
$event->categoryName = Helpers::heskHtmlSpecialCharsDecode($row['category_name']);
|
||||
$event->backgroundColor = $row['background_color'];
|
||||
$event->foregroundColor = $row['foreground_color'];
|
||||
$event->displayBorder = Helpers::boolval($row['display_border']);
|
||||
$event->reminderValue = $row['reminder_value'] === null ? null : floatval($row['reminder_value']);
|
||||
$event->reminderUnits = $row['reminder_unit'] === null ? null : ReminderUnit::getByValue($row['reminder_unit']);
|
||||
|
||||
$auditTrailSql = "SELECT `at`.`id` AS `id`, `at`.`entity_id`, `at`.`language_key`, `at`.`date`,
|
||||
`values`.`replacement_index`, `values`.`replacement_value`
|
||||
FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "audit_trail` AS `at`
|
||||
INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "audit_trail_to_replacement_values` AS `values`
|
||||
ON `at`.`id` = `values`.`audit_trail_id`
|
||||
WHERE `entity_id` = " . intval($event->id) . "
|
||||
AND `entity_type` = '" . AuditTrailEntityType::CALENDAR_EVENT . "'";
|
||||
$auditTrailRs = hesk_dbQuery($auditTrailSql);
|
||||
/* @var $auditTrailEntry AuditTrail */
|
||||
$auditTrailEntry = null;
|
||||
while ($row = hesk_dbFetchAssoc($auditTrailRs)) {
|
||||
if ($auditTrailEntry == null || intval($auditTrailEntry->id) !== intval($row['id'])) {
|
||||
if ($auditTrailEntry !== null) {
|
||||
$event->auditTrail[] = $auditTrailEntry;
|
||||
}
|
||||
|
||||
$auditTrailEntry = new AuditTrail();
|
||||
$auditTrailEntry->id = intval($row['id']);
|
||||
$auditTrailEntry->entityId = intval($row['entity_id']);
|
||||
$auditTrailEntry->entityType = AuditTrailEntityType::CALENDAR_EVENT;
|
||||
$auditTrailEntry->languageKey = $row['language_key'];
|
||||
$auditTrailEntry->date = $row['date'];
|
||||
$auditTrailEntry->replacementValues = array();
|
||||
}
|
||||
$auditTrailEntry->replacementValues[intval($row['replacement_index'])] = $row['replacement_value'];
|
||||
}
|
||||
|
||||
if ($auditTrailEntry !== null) {
|
||||
$event->auditTrail[] = $auditTrailEntry;
|
||||
}
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
// TICKETS
|
||||
if ($searchEventsFilter->includeTickets) {
|
||||
$oldTimeSetting = $heskSettings['timeformat'];
|
||||
$heskSettings['timeformat'] = 'Y-m-d';
|
||||
$currentDate = hesk_date();
|
||||
$heskSettings['timeformat'] = $oldTimeSetting;
|
||||
|
||||
$sql = "SELECT `tickets`.`id` AS `id`, `trackid`, `subject`, `due_date`, `category`, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
|
||||
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border`,
|
||||
CASE WHEN `due_date` < '{$currentDate}' THEN 1 ELSE 0 END AS `overdue`, `owner`.`name` AS `owner_name`, `tickets`.`owner` AS `owner_id`,
|
||||
`tickets`.`priority` AS `priority`, `text_to_status_xref`.`text` AS `status_name`
|
||||
FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "tickets` AS `tickets`
|
||||
INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "categories` AS `categories`
|
||||
ON `categories`.`id` = `tickets`.`category`
|
||||
AND `categories`.`usage` <> 2
|
||||
LEFT JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "users` AS `owner`
|
||||
ON `tickets`.`owner` = `owner`.`id`
|
||||
LEFT JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "text_to_status_xref` AS `text_to_status_xref`
|
||||
ON `tickets`.`status` = `text_to_status_xref`.`status_id`
|
||||
AND `text_to_status_xref`.`language` = '" . hesk_dbEscape($heskSettings['language']) . "'
|
||||
WHERE `due_date` >= {$startTimeSql}
|
||||
AND `due_date` <= {$endTimeSql}
|
||||
AND `status` IN (SELECT `id` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "statuses` WHERE `IsClosed` = 0)
|
||||
AND (`owner` = " . $searchEventsFilter->reminderUserId;
|
||||
|
||||
if ($searchEventsFilter->includeUnassignedTickets) {
|
||||
$sql .= " OR `owner` = 0 ";
|
||||
}
|
||||
|
||||
if ($searchEventsFilter->includeTicketsAssignedToOthers) {
|
||||
$sql .= " OR `owner` NOT IN (0, " . $searchEventsFilter->reminderUserId . ") ";
|
||||
}
|
||||
|
||||
$sql .= ")";
|
||||
|
||||
if (!empty($searchEventsFilter->categories)) {
|
||||
$categoriesAsString = implode(',', $searchEventsFilter->categories);
|
||||
$sql .= " AND `tickets`.`category` IN (" . $categoriesAsString . ")";
|
||||
}
|
||||
|
||||
$rs = hesk_dbQuery($sql);
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$event = new TicketEvent();
|
||||
$event->id = intval($row['id']);
|
||||
$event->trackingId = $row['trackid'];
|
||||
$event->subject = $row['subject'];
|
||||
$event->title = $row['subject'];
|
||||
$event->startTime = $row['due_date'];
|
||||
$event->url = $heskSettings['hesk_url'] . '/' . $heskSettings['admin_dir'] . '/admin_ticket.php?track=' . $event->trackingId;
|
||||
$event->categoryId = intval($row['category']);
|
||||
$event->categoryName = Helpers::heskHtmlSpecialCharsDecode($row['category_name']);
|
||||
$event->backgroundColor = $row['background_color'];
|
||||
$event->foregroundColor = $row['foreground_color'];
|
||||
$event->displayBorder = Helpers::boolval($row['display_border']);
|
||||
$event->owner = $row['owner_name'];
|
||||
$event->priority = Priority::getByValue($row['priority']);
|
||||
$event->status = $row['status_name'];
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
}
|
||||
|
||||
$this->close();
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event CalendarEvent
|
||||
* @param $userContext UserContext
|
||||
* @param $heskSettings array
|
||||
* @return CalendarEvent
|
||||
*/
|
||||
public function createEvent($event, $userContext, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event` (`start`, `end`, `all_day`, `name`,
|
||||
`location`, `comments`, `category`) VALUES ('" . hesk_dbEscape($event->startTime) . "', '" . hesk_dbEscape($event->endTime) . "',
|
||||
'" . ($event->allDay ? 1 : 0) . "', '" . hesk_dbEscape(addslashes($event->title)) . "',
|
||||
'" . hesk_dbEscape(addslashes($event->location)) . "', '". hesk_dbEscape(addslashes($event->comments)) . "', " . intval($event->categoryId) . ")");
|
||||
|
||||
$event->id = hesk_dbInsertID();
|
||||
|
||||
if ($event->reminderValue !== null) {
|
||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event_reminder` (`user_id`, `event_id`,
|
||||
`amount`, `unit`) VALUES (" . intval($userContext->id) . ", " . intval($event->id) . ", " . intval($event->reminderValue) . ",
|
||||
" . intval($event->reminderUnits) . ")");
|
||||
}
|
||||
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event CalendarEvent
|
||||
* @param $userContext UserContext
|
||||
* @param $heskSettings array
|
||||
*/
|
||||
public function updateEvent($event, $userContext, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$sql = "UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event` SET `start` = '" . hesk_dbEscape($event->startTime)
|
||||
. "', `end` = '" . hesk_dbEscape($event->endTime) . "', `all_day` = '" . ($event->allDay ? 1 : 0) . "', `name` = '"
|
||||
. hesk_dbEscape(addslashes($event->title)) . "', `location` = '" . hesk_dbEscape(addslashes($event->location)) . "', `comments` = '"
|
||||
. hesk_dbEscape(addslashes($event->comments)) . "', `category` = " . intval($event->categoryId) . " WHERE `id` = " . intval($event->id);
|
||||
|
||||
if ($event->reminderValue !== null) {
|
||||
$delete_sql = "DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event_reminder` WHERE `event_id` = " . intval($event->id)
|
||||
. " AND `user_id` = " . intval($userContext->id);
|
||||
hesk_dbQuery($delete_sql);
|
||||
$insert_sql = "INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event_reminder` (`user_id`, `event_id`,
|
||||
`amount`, `unit`) VALUES (" . intval($userContext->id) . ", " . intval($event->id) . ", " . intval($event->reminderValue) . ",
|
||||
" . intval($event->reminderUnits) . ")";
|
||||
hesk_dbQuery($insert_sql);
|
||||
}
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @param $userContext UserContext
|
||||
* @param $heskSettings array
|
||||
*/
|
||||
public function deleteEvent($id, $userContext, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event_reminder`
|
||||
WHERE `event_id` = " . intval($id) . " AND `user_id` = " . intval($userContext->id));
|
||||
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event`
|
||||
WHERE `id` = " . intval($id));
|
||||
|
||||
$this->close();
|
||||
}
|
||||
|
||||
public function getBusinessHours($heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_calendar_business_hours`");
|
||||
$businessHours = array();
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$businessHour = new BusinessHours();
|
||||
$businessHour->dayOfWeek = intval($row['day_of_week']);
|
||||
$businessHour->startTime = $row['start_time'];
|
||||
$businessHour->endTime = $row['end_time'];
|
||||
|
||||
$businessHours[] = $businessHour;
|
||||
}
|
||||
|
||||
$this->close();
|
||||
|
||||
return $businessHours;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace DataAccess\CustomFields;
|
||||
|
||||
use BusinessLogic\Tickets\CustomFields\CustomField;
|
||||
use DataAccess\CommonDao;
|
||||
|
||||
class CustomFieldsGateway extends CommonDao {
|
||||
public function getCustomField($id, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_fields` WHERE `id` = " . intval($id));
|
||||
|
||||
if ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$customField = new CustomField();
|
||||
$customField->id = $row['id'];
|
||||
$names = json_decode($row['name'], true);
|
||||
$customField->name = (isset($names[$heskSettings['language']])) ? $names[$heskSettings['language']] : reset($names);
|
||||
$customField->type = $row['type'];
|
||||
$customField->properties = json_decode($row['value'], true);
|
||||
|
||||
return $customField;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace DataAccess\ServiceMessages;
|
||||
|
||||
|
||||
use BusinessLogic\ServiceMessages\GetServiceMessagesFilter;
|
||||
use BusinessLogic\ServiceMessages\ServiceMessage;
|
||||
use BusinessLogic\ServiceMessages\ServiceMessageLocation;
|
||||
use BusinessLogic\ServiceMessages\ServiceMessageStyle;
|
||||
use DataAccess\CommonDao;
|
||||
|
||||
class ServiceMessagesGateway extends CommonDao {
|
||||
/**
|
||||
* @param $serviceMessage ServiceMessage
|
||||
* @return ServiceMessage
|
||||
*/
|
||||
function createServiceMessage($serviceMessage, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
// Get the latest service message order
|
||||
$res = hesk_dbQuery("SELECT `order` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages` ORDER BY `order` DESC LIMIT 1");
|
||||
$row = hesk_dbFetchRow($res);
|
||||
$myOrder = intval($row[0]) + 10;
|
||||
|
||||
$style = ServiceMessageStyle::getIdForStyle($serviceMessage->style);
|
||||
$type = $serviceMessage->published ? 0 : 1;
|
||||
|
||||
// Insert service message into database
|
||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages` (`author`,`title`,`message`,`style`,`type`,`order`, `icon`, `mfh_language`) VALUES (
|
||||
'" . intval($serviceMessage->createdBy) . "',
|
||||
'" . hesk_dbEscape($serviceMessage->title) . "',
|
||||
'" . hesk_dbEscape($serviceMessage->message) . "',
|
||||
'" . hesk_dbEscape($style) . "',
|
||||
'{$type}',
|
||||
'{$myOrder}',
|
||||
'" . hesk_dbEscape($serviceMessage->icon) . "',
|
||||
'" . hesk_dbEscape($serviceMessage->language) . "'
|
||||
)");
|
||||
|
||||
$serviceMessage->id = hesk_dbInsertID();
|
||||
|
||||
foreach ($serviceMessage->locations as $location) {
|
||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||
(`service_message_id`, `location`) VALUES (" . intval($serviceMessage->id) . ", '" . hesk_dbEscape($location) . "')");
|
||||
}
|
||||
|
||||
// Get the autogenerated fields
|
||||
$rs = hesk_dbQuery("SELECT `dt`, `order` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||
WHERE `id` = " . intval($serviceMessage->id));
|
||||
$row = hesk_dbFetchAssoc($rs);
|
||||
$serviceMessage->dateCreated = $row['dt'];
|
||||
$serviceMessage->order = intval($row['order']);
|
||||
|
||||
$this->close();
|
||||
|
||||
return $serviceMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $heskSettings
|
||||
* @param $searchFilter GetServiceMessagesFilter
|
||||
* @return ServiceMessage[]
|
||||
*/
|
||||
function getServiceMessages($heskSettings, $searchFilter) {
|
||||
$this->init();
|
||||
|
||||
$serviceMessages = array();
|
||||
|
||||
$sql = "SELECT DISTINCT `service_messages`.* FROM `". hesk_dbEscape($heskSettings['db_pfix']) . "service_messages` AS `service_messages` ";
|
||||
|
||||
if (!$searchFilter->includeStaffServiceMessages) {
|
||||
$sql .= "INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location` AS `location`
|
||||
ON `location`.`service_message_id` = `service_messages`.`id` AND `location`.`location` LIKE 'CUSTOMER%' ";
|
||||
}
|
||||
|
||||
if (!$searchFilter->includeDrafts) {
|
||||
$sql .= "WHERE `type` = '0' ";
|
||||
}
|
||||
|
||||
$sql .= "ORDER BY `order`";
|
||||
|
||||
|
||||
$rs = hesk_dbQuery($sql);
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$serviceMessage = new ServiceMessage();
|
||||
$serviceMessage->id = $row['id'];
|
||||
$serviceMessage->published = intval($row['type']) !== 1;
|
||||
$serviceMessage->createdBy = intval($row['author']);
|
||||
$serviceMessage->order = intval($row['order']);
|
||||
$serviceMessage->dateCreated = $row['dt'];
|
||||
$serviceMessage->title = $row['title'];
|
||||
$serviceMessage->message = $row['message'];
|
||||
$serviceMessage->style = ServiceMessageStyle::getStyleById($row['style']);
|
||||
$serviceMessage->icon = $row['icon'];
|
||||
$serviceMessage->language = $row['mfh_language'];
|
||||
$serviceMessage->locations = array();
|
||||
|
||||
$locationSql = "SELECT `location` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||
WHERE `service_message_id` = " . intval($serviceMessage->id);
|
||||
|
||||
if (!$searchFilter->includeStaffServiceMessages) {
|
||||
$locationSql .= " AND `location` LIKE 'CUSTOMER%'";
|
||||
}
|
||||
|
||||
$locationsRs = hesk_dbQuery($locationSql);
|
||||
while ($innerRow = hesk_dbFetchAssoc($locationsRs)) {
|
||||
$serviceMessage->locations[] = $innerRow['location'];
|
||||
}
|
||||
|
||||
$serviceMessages[] = $serviceMessage;
|
||||
}
|
||||
|
||||
$this->close();
|
||||
|
||||
return $serviceMessages;
|
||||
}
|
||||
|
||||
function updateServiceMessage($serviceMessage, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$style = ServiceMessageStyle::getIdForStyle($serviceMessage->style);
|
||||
$type = $serviceMessage->published ? 0 : 1;
|
||||
|
||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||
SET `title` = '" . hesk_dbEscape($serviceMessage->title) . "',
|
||||
`message` = '" . hesk_dbEscape($serviceMessage->message) . "',
|
||||
`style` = '" . intval($style) . "',
|
||||
`type` = '{$type}',
|
||||
`icon` = '" . hesk_dbEscape($serviceMessage->icon) . "',
|
||||
`order` = " . intval($serviceMessage->order) . ",
|
||||
`mfh_language` = '" . hesk_dbEscape($serviceMessage->language) . "'
|
||||
WHERE `id` = " . intval($serviceMessage->id));
|
||||
|
||||
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||
WHERE `service_message_id` = " . intval($serviceMessage->id));
|
||||
foreach ($serviceMessage->locations as $location) {
|
||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||
(`service_message_id`, `location`) VALUES (" . intval($serviceMessage->id) . ", '" . hesk_dbEscape($location) . "')");
|
||||
}
|
||||
|
||||
$otherFieldsRs = hesk_dbQuery("SELECT `dt`, `author`, `order` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||
WHERE `id` = " . intval($serviceMessage->id));
|
||||
$otherFields = hesk_dbFetchAssoc($otherFieldsRs);
|
||||
|
||||
$serviceMessage->createdBy = intval($otherFields['author']);
|
||||
$serviceMessage->dateCreated = $otherFields['dt'];
|
||||
|
||||
$this->close();
|
||||
|
||||
return $serviceMessage;
|
||||
}
|
||||
|
||||
function deleteServiceMessage($id, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_service_message_to_location`
|
||||
WHERE `service_message_id` = " . intval($id));
|
||||
|
||||
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||
WHERE `id` = " . intval($id));
|
||||
|
||||
$this->close();
|
||||
}
|
||||
|
||||
function resortAllServiceMessages($heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$rs = hesk_dbQuery("SELECT `id` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||
ORDER BY `order` ASC");
|
||||
|
||||
$sortValue = 10;
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "service_messages`
|
||||
SET `order` = " . intval($sortValue) . "
|
||||
WHERE `id` = " . intval($row['id']));
|
||||
|
||||
$sortValue += 10;
|
||||
}
|
||||
|
||||
$this->close();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace v330;
|
||||
|
||||
class AddHighlightTicketRowsSetting extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`)
|
||||
VALUES ('highlight_ticket_rows_based_on_priority', '0')");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings`
|
||||
WHERE `Key` = 'highlight_ticket_rows_based_on_priority'");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v330\CalendarImprovements;
|
||||
|
||||
class AddBusinessHoursTable extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours`
|
||||
(`day_of_week` INT NOT NULL, `start_time` VARCHAR(5) NOT NULL, `end_time` VARCHAR(5) NOT NULL)");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours`");
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace v330\CalendarImprovements;
|
||||
|
||||
|
||||
class AddShowStartTimeSetting extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`)
|
||||
VALUES ('calendar_show_start_time', 'true')");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings`
|
||||
WHERE `Key` = 'calendar_show_start_time'");
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace v330\CalendarImprovements;
|
||||
|
||||
|
||||
class InsertDefaultBusinessHours extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (0, '00:00', '23:59')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (1, '00:00', '23:59')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (2, '00:00', '23:59')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (3, '00:00', '23:59')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (4, '00:00', '23:59')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (5, '00:00', '23:59')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours` (`day_of_week`, `start_time`, `end_time`)
|
||||
VALUES (6, '00:00', '23:59')");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_calendar_business_hours`");
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace v330\ServiceMessagesImprovements;
|
||||
|
||||
|
||||
class AddLanguageColumnToServiceMessages extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`
|
||||
ADD COLUMN `mfh_language` VARCHAR(255) NOT NULL DEFAULT 'ALL'");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`
|
||||
DROP COLUMN `mfh_language`");
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace v330\ServiceMessagesImprovements;
|
||||
|
||||
|
||||
class CreateServiceMessageToLocationTable extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`
|
||||
(`service_message_id` INT NOT NULL, `location` VARCHAR(100) NOT NULL)");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`");
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace v330\ServiceMessagesImprovements;
|
||||
|
||||
|
||||
use BusinessLogic\ServiceMessages\ServiceMessageLocation;
|
||||
|
||||
class UpdateExistingServiceMessagesLocations extends \AbstractUpdatableMigration {
|
||||
|
||||
function innerUp($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location` (`service_message_id`, `location`)
|
||||
SELECT `id`, '" . hesk_dbEscape(ServiceMessageLocation::CUSTOMER_HOME) . "' FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`");
|
||||
}
|
||||
|
||||
function innerDown($hesk_settings) {
|
||||
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mfh_service_message_to_location`
|
||||
WHERE `service_message_id` IN (SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`)");
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
define('IN_SCRIPT', 1);
|
||||
define('HESK_PATH', '../../');
|
||||
define('INTERNAL_API_PATH', '../');
|
||||
require_once(HESK_PATH . 'hesk_settings.inc.php');
|
||||
require_once(HESK_PATH . 'inc/common.inc.php');
|
||||
require_once(HESK_PATH . 'inc/attachments.inc.php');
|
||||
require_once(HESK_PATH . 'inc/posting_functions.inc.php');
|
||||
require_once(INTERNAL_API_PATH . 'core/output.php');
|
||||
require_once(INTERNAL_API_PATH . 'dao/calendar_dao.php');
|
||||
require_once(INTERNAL_API_PATH . 'core/cors.php');
|
||||
|
||||
hesk_session_start();
|
||||
hesk_load_internal_api_database_functions();
|
||||
hesk_dbConnect();
|
||||
|
||||
$modsForHesk_settings = mfh_getSettings();
|
||||
|
||||
// Routing
|
||||
$request_method = $_SERVER['REQUEST_METHOD'];
|
||||
if ($request_method === 'GET') {
|
||||
$start = hesk_GET('start');
|
||||
$end = hesk_GET('end');
|
||||
$events = get_events($start, $end, $hesk_settings, false);
|
||||
|
||||
return output($events);
|
||||
}
|
||||
|
||||
return http_response_code(400);
|
@ -1,218 +0,0 @@
|
||||
<?php
|
||||
|
||||
function get_events($start, $end, $hesk_settings, $staff = true) {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
$start_time_sql = "CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($start) . " / 1000), @@session.time_zone, '+00:00')";
|
||||
$end_time_sql = "CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($end) . " / 1000), @@session.time_zone, '+00:00')";
|
||||
|
||||
$sql = "SELECT `events`.*, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
|
||||
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border` ";
|
||||
|
||||
if ($staff) {
|
||||
$sql .= ",`reminders`.`amount` AS `reminder_value`, `reminders`.`unit` AS `reminder_unit` ";
|
||||
}
|
||||
|
||||
$sql .= "FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` AS `events`
|
||||
INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` AS `categories`
|
||||
ON `events`.`category` = `categories`.`id` ";
|
||||
|
||||
if ($staff) {
|
||||
$sql .= "LEFT JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` AS `reminders` ON
|
||||
`reminders`.`user_id` = " . intval($_SESSION['id']) . " AND `reminders`.`event_id` = `events`.`id`";
|
||||
}
|
||||
$sql .= "WHERE NOT (`end` < {$start_time_sql} OR `start` > {$end_time_sql}) AND `categories`.`usage` <> 1";
|
||||
|
||||
if (!$staff) {
|
||||
$sql .= " AND `categories`.`type` = '0'";
|
||||
}
|
||||
|
||||
$rs = hesk_dbQuery($sql);
|
||||
|
||||
$events = array();
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
// Skip the event if the user does not have access to it
|
||||
if ($staff && !$_SESSION['isadmin'] && !in_array($row['category'], $_SESSION['categories'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mfh_log_debug('Calendar', "Creating event with id: {$row['id']}", '');
|
||||
|
||||
$event['type'] = 'CALENDAR';
|
||||
$event['id'] = intval($row['id']);
|
||||
$event['startTime'] = $row['start'];
|
||||
$event['endTime'] = $row['end'];
|
||||
$event['allDay'] = $row['all_day'] ? true : false;
|
||||
$event['title'] = $row['name'];
|
||||
$event['location'] = $row['location'];
|
||||
$event['comments'] = $row['comments'];
|
||||
$event['categoryId'] = $row['category'];
|
||||
$event['categoryName'] = $row['category_name'];
|
||||
$event['backgroundColor'] = $row['background_color'];
|
||||
$event['foregroundColor'] = $row['foreground_color'];
|
||||
$event['displayBorder'] = $row['display_border'];
|
||||
|
||||
if ($staff) {
|
||||
$event['reminderValue'] = $row['reminder_value'];
|
||||
$event['reminderUnits'] = $row['reminder_unit'];
|
||||
}
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
if ($staff) {
|
||||
$old_time_setting = $hesk_settings['timeformat'];
|
||||
$hesk_settings['timeformat'] = 'Y-m-d';
|
||||
$current_date = hesk_date();
|
||||
$hesk_settings['timeformat'] = $old_time_setting;
|
||||
|
||||
$sql = "SELECT `trackid`, `subject`, `due_date`, `category`, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
|
||||
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border`,
|
||||
CASE WHEN `due_date` < '{$current_date}' THEN 1 ELSE 0 END AS `overdue`, `owner`.`name` AS `owner_name`, `tickets`.`owner` AS `owner_id`,
|
||||
`tickets`.`priority` AS `priority`
|
||||
FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` AS `tickets`
|
||||
INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` AS `categories`
|
||||
ON `categories`.`id` = `tickets`.`category`
|
||||
AND `categories`.`usage` <> 2
|
||||
LEFT JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` AS `owner`
|
||||
ON `tickets`.`owner` = `owner`.`id`
|
||||
WHERE `due_date` >= CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($start)
|
||||
. " / 1000), @@session.time_zone, '+00:00')
|
||||
AND `due_date` <= CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($end) . " / 1000), @@session.time_zone, '+00:00')
|
||||
AND `status` IN (SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` WHERE `IsClosed` = 0) ";
|
||||
|
||||
$rs = hesk_dbQuery($sql);
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
// Skip the ticket if the user does not have access to it
|
||||
if (!hesk_checkPermission('can_view_tickets', 0)
|
||||
|| ($row['owner_id'] && $row['owner_id'] != $_SESSION['id'] && !hesk_checkPermission('can_view_ass_others', 0))
|
||||
|| (!$row['owner_id'] && !hesk_checkPermission('can_view_unassigned', 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$event['type'] = 'TICKET';
|
||||
$event['trackingId'] = $row['trackid'];
|
||||
$event['subject'] = $row['subject'];
|
||||
$event['title'] = $row['subject'];
|
||||
$event['startTime'] = $row['due_date'];
|
||||
$event['url'] = $hesk_settings['hesk_url'] . '/' . $hesk_settings['admin_dir'] . '/admin_ticket.php?track=' . $event['trackingId'];
|
||||
$event['categoryId'] = $row['category'];
|
||||
$event['categoryName'] = $row['category_name'];
|
||||
$event['backgroundColor'] = $row['background_color'];
|
||||
$event['foregroundColor'] = $row['foreground_color'];
|
||||
$event['displayBorder'] = $row['display_border'];
|
||||
$event['owner'] = $row['owner_name'];
|
||||
|
||||
$priorities = array(
|
||||
0 => $hesklang['critical'],
|
||||
1 => $hesklang['high'],
|
||||
2 => $hesklang['medium'],
|
||||
3 => $hesklang['low']
|
||||
);
|
||||
$event['priority'] = $priorities[$row['priority']];
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
function create_event($event, $hesk_settings) {
|
||||
// Make sure the user can create events in this category
|
||||
if (!$_SESSION['isadmin'] && !in_array($event['category'], $_SESSION['categories'])) {
|
||||
print_error('Access Denied', 'You cannot create an event in this category');
|
||||
}
|
||||
|
||||
$event['start'] = date('Y-m-d H:i:s', strtotime($event['start']));
|
||||
$event['end'] = date('Y-m-d H:i:s', strtotime($event['end']));
|
||||
$event['all_day'] = $event['all_day'] ? 1 : 0;
|
||||
|
||||
$sql = "INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` (`start`, `end`, `all_day`,
|
||||
`name`, `location`, `comments`, `category`) VALUES (
|
||||
'" . hesk_dbEscape($event['start']) . "', '" . hesk_dbEscape($event['end']) . "', '" . hesk_dbEscape($event['all_day']) . "',
|
||||
'" . hesk_dbEscape(addslashes($event['title'])) . "', '" . hesk_dbEscape(addslashes($event['location'])) . "', '" . hesk_dbEscape(addslashes($event['comments'])) . "',
|
||||
" . intval($event['category']) . ")";
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
$event_id = hesk_dbInsertID();
|
||||
|
||||
if ($event['reminder_amount'] != null) {
|
||||
$sql = "INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` (`user_id`, `event_id`,
|
||||
`amount`, `unit`) VALUES (" . intval($event['reminder_user']) . ", " . intval($event_id) . ", " . intval($event['reminder_amount']) . ",
|
||||
" . intval($event['reminder_units']) . ")";
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
}
|
||||
|
||||
return $event_id;
|
||||
}
|
||||
|
||||
function update_event($event, $hesk_settings) {
|
||||
// Make sure the user can edit events in this category
|
||||
if (!$_SESSION['isadmin'] && !in_array($event['category'], $_SESSION['categories'])) {
|
||||
print_error('Access Denied', 'You cannot edit an event in this category');
|
||||
}
|
||||
|
||||
$event['start'] = date('Y-m-d H:i:s', strtotime($event['start']));
|
||||
$event['end'] = date('Y-m-d H:i:s', strtotime($event['end']));
|
||||
if ($event['create_ticket_date'] != null) {
|
||||
$event['create_ticket_date'] = date('Y-m-d H:i:s', strtotime($event['create_ticket_date']));
|
||||
}
|
||||
$event['all_day'] = $event['all_day'] ? 1 : 0;
|
||||
$event['assign_to'] = $event['assign_to'] != null ? intval($event['assign_to']) : 'NULL';
|
||||
|
||||
$sql = "UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` SET `start` = '" . hesk_dbEscape($event['start'])
|
||||
. "', `end` = '" . hesk_dbEscape($event['end']) . "', `all_day` = '" . hesk_dbEscape($event['all_day']) . "', `name` = '"
|
||||
. hesk_dbEscape(addslashes($event['title'])) . "', `location` = '" . hesk_dbEscape(addslashes($event['location'])) . "', `comments` = '"
|
||||
. hesk_dbEscape(addslashes($event['comments'])) . "', `category` = " . intval($event['category']) . " WHERE `id` = " . intval($event['id']);
|
||||
|
||||
if ($event['reminder_amount'] != null) {
|
||||
$delete_sql = "DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` WHERE `event_id` = " . intval($event['id'])
|
||||
. " AND `user_id` = " . intval($event['reminder_user']);
|
||||
hesk_dbQuery($delete_sql);
|
||||
$insert_sql = "INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` (`user_id`, `event_id`,
|
||||
`amount`, `unit`) VALUES (" . intval($event['reminder_user']) . ", " . intval($event['id']) . ", " . intval($event['reminder_amount']) . ",
|
||||
" . intval($event['reminder_units']) . ")";
|
||||
hesk_dbQuery($insert_sql);
|
||||
}
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
}
|
||||
|
||||
function delete_event($id, $hesk_settings) {
|
||||
// Make sure the user can delete events in this category
|
||||
$categoryRs = hesk_dbQuery('SELECT `category` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'calendar_event` WHERE `id` = ' . intval($id));
|
||||
$category = hesk_dbFetchAssoc($categoryRs);
|
||||
if (!$_SESSION['isadmin'] && !in_array($category['category'], $_SESSION['categories'])) {
|
||||
print_error('Access Denied', 'You cannot delete events in this category');
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` WHERE `id` = " . intval($id);
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
}
|
||||
|
||||
function update_ticket_due_date($ticket, $hesk_settings) {
|
||||
$ticket_id_rs = hesk_dbQuery("SELECT `id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE `trackid` = '" . hesk_dbEscape($ticket['trackid']) . "'");
|
||||
$ticket_id = hesk_dbFetchAssoc($ticket_id_rs);
|
||||
|
||||
$due_date = 'NULL';
|
||||
$language_key = 'audit_due_date_removed';
|
||||
$audit_array = array(0 => $_SESSION['name'] . ' (' . $_SESSION['user'] . ')');
|
||||
if ($ticket['due_date'] != NULL) {
|
||||
$audit_array = array(
|
||||
0 => $_SESSION['name'] . ' (' . $_SESSION['user'] . ')',
|
||||
1 => date('Y-m-d H:i:s', strtotime($ticket['due_date']))
|
||||
);
|
||||
$due_date = "'" . date('Y-m-d H:i:s', strtotime($ticket['due_date'])) . "'";
|
||||
$language_key = 'audit_due_date_changed';
|
||||
}
|
||||
$sql = "UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `due_date` = {$due_date}, `overdue_email_sent` = '0'
|
||||
WHERE `trackid` = '" . hesk_dbEscape($ticket['trackid']) . "'";
|
||||
|
||||
mfh_insert_audit_trail_record($ticket_id['id'], 'TICKET', $language_key, hesk_date(),
|
||||
$audit_array);
|
||||
|
||||
hesk_dbQuery($sql);
|
||||
}
|
@ -0,0 +1,361 @@
|
||||
var serviceMessages = [];
|
||||
|
||||
var g_styles = [];
|
||||
g_styles["ERROR"] = 4;
|
||||
g_styles["NOTICE"] = 3;
|
||||
g_styles["INFO"] = 2;
|
||||
g_styles["SUCCESS"] = 1;
|
||||
g_styles["NONE"] = 0;
|
||||
|
||||
$(document).ready(function() {
|
||||
loadTable();
|
||||
bindEditModal();
|
||||
bindFormSubmit();
|
||||
bindDeleteButton();
|
||||
bindCreateModal();
|
||||
bindSortButtons();
|
||||
bindPreview();
|
||||
});
|
||||
|
||||
|
||||
function loadTable() {
|
||||
$('#overlay').show();
|
||||
var heskUrl = $('p#hesk-path').text();
|
||||
var $tableBody = $('#table-body');
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: heskUrl + 'api/index.php/v1/service-messages',
|
||||
headers: { 'X-Internal-Call': true },
|
||||
success: function(data) {
|
||||
$tableBody.html('');
|
||||
|
||||
if (data.length === 0) {
|
||||
$tableBody.append('<tr><td colspan="4">' + mfhLang.text('no_sm') + '</td></tr>');
|
||||
$('#overlay').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
var first = true;
|
||||
var lastElement = null;
|
||||
$.each(data, function() {
|
||||
var $template = $($('#service-message-template').html());
|
||||
|
||||
$template.find('[data-property="id"]').attr('data-value', this.id);
|
||||
$template.find('span[data-property="title"]').html(
|
||||
getFormattedTitle(this.icon, this.title, this.style));
|
||||
$template.find('span[data-property="author"]').text(users[this.createdBy].name);
|
||||
if (this.published) {
|
||||
$template.find('span[data-property="type"]').text(mfhLang.text('sm_published'));
|
||||
} else {
|
||||
$template.find('span[data-property="type"]').text(mfhLang.text('sm_draft'));
|
||||
}
|
||||
$template.find('[data-property="language"]').text(this.language === 'ALL' ?
|
||||
mfhLang.text('all') :
|
||||
languages[this.language]);
|
||||
|
||||
$tableBody.append($template);
|
||||
|
||||
serviceMessages[this.id] = this;
|
||||
|
||||
lastElement = this;
|
||||
|
||||
if (first) {
|
||||
$template.find('[data-direction="up"]').css('visibility', 'hidden');
|
||||
first = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (lastElement) {
|
||||
//-- Hide the down arrow on the last element
|
||||
$('[data-value="' + lastElement.id + '"]').parent().parent()
|
||||
.find('[data-direction="down"]').css('visibility', 'hidden');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
mfhAlert.errorWithLog(mfhLang.text('error_retrieving_sm'), data.responseJSON);
|
||||
console.error(data);
|
||||
},
|
||||
complete: function() {
|
||||
$('#overlay').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getFormattedTitle(icon, title, style) {
|
||||
var $template = $($('#service-message-title-template').html());
|
||||
|
||||
var alertClass = 'none';
|
||||
switch (style) {
|
||||
case 'ERROR':
|
||||
alertClass = 'alert alert-danger';
|
||||
break;
|
||||
case 'NOTICE':
|
||||
alertClass = 'alert alert-warning';
|
||||
break;
|
||||
case 'INFO':
|
||||
alertClass = 'alert alert-info';
|
||||
break;
|
||||
case 'SUCCESS':
|
||||
alertClass = 'alert alert-success';
|
||||
break;
|
||||
}
|
||||
$template.addClass(alertClass)
|
||||
.find('[data-property="icon"]').addClass(icon).end()
|
||||
.find('[data-property="title"]').text(title);
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
function getServiceMessagePreview(icon, title, message, style) {
|
||||
var $template = $('#service-message-preview-template').html();
|
||||
|
||||
var alertClass = 'none';
|
||||
switch (style) {
|
||||
case 'ERROR':
|
||||
alertClass = 'alert alert-danger';
|
||||
break;
|
||||
case 'NOTICE':
|
||||
alertClass = 'alert alert-warning';
|
||||
break;
|
||||
case 'INFO':
|
||||
alertClass = 'alert alert-info';
|
||||
break;
|
||||
case 'SUCCESS':
|
||||
alertClass = 'alert alert-success';
|
||||
break;
|
||||
}
|
||||
$template = $template.replace('none', alertClass)
|
||||
.replace('{{TITLE}}', title)
|
||||
.replace('{{MESSAGE}}', message);
|
||||
$template = $($template);
|
||||
if (icon !== '') {
|
||||
$template.find('i.fa').removeClass('fa').addClass(icon);
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
function bindEditModal() {
|
||||
$(document).on('click', '[data-action="edit"]', function() {
|
||||
var element = serviceMessages[$(this).parent().parent().find('[data-property="id"]').data('value')];
|
||||
var $modal = $('#service-message-modal');
|
||||
$modal.find('#preview-pane').html('').end()
|
||||
.find('input[name="location[]"]').prop('checked', false);
|
||||
|
||||
$modal.find('#edit-label').show();
|
||||
$modal.find('#create-label').hide();
|
||||
|
||||
$modal.find('input[name="style"][value="' + (g_styles[element.style]) + '"]').prop('checked', 'checked').end()
|
||||
.find('input[name="type"][value="' + (element.published ? 0 : 1) + '"]')
|
||||
.prop('checked', 'checked').end()
|
||||
.find('input[name="title"]').val(element.title).end()
|
||||
.find('input[name="id"]').val(element.id).end()
|
||||
.find('input[name="order"]').val(element.order).end()
|
||||
.find('select[name="language"]').val(element.language).end();
|
||||
setIcon(element.icon);
|
||||
|
||||
$.each(element.locations, function() {
|
||||
$modal.find('input[name="location[]"][value="' + this + '"]').prop('checked', 'checked');
|
||||
});
|
||||
|
||||
if ($('input[name="kb_wysiwyg"]').val() === "1") {
|
||||
tinyMCE.get('content').setContent(element.message);
|
||||
} else {
|
||||
$('textarea[name="message"]').val(element.message);
|
||||
}
|
||||
|
||||
$('.tab-pane#sm-contents').addClass('active');
|
||||
$('.tab-pane#properties').removeClass('active');
|
||||
$('.nav-tabs > li').removeClass('active');
|
||||
$('.nav-tabs > li:first').addClass('active');
|
||||
|
||||
|
||||
$modal.modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function bindCreateModal() {
|
||||
$('#create-button').click(function() {
|
||||
var $modal = $('#service-message-modal');
|
||||
$modal.find('#edit-label').hide().end()
|
||||
.find('#create-label').show().end()
|
||||
.find('input[name="style"][value="0"]').prop('checked', 'checked').end() // "None" style
|
||||
.find('input[name="type"][value="0"]').prop('checked', 'checked').end() // Published
|
||||
.find('input[name="title"]').val('').end()
|
||||
.find('input[name="id"]').val(-1).end()
|
||||
.find('input[name="order"]').val('').end()
|
||||
.find('#preview-pane').html('').end()
|
||||
.find('input[name="location[]"]').prop('checked', false)
|
||||
.find('select[name="language"]').val('ALL');
|
||||
setIcon('');
|
||||
|
||||
if ($('input[name="kb_wysiwyg"]').val() === "1") {
|
||||
tinyMCE.get('content').setContent('');
|
||||
} else {
|
||||
$('textarea[name="message"]').val('');
|
||||
}
|
||||
|
||||
$('.tab-pane#sm-contents').addClass('active');
|
||||
$('.tab-pane#properties').removeClass('active');
|
||||
$('.nav-tabs > li').removeClass('active');
|
||||
$('.nav-tabs > li:first').addClass('active');
|
||||
|
||||
$modal.modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function bindFormSubmit() {
|
||||
$('form#service-message').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var heskUrl = $('p#hesk-path').text();
|
||||
|
||||
var $modal = $('#service-message-modal');
|
||||
|
||||
var styles = [];
|
||||
styles[0] = "NONE";
|
||||
styles[1] = "SUCCESS";
|
||||
styles[2] = "INFO";
|
||||
styles[3] = "NOTICE";
|
||||
styles[4] = "ERROR";
|
||||
|
||||
var domLocations = $modal.find('input[name="location[]"]:checked');
|
||||
|
||||
var locations = [];
|
||||
$.each(domLocations, function() {
|
||||
locations.push($(this).val());
|
||||
});
|
||||
|
||||
var data = {
|
||||
icon: $modal.find('input[name="icon"]').val(),
|
||||
title: $modal.find('input[name="title"]').val(),
|
||||
message: getMessage(),
|
||||
published: $modal.find('input[name="type"]:checked').val() === "0",
|
||||
style: styles[$modal.find('input[name="style"]:checked').val()],
|
||||
order: $modal.find('input[name="order"]').val(),
|
||||
language: $modal.find('select[name="language"]').val(),
|
||||
locations: locations
|
||||
};
|
||||
|
||||
var url = heskUrl + 'api/index.php/v1/service-messages/';
|
||||
var method = 'POST';
|
||||
|
||||
var serviceMessageId = parseInt($modal.find('input[name="id"]').val());
|
||||
if (serviceMessageId !== -1) {
|
||||
url += serviceMessageId;
|
||||
method = 'PUT';
|
||||
}
|
||||
|
||||
$modal.find('#action-buttons').find('.cancel-button').attr('disabled', 'disabled');
|
||||
$modal.find('#action-buttons').find('.save-button').attr('disabled', 'disabled');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
headers: {
|
||||
'X-Internal-Call': true,
|
||||
'X-HTTP-Method-Override': method
|
||||
},
|
||||
data: JSON.stringify(data),
|
||||
success: function(data) {
|
||||
if (serviceMessageId === -1) {
|
||||
mfhAlert.success(mfhLang.text('sm_added'));
|
||||
} else {
|
||||
mfhAlert.success(mfhLang.text('sm_mdf'));
|
||||
}
|
||||
$modal.modal('hide');
|
||||
loadTable();
|
||||
},
|
||||
error: function(data) {
|
||||
mfhAlert.errorWithLog(mfhLang.text('error_saving_updating_sm'), data.responseJSON);
|
||||
console.error(data);
|
||||
},
|
||||
complete: function(data) {
|
||||
$modal.find('#action-buttons').find('.cancel-button').removeAttr('disabled');
|
||||
$modal.find('#action-buttons').find('.save-button').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bindDeleteButton() {
|
||||
$(document).on('click', '[data-action="delete"]', function() {
|
||||
$('#overlay').show();
|
||||
|
||||
var heskUrl = $('p#hesk-path').text();
|
||||
var element = serviceMessages[$(this).parent().parent().find('[data-property="id"]').data('value')];
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: heskUrl + 'api/index.php/v1/service-messages/' + element.id,
|
||||
headers: {
|
||||
'X-Internal-Call': true,
|
||||
'X-HTTP-Method-Override': 'DELETE'
|
||||
},
|
||||
success: function() {
|
||||
mfhAlert.success(mfhLang.text('sm_deleted'));
|
||||
loadTable();
|
||||
},
|
||||
error: function(data) {
|
||||
$('#overlay').hide();
|
||||
mfhAlert.errorWithLog(mfhLang.text('error_deleting_sm'), data.responseJSON);
|
||||
console.error(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bindSortButtons() {
|
||||
$(document).on('click', '[data-action="sort"]', function() {
|
||||
$('#overlay').show();
|
||||
var heskUrl = $('p#hesk-path').text();
|
||||
var direction = $(this).data('direction');
|
||||
var element = serviceMessages[$(this).parent().parent().parent().find('[data-property="id"]').data('value')];
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: heskUrl + 'api/index.php/v1-internal/service-messages/' + element.id + '/sort/' + direction,
|
||||
headers: { 'X-Internal-Call': true },
|
||||
success: function() {
|
||||
loadTable();
|
||||
},
|
||||
error: function(data) {
|
||||
mfhAlert.errorWithLog(mfhLang.text('error_sorting_categories'), data.responseJSON);
|
||||
console.error(data);
|
||||
$('#overlay').hide();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function bindPreview() {
|
||||
$('.preview-button').click(function() {
|
||||
var styles = [];
|
||||
styles[0] = "NONE";
|
||||
styles[1] = "SUCCESS";
|
||||
styles[2] = "INFO";
|
||||
styles[3] = "NOTICE";
|
||||
styles[4] = "ERROR";
|
||||
|
||||
var $modal = $('#service-message-modal');
|
||||
var data = {
|
||||
icon: $modal.find('input[name="icon"]').val(),
|
||||
title: $modal.find('input[name="title"]').val(),
|
||||
message: getMessage(),
|
||||
published: $modal.find('input[name="type"]:checked').val() === "0",
|
||||
style: styles[$modal.find('input[name="style"]:checked').val()],
|
||||
order: $modal.find('input[name="order"]').val()
|
||||
};
|
||||
|
||||
var preview = getServiceMessagePreview(data.icon, data.title, data.message, data.style);
|
||||
$('#preview-pane').html(preview);
|
||||
});
|
||||
}
|
||||
|
||||
function getMessage() {
|
||||
if ($('input[name="kb_wysiwyg"]').val() === "1") {
|
||||
return tinyMCE.get('content').getContent();
|
||||
}
|
||||
|
||||
return $('textarea[name="message"]').val();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue