Skip to content

Commit

Permalink
Merge branch 'fixEmailToAuthors330-737' into 'stable-3_3_0'
Browse files Browse the repository at this point in the history
Corrige problema ao tentar excluir versão

See merge request softwares-pkp/plugins_ojs/authorVersion!19
  • Loading branch information
JhonathanLepidus committed Jan 20, 2025
2 parents 4d1a3fa + 4f9721b commit 364f92c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions AuthorVersionPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public function addWorkflowModifications($hookName, $params)
$request = PKPApplication::get()->getRequest();
$requestedPage = $templateMgr->getTemplateVars('requestedPage');

if($requestedPage == 'authorDashboard') {
if ($requestedPage == 'authorDashboard') {
$templateMgr->registerFilter("output", array($this, 'addVersionJustificationButtonFilter'));
}

if($requestedPage == 'workflow') {
if ($requestedPage == 'workflow') {
$templateMgr->registerFilter("output", array($this, 'addVersionJustificationButtonFilter'));
$templateMgr->registerFilter("output", array($this, 'addDeleteVersionButtonFilter'));
}
Expand Down
28 changes: 18 additions & 10 deletions api/v1/authorVersion/AuthorVersionHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function submitVersion($slimRequest, $response, $args)
$submission = $this->getSubmission($slimRequest);
$publication = $submission->getLatestPublication();

if(!is_null($publication->getData('versionJustification'))
if (!is_null($publication->getData('versionJustification'))
|| $publication->getData('status') == STATUS_PUBLISHED
|| $publication->getData('version') == 1
) {
Expand All @@ -74,7 +74,7 @@ public function deleteVersion($slimRequest, $response, $args)
$submission = $this->getSubmission($slimRequest);
$publication = $submission->getLatestPublication();

if($publication->getData('status') == STATUS_PUBLISHED or $publication->getData('version') == 1) {
if ($publication->getData('status') == STATUS_PUBLISHED or $publication->getData('version') == 1) {
return $response->withStatus(400);
}

Expand All @@ -91,7 +91,7 @@ public function updateVersionJustification($slimRequest, $response, $args)
$submission = $this->getSubmission($slimRequest);
$publication = $submission->getLatestPublication();

if($publication->getData('status') == STATUS_PUBLISHED || $publication->getData('version') == 1) {
if ($publication->getData('status') == STATUS_PUBLISHED || $publication->getData('version') == 1) {
return $response->withStatus(400);
}

Expand Down Expand Up @@ -119,13 +119,21 @@ private function sendSubmittedVersionEmail($publication, $versionJustification)

private function sendDeletedVersionEmail($publication, $deletingJustification)
{
if (empty($authors)) {
return;
}

$request = $this->getRequest();
$context = $request->getContext();

$emailTemplate = 'DELETED_VERSION_NOTIFICATION';
$primaryAuthor = $publication->getPrimaryAuthor();
$recipientAuthor = $publication->getPrimaryAuthor();

if (!$recipientAuthor) {
$recipientAuthor = $publication->getData('authors')[0];
}

$recipients = [
['email' => $primaryAuthor->getData('email'), 'name' => $primaryAuthor->getFullName()]
['email' => $recipientAuthor->getData('email'), 'name' => $recipientAuthor->getFullName()]
];

$params = [
Expand All @@ -145,7 +153,7 @@ private function sendEmailTemplate(string $templateName, array $recipients, arra
$email = new MailTemplate($templateName, null, $context, false);
$email->setFrom($context->getData('contactEmail'), $context->getData('contactName'));

foreach($recipients as $recipient) {
foreach ($recipients as $recipient) {
$email->addRecipient($recipient['email'], $recipient['name']);
}

Expand All @@ -171,7 +179,7 @@ private function getManagersAssigned($publication): array
while ($assignment = $allAssignments->next()) {
$userId = $assignment->getUserId();

if($this->userIsManager($userId)) {
if ($this->userIsManager($userId)) {
$manager = $userDao->getById($userId);
$managers[] = [
'email' => $manager->getEmail(),
Expand All @@ -189,8 +197,8 @@ private function userIsManager($userId): bool
$userGroupsOfUser = $userGroupDao->getByUserId($userId);
$managerGroupName = 'preprint server manager';

while($userGroup = $userGroupsOfUser->next()) {
if(strtolower($userGroup->getName('en_US')) == $managerGroupName) {
while ($userGroup = $userGroupsOfUser->next()) {
if (strtolower($userGroup->getName('en_US')) == $managerGroupName) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function appGet($q)
->where('setting_name', '=', 'versionJustification');
};

if($this->submittedVersion) {
if ($this->submittedVersion) {
$q->whereIn('nvp.publication_id', $submittedVersionSubQuery);
} else {
$q->whereNotIn('nvp.publication_id', $submittedVersionSubQuery);
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @defgroup plugins_generic_authorVersion
*/
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<version>
<application>authorVersion</application>
<type>plugins.generic</type>
<release>1.5.4.0</release>
<date>2024-08-12</date>
<release>1.5.5.0</release>
<date>2025-01-20</date>
<lazy-load>1</lazy-load>
<class>AuthorVersionPlugin</class>
</version>

0 comments on commit 364f92c

Please sign in to comment.