diff --git a/crm/blocks/html/ticketHistory/info.inc b/crm/blocks/html/ticketHistory/info.inc index b3f9b13d..8467d11d 100644 --- a/crm/blocks/html/ticketHistory/info.inc +++ b/crm/blocks/html/ticketHistory/info.inc @@ -1,11 +1,12 @@ history * @param Ticket $this->ticket (optional) * @param bool $this->disableComments (optional) */ +use Application\Models\Action; use Application\Models\Person; ?>
@@ -13,11 +14,35 @@ use Application\Models\Person;

_('history'); ?>

_include('ticketHistory/partials/personalInfo.inc'); - } - else { - $this->_include('ticketHistory/partials/genericInfo.inc'); + $canViewPeople = Person::isAllowed('people', 'view'); + + foreach ($this->history as $event) { + $description = $event->getDescription($this->template); + echo " +
+
+

{$event->getActionDate(DATETIME_FORMAT)} $description

+
+ "; + + if (!$this->disableComments) { + $notes = self::escape($event->getNotes()); + if ($notes) { + echo "

$notes

"; + } + } + switch ($event->getAction()->getName()) { + case Action::UPDATED: + if ($event->getData()) { echo json_encode($event->getData()); } + break; + } + + $notification = $event->getSentNotifications(); + if ($notification) { + $this->notification = $notification; + $this->_include('ticketHistory/sentNotification.inc'); + } + echo "
"; } ?>
diff --git a/crm/blocks/html/ticketHistory/partials/genericInfo.inc b/crm/blocks/html/ticketHistory/partials/genericInfo.inc deleted file mode 100644 index ca6d4c51..00000000 --- a/crm/blocks/html/ticketHistory/partials/genericInfo.inc +++ /dev/null @@ -1,23 +0,0 @@ -history - * @param Ticket $this->ticket (optional) - * @param bool $this->disableComments (optional) - */ -declare (strict_types=1); -use Application\Models\Action; -foreach ($this->history as $event) { - echo " -
-
-

{$event->getActionDate(DATETIME_FORMAT)} - {$event->getAction()->getName()} -

-
-
- "; -} diff --git a/crm/blocks/html/ticketHistory/partials/personalInfo.inc b/crm/blocks/html/ticketHistory/partials/personalInfo.inc deleted file mode 100644 index 734ab472..00000000 --- a/crm/blocks/html/ticketHistory/partials/personalInfo.inc +++ /dev/null @@ -1,40 +0,0 @@ -history - * @param Ticket $this->ticket (optional) - * @param bool $this->disableComments (optional) - */ -declare (strict_types=1); -use Application\Models\Action; -foreach ($this->history as $event) { - $description = $event->getDescription($this->template); - echo " -
-
-

{$event->getActionDate(DATETIME_FORMAT)} $description

-
- "; - - if (!$this->disableComments) { - $notes = self::escape($event->getNotes()); - if ($notes) { - echo "

$notes

"; - } - } - switch ($event->getAction()->getName()) { - case Action::UPDATED: - if ($event->getData()) { echo json_encode($event->getData()); } - break; - } - - $notification = $event->getSentNotifications(); - if ($notification) { - $this->notification = $notification; - $this->_include('ticketHistory/sentNotification.inc'); - } - echo "
"; -} diff --git a/crm/blocks/html/ticketHistory/sentNotification.inc b/crm/blocks/html/ticketHistory/sentNotification.inc index 366264e5..07d17461 100644 --- a/crm/blocks/html/ticketHistory/sentNotification.inc +++ b/crm/blocks/html/ticketHistory/sentNotification.inc @@ -1,16 +1,19 @@ notification */ use Application\Models\Person; -$people = []; +$canView = Person::isAllowed('people', 'view'); +$people = []; foreach ($this->notification->people as $id) { try { $person = new Person($id); - $people[] = self::escape($person->getFullname()); + $people[] = ($person->getUsername() || $canView) + ? self::escape($person->getFullname()) + : $this->_('anonymous'); } catch (\Exception $e) { } } diff --git a/crm/blocks/html/tickets/ticketInfo.inc b/crm/blocks/html/tickets/ticketInfo.inc index 321c8cf1..74037a34 100644 --- a/crm/blocks/html/tickets/ticketInfo.inc +++ b/crm/blocks/html/tickets/ticketInfo.inc @@ -1,6 +1,6 @@ ticket * @param bool $this->disableButtons @@ -32,21 +32,21 @@ $description = $contactMethod || $description : ''; $description = $description ? "

$description

" : ''; -$fields = ''; -if (Person::isAllowed('people', 'view')) { - $person = $this->ticket->getReportedByPerson(); - if ($person) { - $uri = BASE_URI.'/people/view?person_id='.$person->getId(); - $name = "{$person->getFullname()}"; - $fields.= "
{$this->_('reportedByPerson')}
$name
"; - } - $person = $this->ticket->getAssignedPerson(); - if ($person) { - $uri = BASE_URI.'/people/view?person_id='.$person->getId(); - $name = "{$person->getFullname()}"; - $fields.= "
{$this->_('assignedPerson_id')}
$name
"; - } +$fields = ''; +$canView = Person::isAllowed('people', 'view'); +$person = $this->ticket->getReportedByPerson(); +if ($person && ($person->getUsername() || $canView)) { + $uri = BASE_URI.'/people/view?person_id='.$person->getId(); + $name = "{$person->getFullname()}"; + $fields.= "
{$this->_('reportedByPerson')}
$name
"; } +$person = $this->ticket->getAssignedPerson(); +if ($person && ($person->getUsername() || $canView)) { + $uri = BASE_URI.'/people/view?person_id='.$person->getId(); + $name = "{$person->getFullname()}"; + $fields.= "
{$this->_('assignedPerson_id')}
$name
"; +} + $cf = $this->ticket->getCategory_id() ? $this->ticket->getCategory()->getCustomFields() : null; if ($cf) { $data = $this->ticket->getCustomFields(); diff --git a/crm/src/Application/Models/Person.php b/crm/src/Application/Models/Person.php index 663f6db3..173cb470 100644 --- a/crm/src/Application/Models/Person.php +++ b/crm/src/Application/Models/Person.php @@ -1,6 +1,6 @@ getUsername() || Person::isAllowed('people', 'view')) + ? $this->getFullname() + : $t->_('anonymous'); + } + /** * @return string */ diff --git a/crm/src/Application/Models/TicketHistory.php b/crm/src/Application/Models/TicketHistory.php index 348447e0..37df8f75 100644 --- a/crm/src/Application/Models/TicketHistory.php +++ b/crm/src/Application/Models/TicketHistory.php @@ -1,6 +1,6 @@ getAction(); - if ($a) { + $action = $this->getAction(); + if ($action) { return $this->renderVariables( - $this->getAction()->getDescription(), + $action->getDescription(), $template ); } @@ -173,14 +173,13 @@ public function getDescription(Template $template) * * @param string $message * @param Template $template The template being used for output formatting - * @param Person $person The person to whom the message will be displayed * @return string */ public function renderVariables($message, Template $template) { $placeholders = [ - 'enteredByPerson'=> $this->getEnteredByPerson_id() ? $this->getEnteredByPerson()->getFullname() : $template->_('anonymous'), - 'actionPerson' => $this->getActionPerson_id() ? $this->getActionPerson() ->getFullname() : $template->_('anonymous'), + 'enteredByPerson'=> $this->getEnteredByPerson_id() ? $this->getEnteredByPerson()->anonymizeCitizenName($template) : $template->_('anonymous'), + 'actionPerson' => $this->getActionPerson_id() ? $this->getActionPerson ()->anonymizeCitizenName($template) : $template->_('anonymous'), 'ticket_id' => $this->getTicket_id(), 'enteredDate' => $this->getEnteredDate(DATETIME_FORMAT), 'actionDate' => $this->getActionDate (DATETIME_FORMAT)