Skip to content

Commit

Permalink
Merge pull request #8941 from Vitaliy-1/i8933_restore_original
Browse files Browse the repository at this point in the history
pkp/pkp#8933 Restore original file after cancelling file upload wizard
  • Loading branch information
Vitaliy-1 authored Jun 2, 2023
2 parents 841a32d + 25123ae commit a8af7b3
Show file tree
Hide file tree
Showing 59 changed files with 1,701 additions and 832 deletions.
32 changes: 19 additions & 13 deletions api/v1/submissions/PKPSubmissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use APP\core\Request;
use APP\core\Services;
use APP\facades\Repo;
use APP\log\SubmissionEventLogEntry;
use APP\log\event\SubmissionEventLogEntry;
use APP\notification\Notification;
use APP\notification\NotificationManager;
use APP\section\Section;
Expand All @@ -31,11 +31,12 @@
use Illuminate\Support\Facades\Mail;
use PKP\core\APIResponse;
use PKP\core\Core;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\decision\DecisionType;
use PKP\facades\Locale;
use PKP\handler\APIHandler;
use PKP\log\SubmissionLog;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\mail\mailables\PublicationVersionNotify;
use PKP\mail\mailables\SubmissionSavedForLater;
use PKP\notification\NotificationSubscriptionSettingsDAO;
Expand All @@ -48,6 +49,7 @@
use PKP\security\authorization\SubmissionAccessPolicy;
use PKP\security\authorization\UserRolesRequiredPolicy;
use PKP\security\Role;
use PKP\security\Validation;
use PKP\services\PKPSchemaService;
use PKP\stageAssignment\StageAssignmentDAO;
use PKP\submission\GenreDAO;
Expand Down Expand Up @@ -709,17 +711,21 @@ public function submit(SlimRequest $slimRequest, APIResponse $response, array $a
$submission = Repo::submission()->get($submission->getId());

if ($slimRequest->getParsedBodyParam('confirmCopyright')) {
SubmissionLog::logEvent(
Application::get()->getRequest(),
$submission,
SubmissionEventLogEntry::SUBMISSION_LOG_COPYRIGHT_AGREED,
'submission.event.copyrightAgreed',
[
'username' => $request->getUser()->getUsername(),
'name' => $request->getUser()->getFullName(true, false, Locale::getLocale()),
'copyrightNotice' => $context->getLocalizedData('copyrightNotice', Locale::getLocale()),
]
);
$user = $request->getUser();
$eventLog = Repo::eventLog()->newDataObject([
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => PKPSubmissionEventLogEntry::SUBMISSION_LOG_COPYRIGHT_AGREED,
'userId' => Validation::loggedInAs() ?? $user->getId(),
'message' => 'submission.event.copyrightAgreed',
'isTranslated' => false,
'dateLogged' => Core::getCurrentDate(),
'username' => $user->getUsername(),
'userFullName' => $user->getFullName(true, false, Locale::getLocale()),
'copyrightNotice' => $context->getData('copyrightNotice'),
]);

Repo::eventLog()->add($eventLog);
}

$userGroups = Repo::userGroup()
Expand Down
2 changes: 1 addition & 1 deletion classes/announcement/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function validate(?Announcement $object, array $props, array $allowedLoca
]
);

// Check required fields if we're adding a context
// Check required fields
ValidatorFactory::required(
$validator,
$object,
Expand Down
6 changes: 3 additions & 3 deletions classes/category/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public function getSchemaMap(): maps\Schema
}

/**
* Validate properties for an announcement
* Validate properties for a category
*
* Perform validation checks on data used to add or edit an announcement.
* Perform validation checks on data used to add or edit a category.
*
* @param array $props A key/value array with the new data to validate
* @param array $allowedLocales The context's supported locales
Expand All @@ -126,7 +126,7 @@ public function validate(?Category $object, array $props, array $allowedLocales,
[]
);

// Check required fields if we're adding a context
// Check required fields
ValidatorFactory::required(
$validator,
$object,
Expand Down
52 changes: 29 additions & 23 deletions classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use APP\core\PageRouter;
use APP\core\Request;
use APP\facades\Repo;
use APP\log\SubmissionEventLogEntry;
use APP\log\event\SubmissionEventLogEntry;
use APP\notification\NotificationManager;
use APP\submission\Submission;
use APP\template\TemplateManager;
Expand All @@ -46,6 +46,7 @@
use PKP\facades\Locale;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionLog;
use PKP\mail\Mailable;
use PKP\mail\mailables\ReviewerReinstate;
Expand All @@ -62,6 +63,7 @@
use PKP\security\authorization\internal\ReviewRoundRequiredPolicy;
use PKP\security\authorization\WorkflowStageAccessPolicy;
use PKP\security\Role;
use PKP\security\Validation;
use PKP\submission\reviewAssignment\ReviewAssignment;
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
use PKP\submission\reviewRound\ReviewRound;
Expand Down Expand Up @@ -682,17 +684,19 @@ public function unconsiderReview($args, $request)
$reviewAssignmentDao->updateObject($reviewAssignment);

// log the unconsider.
SubmissionLog::logEvent(
$request,
$submission,
SubmissionEventLogEntry::SUBMISSION_LOG_REVIEW_UNCONSIDERED,
'log.review.reviewUnconsidered',
[
'editorName' => $user->getFullName(),
'submissionId' => $submission->getId(),
'round' => $reviewAssignment->getRound(),
]
);
$eventLog = Repo::eventLog()->newDataObject([
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => PKPSubmissionEventLogEntry::SUBMISSION_LOG_REVIEW_UNCONSIDERED,
'userId' => Validation::loggedInAs() ?? $user->getId(),
'message' => 'log.review.reviewUnconsidered',
'isTranslated' => false,
'dateLogged' => Core::getCurrentDate(),
'editorName' => $user->getFullName(),
'submissionId' => $submission->getId(),
'round' => $reviewAssignment->getRound(),
]);
Repo::eventLog()->add($eventLog);

return DAO::getDataChangedEvent($reviewAssignment->getId());
}
Expand Down Expand Up @@ -745,17 +749,19 @@ public function reviewRead($args, $request)
$submissionId = $reviewAssignment->getSubmissionId();
$submission = Repo::submission()->get($submissionId);

SubmissionLog::logEvent(
$request,
$submission,
SubmissionEventLogEntry::SUBMISSION_LOG_REVIEW_CONFIRMED,
'log.review.reviewConfirmed',
[
'userName' => $user->getFullName(),
'submissionId' => $reviewAssignment->getSubmissionId(),
'round' => $reviewAssignment->getRound()
]
);
$eventLog = Repo::eventLog()->newDataObject([
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => PKPSubmissionEventLogEntry::SUBMISSION_LOG_REVIEW_CONFIRMED,
'userId' => Validation::loggedInAs() ?? $user->getId(),
'message' => 'log.review.reviewConfirmed',
'isTranslated' => false,
'dateLogged' => Core::getCurrentDate(),
'editorName' => $user->getFullName(),
'submissionId' => $reviewAssignment->getSubmissionId(),
'round' => $reviewAssignment->getRound()
]);
Repo::eventLog()->add($eventLog);
}
// Remove the reviewer task.
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
Expand Down
2 changes: 0 additions & 2 deletions classes/core/PKPApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ public function getDAOMap()
'SubmissionDisciplineDAO' => 'PKP\submission\SubmissionDisciplineDAO',
'SubmissionDisciplineEntryDAO' => 'PKP\submission\SubmissionDisciplineEntryDAO',
'SubmissionEmailLogDAO' => 'PKP\log\SubmissionEmailLogDAO',
'SubmissionEventLogDAO' => 'PKP\log\SubmissionEventLogDAO',
'SubmissionFileEventLogDAO' => 'PKP\log\SubmissionFileEventLogDAO',
'QueryDAO' => 'PKP\query\QueryDAO',
'SubmissionLanguageDAO' => 'PKP\submission\SubmissionLanguageDAO',
'SubmissionLanguageEntryDAO' => 'PKP\submission\SubmissionLanguageEntryDAO',
Expand Down
2 changes: 1 addition & 1 deletion classes/db/DBDataXMLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function parseData($file)
if ($column) {
$this->sql = array_merge($this->sql, array_column(DB::pretend(function () use ($table, $column) {
Schema::table($table, function (Blueprint $table) use ($column) {
$table->dropColumn('column');
$table->dropColumn($column);
});
}), 'query'));
} else {
Expand Down
26 changes: 13 additions & 13 deletions classes/decision/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
use Illuminate\Support\Facades\App;
use PKP\context\Context;
use PKP\core\Core;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\log\PKPSubmissionEventLogEntry;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionLog;
use PKP\observers\events\DecisionAdded;
use PKP\plugins\Hook;
use PKP\security\Role;
use PKP\security\Validation;
use PKP\services\PKPSchemaService;
use PKP\stageAssignment\StageAssignment;
use PKP\stageAssignment\StageAssignmentDAO;
Expand Down Expand Up @@ -228,20 +230,18 @@ public function add(Decision $decision): int
}

// Log the decision
SubmissionLog::logEvent(
$this->request,
$submission,
$this->isRecommendation($decisionType->getDecision())
$eventLog = Repo::eventLog()->newDataObject([
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => $this->isRecommendation($decisionType->getDecision())
? PKPSubmissionEventLogEntry::SUBMISSION_LOG_EDITOR_RECOMMENDATION
: PKPSubmissionEventLogEntry::SUBMISSION_LOG_EDITOR_DECISION,
$decisionType->getLog(),
[
'editorId' => $editor->getId(),
'editorName' => $editor->getFullName(),
'submissionId' => $decision->getData('submissionId'),
'decision' => $decisionType->getDecision(),
]
);
'userId' => Validation::loggedInAs() ?? $this->request->getUser()?->getId(),
'message' => $decisionType->getLog(),
'isTranslated' => false,
'dateLogged' => Core::getCurrentDate()
]);
Repo::eventLog()->add($eventLog);

// Allow the decision type to perform additional actions
$decisionType->runAdditionalActions($decision, $submission, $editor, $context, $actions);
Expand Down
27 changes: 16 additions & 11 deletions classes/decision/types/traits/NotifyReviewers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@

use APP\core\Application;
use APP\facades\Repo;
use APP\log\SubmissionEventLogEntry;
use APP\log\event\SubmissionEventLogEntry;
use APP\submission\Submission;
use Illuminate\Support\Facades\Mail;
use Illuminate\Validation\Validator;
use PKP\core\Core;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionLog;
use PKP\mail\EmailData;
use PKP\mail\mailables\DecisionNotifyReviewer;
use PKP\mail\mailables\ReviewerUnassign;
use PKP\security\Validation;
use PKP\submission\reviewAssignment\ReviewAssignment;
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
use PKP\user\User;
Expand Down Expand Up @@ -62,16 +65,18 @@ protected function sendReviewersEmail(DecisionNotifyReviewer|ReviewerUnassign $m
}
}

SubmissionLog::logEvent(
Application::get()->getRequest(),
$submission,
SubmissionEventLogEntry::SUBMISSION_LOG_DECISION_EMAIL_SENT,
'submission.event.decisionReviewerEmailSent',
[
'recipientCount' => count($recipients),
'subject' => $email->subject,
]
);
$eventLog = Repo::eventLog()->newDataObject([
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => PKPSubmissionEventLogEntry::SUBMISSION_LOG_DECISION_EMAIL_SENT,
'userId' => Validation::loggedInAs() ?? Application::get()->getRequest()->getUser()?->getId(),
'message' => 'submission.event.decisionReviewerEmailSent',
'isTranslated' => false,
'dateLogged' => Core::getCurrentDate(),
'recipientCount' => count($recipients),
'subject' => $email->subject,
]);
Repo::eventLog()->add($eventLog);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions classes/facades/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use PKP\job\repositories\Job as JobRepository;
use PKP\submissionFile\Repository as SubmissionFileRepository;
use PKP\userGroup\Repository as UserGroupRepository;
use PKP\log\event\Repository as EventLogRepository;

class Repo
{
Expand Down Expand Up @@ -86,4 +87,9 @@ public static function userGroup(): UserGroupRepository
{
return app(UserGroupRepository::class);
}

public static function eventLog(): EventLogRepository
{
return app(EventLogRepository::class);
}
}
2 changes: 1 addition & 1 deletion classes/galley/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function validate(?Galley $object, array $props, array $allowedLocales, s
]
);

// Check required fields if we're adding a context
// Check required fields
ValidatorFactory::required(
$validator,
$object,
Expand Down
Loading

0 comments on commit a8af7b3

Please sign in to comment.