From a7afb7ffee6b64daa6d24e30650b4724c60cb722 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Mon, 11 Mar 2019 12:25:10 +0100 Subject: [PATCH] FIX only show attach type in admin templates --- .../models/AttachmentModelAbstract.php | 15 +++++++------- .../controllers/TemplateController.php | 20 +++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/app/attachment/models/AttachmentModelAbstract.php b/src/app/attachment/models/AttachmentModelAbstract.php index 7e7776361c1..e555c1a8292 100755 --- a/src/app/attachment/models/AttachmentModelAbstract.php +++ b/src/app/attachment/models/AttachmentModelAbstract.php @@ -131,14 +131,13 @@ abstract class AttachmentModelAbstract $attachmentTypesXML = $loadedXml->attachment_types; if (count($attachmentTypesXML) > 0) { foreach ($attachmentTypesXML->type as $value) { - if ((string)$value->attributes()->show == 'true') { - $label = defined((string) $value->label) ? constant((string) $value->label) : (string) $value->label; - $attachmentTypes[(string) $value->id] = [ - 'label' => $label, - 'icon' => (string)$value['icon'], - 'sign' => (empty($value['sign']) || (string)$value['sign'] == 'true') ? true : false - ]; - } + $label = defined((string) $value->label) ? constant((string) $value->label) : (string) $value->label; + $attachmentTypes[(string) $value->id] = [ + 'label' => $label, + 'icon' => (string)$value['icon'], + 'sign' => (empty($value['sign']) || (string)$value['sign'] == 'true') ? true : false, + 'show' => (empty($value->attributes()->show) || (string)$value->attributes()->show == 'true') ? true : false + ]; } } } diff --git a/src/app/template/controllers/TemplateController.php b/src/app/template/controllers/TemplateController.php index a0af13c380f..4a55edabb35 100755 --- a/src/app/template/controllers/TemplateController.php +++ b/src/app/template/controllers/TemplateController.php @@ -80,10 +80,12 @@ class TemplateController $attachmentModelsTmp = AttachmentModel::getAttachmentsTypesByXML(); $attachmentTypes = []; foreach ($attachmentModelsTmp as $key => $value) { - $attachmentTypes[] = [ - 'label' => $value['label'], - 'id' => $key - ]; + if ($value['show']) { + $attachmentTypes[] = [ + 'label' => $value['label'], + 'id' => $key + ]; + } } return $response->withJson([ @@ -355,10 +357,12 @@ class TemplateController $attachmentModelsTmp = AttachmentModel::getAttachmentsTypesByXML(); $attachmentTypes = []; foreach ($attachmentModelsTmp as $key => $value) { - $attachmentTypes[] = [ - 'label' => $value['label'], - 'id' => $key - ]; + if ($value['show']) { + $attachmentTypes[] = [ + 'label' => $value['label'], + 'id' => $key + ]; + } } $entities = EntityModel::getAllowedEntitiesByUserId(['userId' => 'superadmin']); -- GitLab