Skip to content

Commit

Permalink
pkp#9860 Public masthead page
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Apr 29, 2024
1 parent 1b2cd55 commit 3a42201
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @ingroup classes_controllers_form
*
* @brief A form for defining in which order the masthead roles should be displayed.
* @brief A form for defining in which order the editorial masthead roles should be displayed.
*/

namespace PKP\components\forms\context;
Expand Down Expand Up @@ -63,8 +63,8 @@ public function __construct($action, $locales, $context)
}

$this->addField(new FieldOptions('mastheadUserGroupIds', [
'label' => __('manager.setup.masthead'),
'description' => __('manager.setup.masthead.description'),
'label' => __('common.editorialMasthead'),
'description' => __('manager.setup.editorialMasthead.description'),
'isOrderable' => true,
'value' => array_column($mastheadOptions, 'value'),
'options' => $mastheadOptions,
Expand Down
2 changes: 2 additions & 0 deletions classes/navigationMenu/NavigationMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class NavigationMenuItem extends \PKP\core\DataObject
// Types for all default navigationMenuItems
public const NMI_TYPE_ABOUT = 'NMI_TYPE_ABOUT';
public const NMI_TYPE_SUBMISSIONS = 'NMI_TYPE_SUBMISSIONS';
public const NMI_TYPE_MASTHEAD = 'NMI_TYPE_MASTHEAD';
public const NMI_TYPE_EDITORIAL_TEAM = 'NMI_TYPE_EDITORIAL_TEAM';
public const NMI_TYPE_CONTACT = 'NMI_TYPE_CONTACT';
public const NMI_TYPE_ANNOUNCEMENTS = 'NMI_TYPE_ANNOUNCEMENTS';
Expand Down Expand Up @@ -311,6 +312,7 @@ class_alias('\PKP\navigationMenu\NavigationMenuItem', '\NavigationMenuItem');
foreach ([
'NMI_TYPE_ABOUT',
'NMI_TYPE_SUBMISSIONS',
'NMI_TYPE_MASTHEAD',
'NMI_TYPE_EDITORIAL_TEAM',
'NMI_TYPE_CONTACT',
'NMI_TYPE_ANNOUNCEMENTS',
Expand Down
20 changes: 17 additions & 3 deletions classes/services/PKPNavigationMenuService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function getMenuItemTypes()
'description' => __('manager.navigationMenus.about.description'),
'conditionalWarning' => __('manager.navigationMenus.about.conditionalWarning'),
],
NavigationMenuItem::NMI_TYPE_MASTHEAD => [
'title' => __('common.editorialMasthead'),
'description' => __('manager.navigationMenus.editorialMasthead.description'),
],
NavigationMenuItem::NMI_TYPE_EDITORIAL_TEAM => [
'title' => __('about.editorialTeam'),
'description' => __('manager.navigationMenus.editorialTeam.description'),
Expand Down Expand Up @@ -252,6 +256,16 @@ public function getDisplayStatus(&$navigationMenuItem, &$navigationMenu)
null
));
break;
case NavigationMenuItem::NMI_TYPE_MASTHEAD:
$navigationMenuItem->setUrl($dispatcher->url(
$request,
PKPApplication::ROUTE_PAGE,
null,
'about',
'editorialMasthead',
null
));
break;
case NavigationMenuItem::NMI_TYPE_EDITORIAL_TEAM:
$navigationMenuItem->setUrl($dispatcher->url(
$request,
Expand Down Expand Up @@ -654,9 +668,9 @@ public function _callbackHandleCustomNavigationMenuItems($hookName, $args)
{
$request = Application::get()->getRequest();

$page = & $args[0];
$op = & $args[1];
$handler = & $args[3];
$page = &$args[0];
$op = &$args[1];
$handler = &$args[3];

// Construct a path to look for
$path = $page;
Expand Down
19 changes: 19 additions & 0 deletions classes/submission/reviewAssignment/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,23 @@ public function delete(ReviewAssignment $reviewAssignment)
{
parent::_delete($reviewAssignment);
}

/**
* Get IDs of the reviewers that have completed a reivew for the given context in the given year.
*
* @return Collection<int,int>
*/
public function getReviewerIdsByCompletedYear(int $contextId, string $year): Collection
{
return DB::table($this->table)
->whereIn(
'submission_id',
fn (Builder $q) => $q
->select('s.submission_id')
->from('submissions as s')
->where('s.context_id', $contextId)
)
->whereYear('date_completed', $year)
->pluck('reviewer_id');
}
}
11 changes: 11 additions & 0 deletions classes/submission/reviewAssignment/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use APP\core\Application;
use APP\core\Request;
use APP\facades\Repo;
use Illuminate\Support\Collection;
use PKP\context\Context;
use PKP\db\DAORegistry;
use PKP\notification\NotificationDAO;
Expand Down Expand Up @@ -259,4 +260,14 @@ protected function updateReviewRoundStatus(ReviewAssignment $reviewAssignment):

return false;
}

/**
* @copydoc DAO::getReviewerIdsByCompletedYear()
*
* @return Collection<int,int>
*/
public function getReviewerIdsByCompletedYear(int $contextId, string $year): Collection
{
return $this->dao->getReviewerIdsByCompletedYear($contextId, $year);
}
}
9 changes: 9 additions & 0 deletions locale/en/common.po
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ msgstr "Attach Files"
msgid "common.attachSelected"
msgstr "Attach Selected"

msgid "common.editorialMasthead"
msgstr "Editorial Masthead"

msgid "common.editorialMasthead.peerReviewers"
msgstr "Peer Reviewers"

msgid "common.editorialMasthead.peerReviewers.description"
msgstr "The editors express their appreciation of the reviewers for {$year} listed below."

msgid "common.name"
msgstr "Name"

Expand Down
7 changes: 5 additions & 2 deletions locale/en/manager.po
Original file line number Diff line number Diff line change
Expand Up @@ -1860,8 +1860,8 @@ msgstr "Yes, require submitting authors to upload one or more of these files."
msgid "manager.setup.genres.submitRequired.no"
msgstr "No, allow new submissions without these files."

msgid "manager.setup.masthead.description"
msgstr "Define the order of masthead roles for public display."
msgid "manager.setup.editorialMasthead.description"
msgstr "Define the order of editorial masthead roles for public display."

msgid "manager.settings.wizard"
msgstr "Settings Wizard"
Expand Down Expand Up @@ -2429,6 +2429,9 @@ msgstr ""
"This link will only be displayed if you have filled out the Editorial Team "
"section under Settings > Journal."

msgid "manager.navigationMenus.editorialMasthead.description"
msgstr "Link to a page displaying all active editorial masthead services."

msgid "manager.navigationMenus.submissions.description"
msgstr "Link to the page displaying submission instructions."

Expand Down
82 changes: 82 additions & 0 deletions pages/about/AboutContextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
use APP\facades\Repo;
use APP\handler\Handler;
use APP\template\TemplateManager;
use DateTime;
use PKP\plugins\Hook;
use PKP\security\authorization\ContextRequiredPolicy;
use PKP\security\Role;
use PKP\userGroup\relationships\enums\UserUserGroupMastheadStatus;
use PKP\userGroup\relationships\UserUserGroup;

class AboutContextHandler extends Handler
{
Expand Down Expand Up @@ -53,6 +57,84 @@ public function index($args, $request)
$templateMgr->display('frontend/pages/about.tpl');
}

/**
* Display editorial masthead page.
*
* @param array $args
* @param \PKP\core\PKPRequest $request
*
* @hook AboutContextHandler::masthead [[$mastheadRoles, $mastheadUsers, $reviewers, $previousYear]]
* @hook AboutContextHandler::editorialMasthead [[$mastheadRoles, $mastheadUsers, $reviewers, $previousYear]]
*/
public function editorialMasthead($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) {
// Get all users that are active 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.
$users = Repo::user()
->getCollector()
->filterByUserGroupIds([$mastheadUserGroup->getId()])
->filterByUserUserGroupMastheadStatus(UserUserGroupMastheadStatus::STATUS_ON)
->getMany();
foreach ($users as $user) {
$userUserGroup = UserUserGroup::withUserId($user->getId())
->withUserGroupId($mastheadUserGroup->getId())
->withActive()
->withMasthead()
->first();
if ($userUserGroup) {
$startDatetime = new DateTime($userUserGroup->dateStart);
$mastheadUsers[$mastheadUserGroup->getId()][$user->getId()] = [
'user' => $user,
'dateStart' => $startDatetime->format('Y'),
];
}
}
}

$previousYear = date('Y') - 1;
$reviewerIds = Repo::reviewAssignment()->getReviewerIdsByCompletedYear($context->getId(), $previousYear);
$reviewers = Repo::user()
->getCollector()
->filterByUserIds($reviewerIds->toArray())
->getMany()
->all();

Hook::call('AboutContextHandler::editorialMasthead', [$mastheadRoles, $mastheadUsers, $reviewers, $previousYear]);

// 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,
'reviewers' => $reviewers,
'previousYear' => $previousYear,
'orcidIcon' => $orcidIcon
]);
$templateMgr->display('frontend/pages/editorialMasthead.tpl');
}

/**
* Display editorialTeam page.
*
Expand Down
1 change: 1 addition & 0 deletions pages/about/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

switch ($op) {
case 'index':
case 'editorialMasthead':
case 'editorialTeam':
case 'submissions':
case 'contact':
Expand Down
55 changes: 55 additions & 0 deletions templates/frontend/pages/editorialMasthead.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{**
* templates/frontend/pages/editorialMasthead.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 masthead page.
*
*}
{include file="frontend/components/header.tpl" pageTitle="common.editorialMasthead"}

<div class="page page_masthead">
{include file="frontend/components/breadcrumbs.tpl" currentTitleKey="common.editorialMasthead"}

<h1>{translate key="common.editorialMasthead"}</h1>
{foreach from=$mastheadRoles item="mastheadRole"}
{if $mastheadRole->getRoleId() != \PKP\security\Role::ROLE_ID_REVIEWER}
{if array_key_exists($mastheadRole->getId(), $mastheadUsers)}
<h2>{$mastheadRole->getLocalizedName()|escape}</h2>
<ul>
{foreach from=$mastheadUsers[$mastheadRole->getId()] item="mastheadUser"}
<li>
{$mastheadUser['user']->getFullName()|escape},
{$mastheadUser['user']->getLocalizedData('affiliation')|escape},
{$mastheadUser['dateStart']}
{if $mastheadUser['user']->getData('orcid')}
<span class="orcid">
{if $mastheadUser['user']->getData('orcidAccessToken')}
{$orcidIcon}
{/if}
<a href="{$mastheadUser['user']->getData('orcid')|escape}" target="_blank">
{$mastheadUser['user']->getData('orcid')|escape}
</a>
</span>
{/if}
</li>
{/foreach}
</ul>
{/if}
{/if}
{/foreach}

{if !empty($reviewers)}
<h2>{translate key="common.editorialMasthead.peerReviewers"}</h2>
<p>{translate key="common.editorialMasthead.peerReviewers.description" year=$previousYear}</p>
<ul>
{foreach from=$reviewers item="reviewer"}
<li>{$reviewer->getFullName()|escape}</li>
{/foreach}
</ul>
{/if}
</div><!-- .page -->

{include file="frontend/components/footer.tpl"}
2 changes: 1 addition & 1 deletion templates/management/website.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@set="set"
/>
</tab>
<tab id="appearance-masthead" label="{translate key="manager.setup.masthead"}">
<tab id="appearance-masthead" label="{translate key="common.editorialMasthead"}">
<pkp-form
v-bind="components.{$smarty.const.FORM_APPEARANCE_MASTHEAD}"
@set="set"
Expand Down

0 comments on commit 3a42201

Please sign in to comment.