From 8170fa2b5664afc06a50ad251e65401719c4793f Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Wed, 29 Mar 2017 19:19:40 +0200 Subject: [PATCH] pkp/pkp-lib#1932 display submission note file --- .../InformationCenterHandler.inc.php | 22 ++++++++++++++++++- .../controllers/informationCenter/note.tpl | 6 ++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/controllers/informationCenter/InformationCenterHandler.inc.php b/controllers/informationCenter/InformationCenterHandler.inc.php index 914c8739e31..ca419d120cf 100644 --- a/controllers/informationCenter/InformationCenterHandler.inc.php +++ b/controllers/informationCenter/InformationCenterHandler.inc.php @@ -104,11 +104,31 @@ function listNotes($args, $request) { $templateMgr = TemplateManager::getManager($request); $noteDao = DAORegistry::getDAO('NoteDAO'); $user = $request->getUser(); + + // get submission note file, needed for legacy data + $noteFilesDownloadLink = array(); + $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); + import('lib.pkp.classes.submission.SubmissionFile'); + import('lib.pkp.controllers.api.file.linkAction.DownloadFileLinkAction'); + $notes = $noteDao->getByAssoc($this->_getAssocType(), $this->_getAssocId()); + while ($note = $notes->next()) { + $submissionFiles = $submissionFileDao->getLatestRevisionsByAssocId( + ASSOC_TYPE_NOTE, $note->getId(), + $this->_getAssocId(), + SUBMISSION_FILE_NOTE + ); + if (!empty($submissionFiles)) { + assert(count($submissionFiles) == 1); + $noteFilesDownloadLink[$note->getId()] = new DownloadFileLinkAction($request, array_shift($submissionFiles), $request->getUserVar('stageId')); + } + } + $templateMgr->assign(array( 'notes' => $noteDao->getByAssoc($this->_getAssocType(), $this->_getAssocId()), 'currentUserId' => $user->getId(), 'notesDeletable' => true, - 'notesListId' => 'notesList' + 'notesListId' => 'notesList', + 'noteFilesDownloadLink' => $noteFilesDownloadLink, )); $json = new JSONMessage(true, $templateMgr->fetch('controllers/informationCenter/notesList.tpl')); $json->setEvent('dataChanged'); diff --git a/templates/controllers/informationCenter/note.tpl b/templates/controllers/informationCenter/note.tpl index 9314ed1f325..a23c336f516 100644 --- a/templates/controllers/informationCenter/note.tpl +++ b/templates/controllers/informationCenter/note.tpl @@ -33,9 +33,6 @@ {if ($notesDeletable && array_intersect(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), (array)$userRoles)) || $noteFileDownloadLink}
- {if $noteFileDownloadLink} - {include file="linkAction/linkAction.tpl" action=$noteFileDownloadLink contextId=$note->getId()} - {/if} {if $notesDeletable && array_intersect(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), (array)$userRoles)}
{csrf} @@ -48,6 +45,9 @@ {/if}
+ {if $noteFileDownloadLink} + {include file="linkAction/linkAction.tpl" action=$noteFileDownloadLink contextId=$note->getId()} + {/if} {include file="controllers/revealMore.tpl" content=$note->getContents()|strip_unsafe_html}