Skip to content

Commit b125a53

Browse files
committed
pkp#9456 Use the new DAO and refactor for private notes
1 parent 595a631 commit b125a53

File tree

18 files changed

+581
-158
lines changed

18 files changed

+581
-158
lines changed

classes/components/listPanels/PKPSelectReviewerListPanel.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ public function getConfig()
127127
->values()
128128
->toArray();
129129
$contextId = $this->getParams['contextId'];
130-
$privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO');
131130
foreach ($reviewers as $key => $reviewer) {
132-
$privateNote = $privateNotesDAO->getPrivateNote($contextId, $reviewer['id']);
133-
$reviewers[$key]['privateNotes'] = $privateNote ? $privateNote->getNote() : null;
131+
$userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($reviewer->getId(), $contextId);
132+
$reviewers[$key]['userPrivateNote'] = $userPrivateNote?->getNote();
134133
}
135134
$config['lastRoundReviewers'] = $reviewers;
136135
}
@@ -154,7 +153,7 @@ public function getConfig()
154153
$config['declinedReviewsLabel'] = __('reviewer.list.declinedReviews');
155154
$config['emptyLabel'] = __('reviewer.list.empty');
156155
$config['gossipLabel'] = __('user.gossip');
157-
$config['privateNotesLabel'] = __('user.private.notes');
156+
$config['userPrivateNotesLabel'] = __('user.private.notes');
158157
$config['neverAssignedLabel'] = __('reviewer.list.neverAssigned');
159158
$config['reassignLabel'] = __('reviewer.list.reassign');
160159
$config['reassignWithNameLabel'] = __('reviewer.list.reassign.withName');
@@ -181,11 +180,10 @@ public function getItems($request)
181180
$items = [];
182181
$map = Repo::user()->getSchemaMap();
183182
$contextId = $request->getContext()->getId();
184-
$privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO');
185183
foreach ($reviewers as $reviewer) {
186184
$item = $map->summarizeReviewer($reviewer);
187-
$privateNote = $privateNotesDAO->getPrivateNote($contextId, $reviewer->getId());
188-
$item['privateNotes'] = $privateNote ? $privateNote->getNote() : null;
185+
$userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($reviewer->getId(), $contextId);
186+
$item['userPrivateNote'] = $userPrivateNote?->getNote();
189187
$items[] = $item;
190188
}
191189

classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -1011,17 +1011,17 @@ public function gossip($args, $request)
10111011
return new JSONMessage(false, __('user.authorization.roleBasedAccessDenied'));
10121012
}
10131013

1014-
$privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO');
1015-
$privateNote = $privateNotesDAO->getPrivateNote($request->getContext()->getId(), $user->getId());
1016-
if (!$privateNote) {
1017-
$privateNote = $privateNotesDAO->newDataObject();
1018-
$privateNote->setContextId($request->getContext()->getId());
1019-
$privateNote->setUserId($user->getId());
1020-
$privateNote->setNote('');
1014+
$userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($user->getId(), $request->getContext()->getId());
1015+
if (!$userPrivateNote) {
1016+
$userPrivateNote = Repo::userPrivateNote()->newDataObject([
1017+
'userId' => $user->getId(),
1018+
'contextId' => $request->getContext()->getId(),
1019+
'note' => ''
1020+
]);
10211021
}
10221022

10231023
$requestArgs = array_merge($this->getRequestArgs(), ['reviewAssignmentId' => $reviewAssignment->getId()]);
1024-
$reviewerGossipForm = new ReviewerGossipForm($user, $privateNote, $requestArgs);
1024+
$reviewerGossipForm = new ReviewerGossipForm($user, $userPrivateNote, $requestArgs);
10251025

10261026
// View form
10271027
if (!$request->isPost()) {

classes/core/PKPApplication.php

-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ public function getDAOMap()
490490
'NotificationSubscriptionSettingsDAO' => 'PKP\notification\NotificationSubscriptionSettingsDAO',
491491
'PluginGalleryDAO' => 'PKP\plugins\PluginGalleryDAO',
492492
'PluginSettingsDAO' => 'PKP\plugins\PluginSettingsDAO',
493-
'PrivateNotesDAO' => 'PKP\user\PrivateNotesDAO',
494493
'PublicationDAO' => 'APP\publication\PublicationDAO',
495494
'QueuedPaymentDAO' => 'PKP\payment\QueuedPaymentDAO',
496495
'ReviewFilesDAO' => 'PKP\submission\ReviewFilesDAO',

classes/facades/Repo.php

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use PKP\log\event\Repository as EventLogRepository;
3838
use PKP\submissionFile\Repository as SubmissionFileRepository;
3939
use PKP\userGroup\Repository as UserGroupRepository;
40+
use PKP\userPrivateNote\Repository as UserPrivateNoteRepository;
4041

4142
class Repo
4243
{
@@ -90,6 +91,11 @@ public static function userGroup(): UserGroupRepository
9091
return app(UserGroupRepository::class);
9192
}
9293

94+
public static function userPrivateNote(): UserPrivateNoteRepository
95+
{
96+
return app(UserPrivateNoteRepository::class);
97+
}
98+
9399
public static function eventLog(): EventLogRepository
94100
{
95101
return app(EventLogRepository::class);

classes/migration/upgrade/v3_5_0/I9456_PrivateNotes.php renamed to classes/migration/upgrade/v3_5_0/I9456_UserPrivateNotes.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33
/**
4-
* @file classes/migration/upgrade/v3_5_0/I9456_PrivateNotes.php
4+
* @file classes/migration/upgrade/v3_5_0/I9456_UserPrivateNotes.php
55
*
66
* Copyright (c) 2014-2023 Simon Fraser University
77
* Copyright (c) 2000-2023 John Willinsky
88
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
99
*
10-
* @class I9456_PrivateNotes
10+
* @class I9456_UserPrivateNotes
1111
*/
1212

1313
namespace PKP\migration\upgrade\v3_5_0;
@@ -18,7 +18,7 @@
1818
use Illuminate\Support\Facades\Schema;
1919
use PKP\migration\Migration;
2020

21-
class I9456_PrivateNotes extends Migration
21+
class I9456_UserPrivateNotes extends Migration
2222
{
2323
/**
2424
* Run the migrations.
@@ -27,7 +27,7 @@ public function up(): void
2727
{
2828
Schema::create('user_private_notes', function (Blueprint $table) {
2929
$table->comment('User private notes are an addition to the gossip, but this one is private to each context.');
30-
$table->bigInteger('private_note_id')->autoIncrement();
30+
$table->bigInteger('user_private_note_id')->autoIncrement();
3131

3232
$table->bigInteger('context_id');
3333
$contextDao = Application::getContextDAO();

classes/services/PKPSchemaService.php

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class PKPSchemaService
4747
public const SCHEMA_SUBMISSION_FILE = 'submissionFile';
4848
public const SCHEMA_USER = 'user';
4949
public const SCHEMA_USER_GROUP = 'userGroup';
50+
public const SCHEMA_USER_PRIVATE_NOTE = 'userPrivateNote';
5051
public const SCHEMA_EVENT_LOG = 'eventLog';
5152

5253
/** @var array cache of schemas that have been loaded */
@@ -631,6 +632,7 @@ class_alias('\PKP\services\PKPSchemaService', '\PKPSchemaService');
631632
'SCHEMA_SUBMISSION_FILE',
632633
'SCHEMA_USER',
633634
'SCHEMA_USER_GROUP',
635+
'SCHEMA_USER_PRIVATE_NOTE',
634636
] as $constantName) {
635637
if (!defined($constantName)) {
636638
define($constantName, constant('PKPSchemaService::' . $constantName));

classes/user/PrivateNotesDAO.php

-108
This file was deleted.

0 commit comments

Comments
 (0)