Skip to content

Commit

Permalink
pkp#9456 Removed First from the method name
Browse files Browse the repository at this point in the history
  • Loading branch information
nibou230 committed Dec 7, 2023
1 parent b5eca50 commit 58a40e0
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 50 deletions.
4 changes: 2 additions & 2 deletions classes/components/listPanels/PKPSelectReviewerListPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion classes/migration/install/CommonMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions classes/userPrivateNote/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
76 changes: 36 additions & 40 deletions classes/userPrivateNote/UserPrivateNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
9 changes: 5 additions & 4 deletions controllers/grid/settings/user/form/UserDetailsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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')]);
}

Expand Down

0 comments on commit 58a40e0

Please sign in to comment.