Skip to content

Commit

Permalink
#8933 Refactor event log to restore revised submission file
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed May 19, 2023
1 parent 5599093 commit 5383bf9
Show file tree
Hide file tree
Showing 54 changed files with 1,751 additions and 854 deletions.
30 changes: 18 additions & 12 deletions api/v1/submissions/PKPSubmissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\PKPSubmission;
Expand Down Expand Up @@ -708,17 +710,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' => 0,
'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
4 changes: 2 additions & 2 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 Down
50 changes: 28 additions & 22 deletions classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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 @@ -57,6 +58,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 @@ -675,17 +677,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' => 0,
'dateLogged' => Core::getCurrentDate(),
'editorName' => $user->getFullName(),
'submissionId' => $submission->getId(),
'round' => $reviewAssignment->getRound(),
]);
Repo::eventLog()->add($eventLog);

return \PKP\db\DAO::getDataChangedEvent($reviewAssignment->getId());
}
Expand Down Expand Up @@ -738,17 +742,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' => 0,
'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\submission\reviewRound\ReviewRoundDAO;
use PKP\submissionFile\SubmissionFile;
Expand Down Expand Up @@ -226,20 +228,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' => 0,
'dateLogged' => Core::getCurrentDate()
]);
Repo::eventLog()->add($eventLog);

// Allow the decision type to perform additional actions
$decisionType->runAdditionalActions($decision, $submission, $editor, $context, $actions);
Expand Down
25 changes: 15 additions & 10 deletions classes/decision/types/traits/NotifyReviewers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
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' => 0,
'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);
}
}
Loading

0 comments on commit 5383bf9

Please sign in to comment.