From d3442d444cd3bd17396d7426e73f931a0c0f281e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 18 May 2019 16:31:22 +0200 Subject: [PATCH] Fix forward handling in tasks/task elements --- Controller/ApiController.php | 4 ++-- Controller/BackendController.php | 2 +- Models/TaskElement.php | 8 ++----- Theme/Backend/Lang/en.lang.php | 1 + Theme/Backend/task-single.tpl.php | 40 ++++++++++++++++++------------- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 973d0d0..b13a5da 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -267,11 +267,11 @@ final class ApiController extends Controller } foreach ($tos as $to) { - $element->addTo($to); + $element->addTo((int) $to); } foreach ($ccs as $cc) { - $element->addCC($cc); + $element->addCC((int) $cc); } return $element; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 799cdd6..fe619fa 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -110,7 +110,7 @@ final class BackendController extends Controller $head = $response->get('Content')->getData('head'); $head->addAsset(AssetType::CSS, '/Modules/Tasks/Theme/Backend/css/styles.css'); - $task = TaskMapper::get((int) $request->getData('id')); + $task = TaskMapper::get((int) $request->getData('id'), RelationType::ALL, null, 5); $accountId = $request->getHeader()->getAccount(); if (!($task->getCreatedBy()->getId() === $accountId diff --git a/Models/TaskElement.php b/Models/TaskElement.php index df2f60e..eaab3a9 100644 --- a/Models/TaskElement.php +++ b/Models/TaskElement.php @@ -182,10 +182,6 @@ class TaskElement implements \JsonSerializable public function setCreatedBy($creator) : void { $this->createdBy = $creator; - - if (empty($this->acc)) { - $this->addTo($this->createdBy); - } } /** @@ -458,7 +454,7 @@ class TaskElement implements \JsonSerializable { if ($to instanceof Group) { $this->addGroupTo($to); - } elseif(($to instanceof Account) || \is_int($to)) { + } elseif (($to instanceof Account) || \is_int($to)) { $this->addAccountTo($to); } } @@ -550,7 +546,7 @@ class TaskElement implements \JsonSerializable { if ($cc instanceof Group) { $this->addGroupCC($cc); - } elseif(($cc instanceof Account) || \is_int($cc)) { + } elseif (($cc instanceof Account) || \is_int($cc)) { $this->addAccountCC($cc); } } diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 4c8a335..5ba459a 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -26,6 +26,7 @@ return ['Tasks' => [ 'Due/Priority' => 'Due/Priority', 'Forward' => 'Forward', 'Forwarded' => 'Forwarded', + 'ForwardedTo' => 'Forwarded to', 'From' => 'From', 'Group' => 'Group', 'History' => 'History', diff --git a/Theme/Backend/task-single.tpl.php b/Theme/Backend/task-single.tpl.php index f191ba7..8e74e23 100644 --- a/Theme/Backend/task-single.tpl.php +++ b/Theme/Backend/task-single.tpl.php @@ -15,6 +15,8 @@ use \Modules\Admin\Models\Account; use \Modules\Admin\Models\Group; use \Modules\Tasks\Models\TaskPriority; use \Modules\Tasks\Models\TaskStatus; +use \Modules\Tasks\Models\AccountRelation; +use \Modules\Tasks\Models\GroupRelation; /** * @var \phpOMS\Views\View $this @@ -99,21 +101,9 @@ echo $this->getData('nav')->render(); ?> $element) : $c++; ?> - getTo(); if ($c > 1 && \count($tos) > 1) : ?> -
-
- getHtml('Forwarded') ?> - - - printHtml($to->getRelation()->getName1()); ?> - - printHtml($to->getRelation()->getName()); ?> - - -
-
- + foreach ($elements as $key => $element) : $c++; + if ($element->getDescription() !== '') : + ?>
@@ -153,6 +143,24 @@ echo $this->getData('nav')->render(); ?>
+ + + getTo(); + if ($c > 1 && \count($tos) > 0) : ?> +
+
+ getHtml('ForwardedTo') ?> + + + printHtml($to->getRelation()->getName1()); ?> + + printHtml($to->getRelation()->getName()); ?> + + +
+
+ @@ -187,7 +195,7 @@ echo $this->getData('nav')->render(); ?>