Skip to content

Commit

Permalink
pkp#9456 Use the new DAO and refactor for private notes
Browse files Browse the repository at this point in the history
  • Loading branch information
nibou230 committed Nov 30, 2023
1 parent 90f4b47 commit 3d170c7
Show file tree
Hide file tree
Showing 18 changed files with 581 additions and 158 deletions.
12 changes: 5 additions & 7 deletions classes/components/listPanels/PKPSelectReviewerListPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ public function getConfig()
->values()
->toArray();
$contextId = $this->getParams['contextId'];
$privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO');
foreach ($reviewers as $key => $reviewer) {
$privateNote = $privateNotesDAO->getPrivateNote($contextId, $reviewer['id']);
$reviewers[$key]['privateNotes'] = $privateNote ? $privateNote->getNote() : null;
$userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($reviewer->getId(), $contextId);
$reviewers[$key]['userPrivateNote'] = $userPrivateNote?->getNote();
}
$config['lastRoundReviewers'] = $reviewers;
}
Expand All @@ -154,7 +153,7 @@ public function getConfig()
$config['declinedReviewsLabel'] = __('reviewer.list.declinedReviews');
$config['emptyLabel'] = __('reviewer.list.empty');
$config['gossipLabel'] = __('user.gossip');
$config['privateNotesLabel'] = __('user.private.notes');
$config['userPrivateNotesLabel'] = __('user.private.notes');
$config['neverAssignedLabel'] = __('reviewer.list.neverAssigned');
$config['reassignLabel'] = __('reviewer.list.reassign');
$config['reassignWithNameLabel'] = __('reviewer.list.reassign.withName');
Expand All @@ -181,11 +180,10 @@ public function getItems($request)
$items = [];
$map = Repo::user()->getSchemaMap();
$contextId = $request->getContext()->getId();
$privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO');
foreach ($reviewers as $reviewer) {
$item = $map->summarizeReviewer($reviewer);
$privateNote = $privateNotesDAO->getPrivateNote($contextId, $reviewer->getId());
$item['privateNotes'] = $privateNote ? $privateNote->getNote() : null;
$userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($reviewer->getId(), $contextId);
$item['userPrivateNote'] = $userPrivateNote?->getNote();
$items[] = $item;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,17 +1011,17 @@ public function gossip($args, $request)
return new JSONMessage(false, __('user.authorization.roleBasedAccessDenied'));
}

$privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO');
$privateNote = $privateNotesDAO->getPrivateNote($request->getContext()->getId(), $user->getId());
if (!$privateNote) {
$privateNote = $privateNotesDAO->newDataObject();
$privateNote->setContextId($request->getContext()->getId());
$privateNote->setUserId($user->getId());
$privateNote->setNote('');
$userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($user->getId(), $request->getContext()->getId());
if (!$userPrivateNote) {
$userPrivateNote = Repo::userPrivateNote()->newDataObject([
'userId' => $user->getId(),
'contextId' => $request->getContext()->getId(),
'note' => ''
]);
}

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

// View form
if (!$request->isPost()) {
Expand Down
1 change: 0 additions & 1 deletion classes/core/PKPApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ public function getDAOMap()
'NotificationSubscriptionSettingsDAO' => 'PKP\notification\NotificationSubscriptionSettingsDAO',
'PluginGalleryDAO' => 'PKP\plugins\PluginGalleryDAO',
'PluginSettingsDAO' => 'PKP\plugins\PluginSettingsDAO',
'PrivateNotesDAO' => 'PKP\user\PrivateNotesDAO',
'PublicationDAO' => 'APP\publication\PublicationDAO',
'QueuedPaymentDAO' => 'PKP\payment\QueuedPaymentDAO',
'ReviewFilesDAO' => 'PKP\submission\ReviewFilesDAO',
Expand Down
6 changes: 6 additions & 0 deletions classes/facades/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use PKP\log\event\Repository as EventLogRepository;
use PKP\submissionFile\Repository as SubmissionFileRepository;
use PKP\userGroup\Repository as UserGroupRepository;
use PKP\userPrivateNote\Repository as UserPrivateNoteRepository;

class Repo
{
Expand Down Expand Up @@ -90,6 +91,11 @@ public static function userGroup(): UserGroupRepository
return app(UserGroupRepository::class);
}

public static function userPrivateNote(): UserPrivateNoteRepository
{
return app(UserPrivateNoteRepository::class);
}

public static function eventLog(): EventLogRepository
{
return app(EventLogRepository::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I9456_PrivateNotes.php
* @file classes/migration/upgrade/v3_5_0/I9456_UserPrivateNotes.php
*
* Copyright (c) 2014-2023 Simon Fraser University
* Copyright (c) 2000-2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I9456_PrivateNotes
* @class I9456_UserPrivateNotes
*/

namespace PKP\migration\upgrade\v3_5_0;
Expand All @@ -18,7 +18,7 @@
use Illuminate\Support\Facades\Schema;
use PKP\migration\Migration;

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

$table->bigInteger('context_id');
$contextDao = Application::getContextDAO();
Expand Down
2 changes: 2 additions & 0 deletions classes/services/PKPSchemaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PKPSchemaService
public const SCHEMA_SUBMISSION_FILE = 'submissionFile';
public const SCHEMA_USER = 'user';
public const SCHEMA_USER_GROUP = 'userGroup';
public const SCHEMA_USER_PRIVATE_NOTE = 'userPrivateNote';
public const SCHEMA_EVENT_LOG = 'eventLog';

/** @var array cache of schemas that have been loaded */
Expand Down Expand Up @@ -631,6 +632,7 @@ class_alias('\PKP\services\PKPSchemaService', '\PKPSchemaService');
'SCHEMA_SUBMISSION_FILE',
'SCHEMA_USER',
'SCHEMA_USER_GROUP',
'SCHEMA_USER_PRIVATE_NOTE',
] as $constantName) {
if (!defined($constantName)) {
define($constantName, constant('PKPSchemaService::' . $constantName));
Expand Down
108 changes: 0 additions & 108 deletions classes/user/PrivateNotesDAO.php

This file was deleted.

Loading

0 comments on commit 3d170c7

Please sign in to comment.