diff --git a/main/inc/lib/PortfolioController.php b/main/inc/lib/PortfolioController.php index 7b184db524..276013d544 100644 --- a/main/inc/lib/PortfolioController.php +++ b/main/inc/lib/PortfolioController.php @@ -399,6 +399,14 @@ class PortfolioController $extraField = new ExtraField('portfolio'); $extra = $extraField->addElements($form, $item->getId()); + $attachmentList = $this->generateAttachmentList($item, false); + + if (!empty($attachmentList)) { + $form->addLabel(get_lang('AttachmentFiles'), $attachmentList); + } + + $this->addAttachmentsFieldToForm($form); + $form->addButtonUpdate(get_lang('Update')); $form->setDefaults( [ @@ -428,6 +436,13 @@ class PortfolioController $this->em->persist($item); $this->em->flush(); + $this->processAttachments( + $form, + $item->getUser(), + $item->getId(), + PortfolioAttachment::TYPE_ITEM + ); + Display::addFlash( Display::return_message(get_lang('ItemUpdated'), 'success') ); @@ -1707,11 +1722,16 @@ class PortfolioController $fs->remove($attachmentFilename); - Display::addFlash( - Display::return_message(get_lang('AttachmentFileDeleteSuccess'), 'success') - ); + if ($httpRequest->isXmlHttpRequest()) { + echo Display::return_message(get_lang('AttachmentFileDeleteSuccess'), 'success'); + } else { + Display::addFlash( + Display::return_message(get_lang('AttachmentFileDeleteSuccess'), 'success') + ); + + header('Location: '.$this->baseUrl.http_build_query(['action' => 'view', 'id' => $itemId])); + } - header('Location: '.$this->baseUrl.http_build_query(['action' => 'view', 'id' => $itemId])); exit; } @@ -2095,7 +2115,7 @@ class PortfolioController return $form->returnForm(); } - private function generateAttachmentList($post): string + private function generateAttachmentList($post, bool $includeHeader = true): string { $attachmentsRepo = $this->em->getRepository(PortfolioAttachment::class); @@ -2117,7 +2137,7 @@ class PortfolioController $currentUserId = api_get_user_id(); - $listItems = ''; + $listItems = '