diff --git a/classes/components/listPanels/PKPSelectReviewerListPanel.php b/classes/components/listPanels/PKPSelectReviewerListPanel.php index 754cfea9867..906dfbbbfcc 100644 --- a/classes/components/listPanels/PKPSelectReviewerListPanel.php +++ b/classes/components/listPanels/PKPSelectReviewerListPanel.php @@ -128,7 +128,7 @@ public function getConfig() ->toArray(); $contextId = $this->getParams['contextId']; foreach ($reviewers as $key => $reviewer) { - $userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($reviewer->getId(), $contextId); + $userPrivateNote = Repo::userPrivateNote()->getUserPrivateNote($reviewer->getId(), $contextId); $reviewers[$key]['userPrivateNote'] = $userPrivateNote?->getNote(); } $config['lastRoundReviewers'] = $reviewers; @@ -182,7 +182,7 @@ public function getItems($request) $contextId = $request->getContext()->getId(); foreach ($reviewers as $reviewer) { $item = $map->summarizeReviewer($reviewer); - $userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($reviewer->getId(), $contextId); + $userPrivateNote = Repo::userPrivateNote()->getUserPrivateNote($reviewer->getId(), $contextId); $item['userPrivateNote'] = $userPrivateNote?->getNote(); $items[] = $item; } diff --git a/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php b/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php index 905085088e5..2beb2bb1189 100644 --- a/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php +++ b/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php @@ -1011,7 +1011,7 @@ public function gossip($args, $request) return new JSONMessage(false, __('user.authorization.roleBasedAccessDenied')); } - $userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($user->getId(), $request->getContext()->getId()); + $userPrivateNote = Repo::userPrivateNote()->getUserPrivateNote($user->getId(), $request->getContext()->getId()); if (!$userPrivateNote) { $userPrivateNote = Repo::userPrivateNote()->newDataObject([ 'userId' => $user->getId(), diff --git a/classes/migration/install/CommonMigration.php b/classes/migration/install/CommonMigration.php index 4168e576771..291d6f39f14 100644 --- a/classes/migration/install/CommonMigration.php +++ b/classes/migration/install/CommonMigration.php @@ -15,7 +15,6 @@ namespace PKP\migration\install; use APP\core\Application; -use APP\facades\Repo; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; diff --git a/classes/userPrivateNote/Repository.php b/classes/userPrivateNote/Repository.php index 004c7345519..b96038d969d 100644 --- a/classes/userPrivateNote/Repository.php +++ b/classes/userPrivateNote/Repository.php @@ -113,9 +113,9 @@ public function delete(UserPrivateNote $userPrivateNote): void /** * Get the user private note for the specified context. * - * This returns the first user private note, as the "user ID/context ID" key should be unique. + * This returns the user private note, as the "user ID/context ID" key should be unique. */ - public function getFirstUserPrivateNote(int $userId, int $contextId): ?UserPrivateNote + public function getUserPrivateNote(int $userId, int $contextId): ?UserPrivateNote { return Repo::userPrivateNote() ->getCollector() diff --git a/classes/userPrivateNote/UserPrivateNote.php b/classes/userPrivateNote/UserPrivateNote.php index c8bff738af6..ec1bc8f795b 100644 --- a/classes/userPrivateNote/UserPrivateNote.php +++ b/classes/userPrivateNote/UserPrivateNote.php @@ -22,68 +22,64 @@ class UserPrivateNote extends DataObject { - /** - * Get private note context ID. + /** + * Get private note context ID. * - * @return int - */ + * @return int + */ public function getContextId(): int { - return $this->getData('contextId'); - } + return $this->getData('contextId'); + } - /** - * Set private note context ID. + /** + * Set private note context ID. * - * @param $contextId int - */ + * @param $contextId int + */ public function setContextId(int $contextId): void { - $this->setData('contextId', $contextId); - } + $this->setData('contextId', $contextId); + } - /** - * Get private note user ID. + /** + * Get private note user ID. * - * @return int - */ + * @return int + */ public function getUserId(): int { - return $this->getData('userId'); - } + return $this->getData('userId'); + } - /** - * Set private note user ID. + /** + * Set private note user ID. * - * @param $userId int - */ + * @param $userId int + */ public function setUserId(int $userId): void { - $this->setData('userId', $userId); - } + $this->setData('userId', $userId); + } - /** - * Get private note value. + /** + * Get private note value. * - * @return string - */ + * @return string + */ public function getNote(): string { - return $this->getData('note'); - } + return $this->getData('note'); + } - /** - * Set private note value. + /** + * Set private note value. * - * @param $note string - */ + * @param $note string + */ public function setNote(string $note): void { - $this->setData('note', $note); - } -} - -if (!PKP_STRICT_MODE) { - class_alias('\PKP\userPrivateNote\UserPrivateNote', '\UserPrivateNote'); + $this->setData('note', $note); + } } diff --git a/controllers/grid/settings/user/form/UserDetailsForm.php b/controllers/grid/settings/user/form/UserDetailsForm.php index 7e0e5833433..71558354e15 100644 --- a/controllers/grid/settings/user/form/UserDetailsForm.php +++ b/controllers/grid/settings/user/form/UserDetailsForm.php @@ -174,11 +174,12 @@ public function initData() 'interests' => $interestManager->getInterestsForUser($user), 'locales' => $user->getLocales(), ]; - $data['canCurrentUserGossip'] = Repo::user()->canCurrentUserGossip($user->getId()); + $userId = $user->getId(); + $data['canCurrentUserGossip'] = Repo::user()->canCurrentUserGossip($userId); if ($data['canCurrentUserGossip']) { $data['gossip'] = $user->getGossip(); - $userPrivateNote = Repo::userPrivateNote() - ->getFirstUserPrivateNote($user->getId(), $request->getContext()->getId()); + $contextId = $request->getContext()->getId(); + $userPrivateNote = Repo::userPrivateNote()->getUserPrivateNote($userId, $contextId); $data['userPrivateNote'] = $userPrivateNote ? $userPrivateNote->getNote() : ''; } } elseif (isset($this->author)) { @@ -405,7 +406,7 @@ public function execute(...$functionParams) // Users can never view/edit their own private notes fields if (Repo::user()->canCurrentUserGossip($userId)) { - $userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($userId, $context->getId()); + $userPrivateNote = Repo::userPrivateNote()->getUserPrivateNote($userId, $context->getId()); Repo::userPrivateNote()->edit($userPrivateNote, ['note', $this->getData('userPrivateNote')]); }