From 0214bdb8048dd3a58061c75ddcdcad3b6489fb23 Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Thu, 25 Apr 2024 14:44:33 +0200 Subject: [PATCH] pkp/pkp-lib#9914 editorial history public page --- locale/en/common.po | 3 + pages/about/AboutContextHandler.php | 85 +++++++++++++++++++ pages/about/index.php | 1 + templates/frontend/pages/editorialHistory.tpl | 45 ++++++++++ .../frontend/pages/editorialMasthead.tpl | 6 ++ 5 files changed, 140 insertions(+) create mode 100644 templates/frontend/pages/editorialHistory.tpl diff --git a/locale/en/common.po b/locale/en/common.po index 57b7d5d6f75..dadb88c62a1 100644 --- a/locale/en/common.po +++ b/locale/en/common.po @@ -157,6 +157,9 @@ msgstr "Peer Reviewers" msgid "common.editorialMasthead.peerReviewers.description" msgstr "The editors express their appreciation of the reviewers for {$year} listed below." +msgid "common.editorialHistory" +msgstr "Editorial History" + msgid "common.name" msgstr "Name" diff --git a/pages/about/AboutContextHandler.php b/pages/about/AboutContextHandler.php index d616dc66fb8..8e83df10fe4 100644 --- a/pages/about/AboutContextHandler.php +++ b/pages/about/AboutContextHandler.php @@ -21,10 +21,12 @@ use APP\handler\Handler; use APP\template\TemplateManager; use DateTime; +use PKP\facades\Locale; use PKP\plugins\Hook; use PKP\security\authorization\ContextRequiredPolicy; use PKP\security\Role; use PKP\userGroup\relationships\enums\UserUserGroupMastheadStatus; +use PKP\userGroup\relationships\enums\UserUserGroupStatus; use PKP\userGroup\relationships\UserUserGroup; class AboutContextHandler extends Handler @@ -138,6 +140,89 @@ public function editorialMasthead($args, $request) $templateMgr->display('frontend/pages/editorialMasthead.tpl'); } + /** + * Display editorial history page. + * + * @param array $args + * @param \PKP\core\PKPRequest $request + * + * @hook AboutContextHandler::editorialHistory [[$mastheadRoles, $mastheadUsers]] + */ + public function editorialHistory($args, $request) + { + $context = $request->getContext(); + + $savedMastheadUserGroupIdsOrder = (array) $context->getData('mastheadUserGroupIds'); + + $collector = Repo::userGroup()->getCollector(); + $allMastheadUserGroups = $collector + ->filterByContextIds([$context->getId()]) + ->filterByMasthead(true) + ->orderBy($collector::ORDERBY_ROLE_ID) + ->getMany() + ->toArray(); + + // sort the masthead roles in their saved order for display + $mastheadRoles = array_replace(array_flip($savedMastheadUserGroupIdsOrder), $allMastheadUserGroups); + + $mastheadUsers = []; + foreach ($mastheadRoles as $mastheadUserGroup) { + if ($mastheadUserGroup->getRoleId() == Role::ROLE_ID_REVIEWER) { + continue; + } + // Get all users that were active and are not active any more in the given role + // and that have accepted to be displayed on the masthead for that role. + // No need to filter by context ID, because the user groups are already filtered so. + $usersCollector = Repo::user()->getCollector(); + $users = $usersCollector + ->filterByUserGroupIds([$mastheadUserGroup->getId()]) + ->filterByUserUserGroupStatus(UserUserGroupStatus::STATUS_ENDED) + ->filterByUserUserGroupMastheadStatus(UserUserGroupMastheadStatus::STATUS_ON) + ->orderBy($usersCollector::ORDERBY_FAMILYNAME, $usersCollector::ORDER_DIR_ASC, [Locale::getLocale(), Application::get()->getRequest()->getSite()->getPrimaryLocale()]) + ->getMany(); + + foreach ($users as $user) { + $userUserGroups = UserUserGroup::withUserId($user->getId()) + ->withUserGroupId($mastheadUserGroup->getId()) + ->withEnded() + ->withMasthead() + ->get(); + $services = []; + foreach ($userUserGroups as $userUserGroup) { + $startDatetime = new DateTime($userUserGroup->dateStart); + $endDatetime = new DateTime($userUserGroup->dateEnd); + $services[] = [ + 'dateStart' => $startDatetime->format('Y'), + 'dateEnd' => $endDatetime->format('Y'), + ]; + } + if (!empty($services)) { + $mastheadUsers[$mastheadUserGroup->getId()][$user->getId()] = [ + 'user' => $user, + 'services' => $services + ]; + } + + } + } + + Hook::call('AboutContextHandler::editorialHistory', [$mastheadRoles, $mastheadUsers]); + + // To come after https://github.com/pkp/pkp-lib/issues/9771 + // $orcidIcon = OrcidManager::getIcon(); + $orcidIcon = ''; + + $templateMgr = TemplateManager::getManager($request); + $this->setupTemplate($request); + $templateMgr->assign([ + 'mastheadRoles' => $mastheadRoles, + 'mastheadUsers' => $mastheadUsers, + 'orcidIcon' => $orcidIcon + ]); + $templateMgr->display('frontend/pages/editorialHistory.tpl'); + } + + /** * Display editorialTeam page. * diff --git a/pages/about/index.php b/pages/about/index.php index 8fdbf33b381..2938fadcdbc 100644 --- a/pages/about/index.php +++ b/pages/about/index.php @@ -20,6 +20,7 @@ switch ($op) { case 'index': case 'editorialMasthead': + case 'editorialHistory': case 'editorialTeam': case 'submissions': case 'contact': diff --git a/templates/frontend/pages/editorialHistory.tpl b/templates/frontend/pages/editorialHistory.tpl new file mode 100644 index 00000000000..44ee26d0455 --- /dev/null +++ b/templates/frontend/pages/editorialHistory.tpl @@ -0,0 +1,45 @@ +{** + * templates/frontend/pages/editorialHistory.tpl + * + * Copyright (c) 2024 Simon Fraser University + * Copyright (c) 2024 John Willinsky + * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. + * + * @brief Display journal's editorial history page. + * + *} +{include file="frontend/components/header.tpl" pageTitle="common.editorialHistory"} + +
+ {include file="frontend/components/breadcrumbs.tpl" currentTitleKey="common.editorialHistory"} + +

{translate key="common.editorialHistory"}

+ {foreach from=$mastheadRoles item="mastheadRole"} + {if array_key_exists($mastheadRole->getId(), $mastheadUsers)} +

{$mastheadRole->getLocalizedName()|escape}

+ + {/if} + {/foreach} +
+ +{include file="frontend/components/footer.tpl"} diff --git a/templates/frontend/pages/editorialMasthead.tpl b/templates/frontend/pages/editorialMasthead.tpl index a96cc140332..105576087c1 100644 --- a/templates/frontend/pages/editorialMasthead.tpl +++ b/templates/frontend/pages/editorialMasthead.tpl @@ -39,6 +39,12 @@ {/if} {/foreach} +

+ + {translate key="common.editorialHistory"} + +

+ {if !empty($reviewers)}

{translate key="common.editorialMasthead.peerReviewers"}

{translate key="common.editorialMasthead.peerReviewers.description" year=$previousYear}