Skip to content

Commit

Permalink
#5299 Move Submission Preview to pkp-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnyga authored and asmecher committed Dec 13, 2022
1 parent ac43a3c commit 3a4dce7
Show file tree
Hide file tree
Showing 28 changed files with 227 additions and 0 deletions.
62 changes: 62 additions & 0 deletions classes/submission/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use PKP\plugins\Hook;
use PKP\security\Role;
use PKP\services\PKPSchemaService;
use PKP\user\User;
use PKP\validation\ValidatorFactory;

abstract class Repository
Expand Down Expand Up @@ -328,6 +329,37 @@ public function canEditPublication(int $submissionId, int $userId): bool
return false;
}

/**
* Checks if this user is granted reader access to pre-publication submissions
* based on their roles in the context (i.e. Manager, Editor, etc).
*
* @param $user User
* @param $submission Submission
*
* @return bool
*/
public function canPreview(User $user, Submission $submission): bool
{
// Only grant access when in copyediting or production stage
if (!in_array($submission->getData('stageId'), [WORKFLOW_STAGE_ID_EDITING, WORKFLOW_STAGE_ID_PRODUCTION])) {
return false;
}

if ($this->_roleCanPreview($user, $submission)) {
return true;
}

if ($user) {
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
$stageAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR, null, $user->getId());
$stageAssignment = $stageAssignments->next();
if ($stageAssignment) {
return true;
}
}
return false;
}

/** @copydoc DAO::insert */
public function add(Submission $submission, Publication $publication): int
{
Expand Down Expand Up @@ -576,4 +608,34 @@ protected function getCurrentPublicationIdByPublications(Submission $submission)

return $newCurrentPublicationId ?? $submission->getData('currentPublicationId');
}

/**
* Checks if this user is granted access to preview
* based on their roles in the context (i.e. Manager, Editor, etc).
*
* @param $user User
* @param $submission Submission
*
* @return bool
*/
protected function _roleCanPreview(User $user, Submission $submission): bool
{
$roleDao = DAORegistry::getDAO('RoleDAO'); /* @var $roleDao RoleDAO */
if ($user && $submission) {
$subscriptionAssumedRoles = [
Role::ROLE_ID_MANAGER,
Role::ROLE_ID_SUB_EDITOR,
Role::ROLE_ID_ASSISTANT,
Role::ROLE_ID_SUBSCRIPTION_MANAGER
];

$roles = $roleDao->getByUserId($user->getId(), $submission->getData('contextId'));
foreach ($roles as $role) {
if (in_array($role->getRoleId(), $subscriptionAssumedRoles)) {
return true;
}
}
}
return false;
}
}
5 changes: 5 additions & 0 deletions locale/ar_IQ/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2319,3 +2319,8 @@ msgid "editor.submission.decision.backFromCopyediting.notifyAuthorsDescription"
msgstr ""
"إرسال بريد الكتروني إلى المؤلفين لإبلاغهم بإلغاء التدقيق وبأن طلب تقديمهم "
"سيخضع للمزيد من مراجعات التحرير."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"هذه معاينة استعراضية ولم يتم نشرها بعد. <a href=\"{$url}\">View ""submission</a>"
5 changes: 5 additions & 0 deletions locale/bs_BA/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -565,3 +565,8 @@ msgstr "Publikacija za ovog autora nije pronađena."

msgid "author.editPublishedDisabled"
msgstr "Autore ove publikacije nije moguće uređivati jer je već objavljena."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Ovo je pregled i nije objavljeno. <a href=\"{$url}\">Pogledaj predaju</a>"
6 changes: 6 additions & 0 deletions locale/ca_ES/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2195,3 +2195,9 @@ msgstr "S'ha reactivat la tramesa rebutjada."

msgid "editor.submission.decision.revertDecline"
msgstr "Revertir el rebuig"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Això és una vista prèvia i encara no s'ha publicat. <a href=\"{$url}\">Veure "
"tramesa</a>"
6 changes: 6 additions & 0 deletions locale/cs_CZ/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2445,3 +2445,9 @@ msgid "log.review.reviewerResendRequest"
msgstr ""
"Opětovné odeslání žádosti o recenzi v kole {$round} na adresu {$reviewerName}"
" pro příspěvek {$submissionid}."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Toto je náhled – dosud nebyl publikován. <a href=\"{$url}\">Zobrazit "
"příspěvek</a>"
5 changes: 5 additions & 0 deletions locale/da_DK/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2459,3 +2459,8 @@ msgid "log.review.reviewerResendRequest"
msgstr ""
"Sendte anmodningen om at bedømme i bedømmelsesrunde {$round} til "
"{$reviewerName} for indsendelsen {$submissionid} igen."

msgid "submission.viewingPreview"
msgstr ""
"Dette er en forhåndsvisning, der endnu ikke blevet offentliggjort. <a href=\""
"{$url}\">Se indsendelse</a>"
6 changes: 6 additions & 0 deletions locale/de_DE/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2010,3 +2010,9 @@ msgstr "Kategorien"

msgid "submission.submit.includeInBrowse.title"
msgstr "Publikationslisten"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Diese Vorschau wurde noch nicht veröffentlicht. <a href=\"{$url}\">Beitrag "
"anzeigen</a>"
6 changes: 6 additions & 0 deletions locale/el_GR/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1982,3 +1982,9 @@ msgstr "Δήλωση πνευματικών δικαιωμάτων"

msgid "submission.copyrightHolder.other"
msgstr "Προσαρμοσμένη δήλωση πνευματικών δικαιωμάτων"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Αυτή είναι μια προεπισκόπηση και δεν έχει δημοσιευτεί ακόμα. <a href=\"{$url}"
"\">Δείτε την υποβολή</a>"
3 changes: 3 additions & 0 deletions locale/en_US/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2204,3 +2204,6 @@ msgstr "Failed to mark the DOI stale for {$pubObjectTitle}. The DOI cannot be ma

msgid "doi.submission.notPublished"
msgstr "Failed to mark the DOI registered for {$pubObjectTitle}. The submission must be published before the status can be updated."

msgid "submission.viewingPreview"
msgstr "This is a preview and has not been published. <a href=\"{$url}\">View submission</a>"
6 changes: 6 additions & 0 deletions locale/es_ES/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2085,3 +2085,9 @@ msgstr "Se ha reactivado el envío rechazado."

msgid "notification.type.revertDecline"
msgstr "Se ha revertido la decisión de rechazar este envío."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Esta es una vista previa y no se ha publicado. <a href=\"{$url}\">Ver "
"envío</a>"
5 changes: 5 additions & 0 deletions locale/fi_FI/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1994,3 +1994,8 @@ msgstr ""
"keräämään puuttuvat arviot mahdollisimman nopeasti. Sinun ei tässä vaiheessa "
"tarvitse ryhtyä mihinkään toimenpiteisiin. Sinulle ilmoitetaan heti, kun "
"arviot ovat valmiina ja toimittaja tekee päätöksen käsikirjoituksesi suhteen."

msgid "submission.viewingPreview"
msgstr ""
"Tämä on esikatselu eikä käsikirjoituksen versiota ole julkaistu. <a href=\"{$url}\">Palaa "
"käsikirjoitukseen</a>"
6 changes: 6 additions & 0 deletions locale/fr_CA/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2051,3 +2051,9 @@ msgstr "Soumission acceptée"

msgid "submission.firstPublished"
msgstr "Première publication"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Ceci est un aperçu et n'a pas été publié. <a href=\"{$url}\">Afficher la "
"soumission</a>"
6 changes: 6 additions & 0 deletions locale/fr_FR/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2122,3 +2122,9 @@ msgstr "Catégories"

msgid "submission.submit.includeInBrowse.title"
msgstr "Listes de publications"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Ceci est un aperçu et n'a pas été publié. <a href=\"{$url}\">Voir la "
"soumission</a>"
17 changes: 17 additions & 0 deletions locale/gd_GB/submission.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-06T17:00:00+00:00\n"
"PO-Revision-Date: 2021-05-06 17:00+0000\n"
"submission/gd_GB/>\n"
"Language: gd_GB\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"’S e ro-shealladh a tha seo ’s cha deach fhoillseachadh fhathast. <a href=\""
"{$url}\">Seall an tagradh</a>"
6 changes: 6 additions & 0 deletions locale/id_ID/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2070,3 +2070,9 @@ msgstr ""
"diberitahukan dan akan mengambil tindakan untuk memastikan proses review "
"selesai dilakukan. Anda tidak perlu mengambil langkah apapun saat ini. Anda "
"akan diberitahu bila sudah ada keputusan."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Naskah ini merupakan pratinjau dan belum diterbitkan. <a href=\"{$url}\">"
"Lihat Naskah</a>"
6 changes: 6 additions & 0 deletions locale/it_IT/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2437,3 +2437,9 @@ msgstr "Il round di revisione per la proposta {$title}, e' stato cancellato."

msgid "editor.submission.decision.backFromCopyediting"
msgstr "Annulla il Copyediting"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Questa è una preview non ancora pubblicata <a href=\"{$url}\">Vai "
"all'articolo</a>"
4 changes: 4 additions & 0 deletions locale/ja_JP/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1996,3 +1996,7 @@ msgstr "カテゴリー"

msgid "submission.submit.includeInBrowse.title"
msgstr "出版リスト"

msgstr "全ての編集者推薦が提出され、決定が必要です。"

msgid "submission.viewingPreview"msgstr "これはプレビューであり、公開されていません。 <a href=\"{$url}\">投稿表示</a>"
6 changes: 6 additions & 0 deletions locale/ka_GE/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2459,3 +2459,9 @@ msgstr "ყველა წარდგენის ნახვა"

msgid "category.category"
msgstr "კატეგორიები"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"ეს არის წინასწარი დათვალიერების რეჟიმი, მასალა ჯერ არ გამოქვეყნებულა. <a "
"href=\"{$url}\">მასალის ნახვა</a>"
5 changes: 5 additions & 0 deletions locale/mk_MK/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2132,3 +2132,8 @@ msgstr ""

msgid "submission.query.leaveQuery"
msgstr "Напуштете ја дискусијата"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Ова е преглед кој не е објавен. <a href=\"{$url}\">Види го поднесокот</a>"
5 changes: 5 additions & 0 deletions locale/nb_NO/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2127,3 +2127,8 @@ msgstr ""
"vil ta skritt for å sikre at fagfellevurderingen blir fullført. Du trenger "
"ikke å foreta deg noe på dette tidspunkt. Du får beskjed når det er tatt en "
"beslutning."

msgid "submission.viewingPreview"
msgstr ""
"Dette er en forhåndsvisning og har ikke blitt publisert enda. <a href=\""
"{$url}\">Se innleveringen</a>"
6 changes: 6 additions & 0 deletions locale/pl_PL/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2509,3 +2509,9 @@ msgid "editor.submission.decision.resubmit.completed.description"
msgstr ""
"Została wygenerowana prośba o poprawki dla zgłoszenia {$title}. Zapisano "
"decyzję o wysłaniu poprawek do następnej rundy recenzji."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"To jest wgląd do artykułu, który jeszcze nie był publikowany.<a href=\"{$url}"
"\">Wyświetl zgłoszenie</a>"
4 changes: 4 additions & 0 deletions locale/pt_BR/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2774,3 +2774,7 @@ msgid "log.review.reviewerResendRequest"
msgstr ""
"Reenvie a solicitação de avaliação na rodada {$round} para {$reviewerName} "
"para submissão {$submissionid}."

msgid "submission.viewingPreview"
msgstr ""
"Esta é uma prévia e não foi publicada. <a href=\"{$url}\"> Ver submissão</a>"
5 changes: 5 additions & 0 deletions locale/pt_PT/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2456,3 +2456,8 @@ msgid "log.review.reviewerResendRequest"
msgstr ""
"Reenvie o pedido de revisão da ronda {$round} para {$reviewerName} para a "
"submissão {$submissionid}."

msgid "submission.viewingPreview"
msgstr ""
"Isto é uma visualização prévia e não foi ainda publicado. <a href=\"{$url}\""
">Ver submissão</a>"
2 changes: 2 additions & 0 deletions locale/ru_RU/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1907,3 +1907,5 @@ msgstr "Категории"

msgid "submission.submit.includeInBrowse.title"
msgstr "Списки публикаций"

msgid "submission.viewingPreview"msgstr "Это предварительный просмотр, материал пока не опубликован. <a href=\"{$url}\">Просмотреть материал</a>"
17 changes: 17 additions & 0 deletions locale/sk_SK/submission.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-06 17:00+0000\n"
"PO-Revision-Date: 2021-05-06 12:00+0000\n"
"pkp-lib/submission/sk_SK/>\n"
"Language: sk_SK\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Toto je náhľad – doteraz nebol publikovaný. <a href=\"{$url}\">Zobraziť "
"príspevok</a>"
6 changes: 6 additions & 0 deletions locale/sl_SI/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2413,3 +2413,9 @@ msgid "log.review.reviewerResendRequest"
msgstr ""
"Recenzentu {$reviewerName} ponovno pošjli prošnjo za opravljanje recenzije v "
"recenzijskem krogu {$round} za prispevek {$submissionid}."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"To je le predogled, še ni bilo objavljeno. <a href=\"{$url}\">View "
"submission</a>"
5 changes: 5 additions & 0 deletions locale/sv_SE/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2387,3 +2387,8 @@ msgid "doi.submission.notPublished"
msgstr ""
"Misslyckades med att markera DOI som registrerad för {$pubObjectTitle}. "
"Bidraget måste vara publicerat innan statusen kan uppdateras."

msgid "submission.viewingPreview"
msgstr ""
"Detta är en förhandsvisning och har därmed inte blivit publicerad än. <a "
"href=\"{$url}\">Visa bidrag</a>"
6 changes: 6 additions & 0 deletions locale/tr_TR/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -2421,3 +2421,9 @@ msgstr ""
#, fuzzy
msgid "editor.submission.decision.revertInitialDecline.completed.description"
msgstr "{$title} başlıklı aday makale artık yeni başvuru aşamasında aktiftir."

#, fuzzy
msgid "submission.viewingPreview"
msgstr ""
"Bu bir önizlemedir ve yayınlanmamıştır. <a href=\"{$url}\">Makaleyi "
"görüntüle</a>"

0 comments on commit 3a4dce7

Please sign in to comment.