Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp#8933 Restore original file after cancelling file upload wizard #8941

Merged
merged 22 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7f93ddb
pkp/pkp-lib#8933 Restore original file after cancelling file upload w…
Vitaliy-1 Apr 24, 2023
1365309
pkp/pkp-lib#8933 Refactor event log to restore revised submission file
Vitaliy-1 May 17, 2023
2608759
pkp/pkp-lib#8933 Fix migration errors
Vitaliy-1 May 20, 2023
6d158c3
pkp/pkp-lib#8933 Fix indent
Vitaliy-1 May 22, 2023
9fa310f
pkp/pkp-lib#8933 Fix migration - nullable setting_type & inserting em…
Vitaliy-1 May 22, 2023
96493ff
pkp/pkp-lib#8933 Fix migration - get the correct context primary locale
Vitaliy-1 May 25, 2023
25799d4
pkp/pkp-lib#8933 Make is_translated boolean
Vitaliy-1 May 26, 2023
067f41c
pkp/pkp-lib#8933 Re-add Validation::isLoggedInAs()
Vitaliy-1 May 26, 2023
f760cde
pkp/pkp-lib#8933 Combine filterByAssocType & filterByAssocId
Vitaliy-1 May 26, 2023
c58ab9f
pkp/pkp-lib#8933 Remove support for custom props
Vitaliy-1 May 26, 2023
16cef3c
pkp/pkp-lib#8933 generic event log property for custom data
Vitaliy-1 May 26, 2023
cc86ccb
pkp/pkp-lib#8933 Update comments
Vitaliy-1 May 26, 2023
2f9ddea
pkp/pkp-lib#8933 Pass Context to event log Repository::validate()
Vitaliy-1 May 28, 2023
ed6f893
pkp/pkp-lib#8933 Event log is never updated
Vitaliy-1 May 28, 2023
c73c18a
pkp/pkp-lib#8933 Fix extra indent
Vitaliy-1 May 28, 2023
ec8efe2
pkp/pkp-lib#8933 Update docs
Vitaliy-1 May 28, 2023
10c8e61
pkp/pkp-lib#8933 Looser validation for logged decision values
Vitaliy-1 May 28, 2023
7c4f9cd
pkp/pkp-lib#8933 Force cast int on original file ID
Vitaliy-1 May 28, 2023
c2daeed
pkp/pkp-lib#8933 Optimize migration performance
Vitaliy-1 May 29, 2023
8942fe6
pkp/pkp-lib#8933 Change isTranslated to boolean false when creating a…
Vitaliy-1 May 30, 2023
51a74e9
pkp/pkp-lib#8933 Remove setting_type column
Vitaliy-1 May 30, 2023
25123ae
pkp/pkp-lib#8933 Optimize event log migration performance
Vitaliy-1 May 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
{
Vitaliy-1 marked this conversation as resolved.
Show resolved Hide resolved
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