From b125a533e623d6785e5cb1c6cf46604d70325ccc Mon Sep 17 00:00:00 2001 From: Nicolas Boulay Date: Fri, 24 Nov 2023 13:43:42 -0500 Subject: [PATCH] pkp/pkp-lib#9456 Use the new DAO and refactor for private notes --- .../listPanels/PKPSelectReviewerListPanel.php | 12 +- .../users/reviewer/PKPReviewerGridHandler.php | 16 +- classes/core/PKPApplication.php | 1 - classes/facades/Repo.php | 6 + ...teNotes.php => I9456_UserPrivateNotes.php} | 8 +- classes/services/PKPSchemaService.php | 2 + classes/user/PrivateNotesDAO.php | 108 ----------- classes/userPrivateNote/Collector.php | 167 ++++++++++++++++++ classes/userPrivateNote/DAO.php | 141 +++++++++++++++ classes/userPrivateNote/Repository.php | 128 ++++++++++++++ .../UserPrivateNote.php} | 12 +- classes/userPrivateNote/maps/Schema.php | 95 ++++++++++ .../settings/user/form/UserDetailsForm.php | 12 +- .../reviewer/form/ReviewerGossipForm.php | 23 +-- schemas/userPrivateNotes.json | 2 +- .../settings/user/form/userDetailsForm.tpl | 2 +- .../reviewer/form/reviewerGossipForm.tpl | 2 +- xml/schema/common.xml | 2 +- 18 files changed, 581 insertions(+), 158 deletions(-) rename classes/migration/upgrade/v3_5_0/{I9456_PrivateNotes.php => I9456_UserPrivateNotes.php} (87%) delete mode 100644 classes/user/PrivateNotesDAO.php create mode 100644 classes/userPrivateNote/Collector.php create mode 100644 classes/userPrivateNote/DAO.php create mode 100644 classes/userPrivateNote/Repository.php rename classes/{user/PrivateNote.php => userPrivateNote/UserPrivateNote.php} (87%) create mode 100644 classes/userPrivateNote/maps/Schema.php diff --git a/classes/components/listPanels/PKPSelectReviewerListPanel.php b/classes/components/listPanels/PKPSelectReviewerListPanel.php index e4d400c1099..754cfea9867 100644 --- a/classes/components/listPanels/PKPSelectReviewerListPanel.php +++ b/classes/components/listPanels/PKPSelectReviewerListPanel.php @@ -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; } @@ -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'); @@ -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; } diff --git a/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php b/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php index a260befee99..905085088e5 100644 --- a/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php +++ b/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php @@ -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()) { diff --git a/classes/core/PKPApplication.php b/classes/core/PKPApplication.php index d890a0199be..f2824003287 100644 --- a/classes/core/PKPApplication.php +++ b/classes/core/PKPApplication.php @@ -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', diff --git a/classes/facades/Repo.php b/classes/facades/Repo.php index 6142f56b567..fcbaac2bd52 100644 --- a/classes/facades/Repo.php +++ b/classes/facades/Repo.php @@ -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 { @@ -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); diff --git a/classes/migration/upgrade/v3_5_0/I9456_PrivateNotes.php b/classes/migration/upgrade/v3_5_0/I9456_UserPrivateNotes.php similarity index 87% rename from classes/migration/upgrade/v3_5_0/I9456_PrivateNotes.php rename to classes/migration/upgrade/v3_5_0/I9456_UserPrivateNotes.php index 7c7273dabd1..09b350617a1 100644 --- a/classes/migration/upgrade/v3_5_0/I9456_PrivateNotes.php +++ b/classes/migration/upgrade/v3_5_0/I9456_UserPrivateNotes.php @@ -1,13 +1,13 @@ 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(); diff --git a/classes/services/PKPSchemaService.php b/classes/services/PKPSchemaService.php index ac4d57a9401..8029a73fae2 100644 --- a/classes/services/PKPSchemaService.php +++ b/classes/services/PKPSchemaService.php @@ -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 */ @@ -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)); diff --git a/classes/user/PrivateNotesDAO.php b/classes/user/PrivateNotesDAO.php deleted file mode 100644 index a9dd3159ae2..00000000000 --- a/classes/user/PrivateNotesDAO.php +++ /dev/null @@ -1,108 +0,0 @@ -retrieve( - 'SELECT * FROM user_private_notes WHERE context_id = ? AND user_id = ?', - $params - ); - $factory = new DAOResultFactory($result, $this, '_fromRow'); - return $factory->toIterator()->current(); - } - - /** - * Set a user private note value. - * - * @param int $journalId - * @param int $userId - * @param string $note - */ - public function setPrivateNote(int $journalId, int $userId, string $note): void - { - $params = [ - $note, - $journalId, - $userId - ]; - $dbPrivateNote = $this->getPrivateNote($journalId, $userId); - if ($dbPrivateNote) { - $this->update( - 'UPDATE user_private_notes SET note = ? WHERE context_id = ? AND user_id = ?', - $params - ); - } else { - $this->update( - 'INSERT INTO user_private_notes (note, context_id, user_id) VALUES (?, ?, ?)', - $params - ); - } - } - - /** - * Internal function to return a PrivateNote object from a row. - * - * @param array $row - * - * @return PrivateNote - */ - function _fromRow(array $row): PrivateNote - { - $privateNote = $this->newDataObject(); - - $privateNote->setId($row['private_note_id']); - $privateNote->setContextId($row['context_id']); - $privateNote->setUserId($row['user_id']); - $privateNote->setNote($row['note']); - - return $privateNote; - } -} - -if (!PKP_STRICT_MODE) { - class_alias('\PKP\user\PrivateNotesDAO', '\PrivateNotesDAO'); -} diff --git a/classes/userPrivateNote/Collector.php b/classes/userPrivateNote/Collector.php new file mode 100644 index 00000000000..dacdac8c8bc --- /dev/null +++ b/classes/userPrivateNote/Collector.php @@ -0,0 +1,167 @@ +dao = $dao; + } + + public function getCount(): int + { + return $this->dao->getCount($this); + } + + /** + * @return Collection + */ + public function getIds(): Collection + { + return $this->dao->getIds($this); + } + + /** + * @copydoc DAO::getMany() + * + * @return LazyCollection + */ + public function getMany(): LazyCollection + { + return $this->dao->getMany($this); + } + + /** + * Filter by multiple ids + */ + public function filterByUserPrivateNoteIds(?array $ids): self + { + $this->userPrivateNoteIds = $ids; + return $this; + } + + /** + * Filter by context IDs + */ + public function filterByContextIds(?array $contextIds): self + { + $this->contextIds = $contextIds; + return $this; + } + + /** + * Filter by user ids + */ + public function filterByUserIds(?array $userIds): self + { + $this->userIds = $userIds; + return $this; + } + + /** + * Include orderBy columns to the collector query + */ + public function orderBy(?string $orderBy): self + { + $this->orderBy = $orderBy; + return $this; + } + + /** + * Limit the number of objects retrieved + */ + public function limit(?int $count): self + { + $this->count = $count; + return $this; + } + + /** + * Offset the number of objects retrieved, for example to + * retrieve the second page of contents + */ + public function offset(?int $offset): self + { + $this->offset = $offset; + return $this; + } + + /** + * @copydoc CollectorInterface::getQueryBuilder() + * + * @hook UserGroup::Collector [[&$q, $this]] + */ + public function getQueryBuilder(): Builder + { + $q = DB::table('user_private_notes as upn') + ->select('upn.*'); + + if (isset($this->userPrivateNoteIds)) { + $q->whereIn('upn.user_private_note_id', $this->userPrivateNoteIds); + } + + if (isset($this->contextIds)) { + $q->whereIn('upn.context_id', $this->contextIds); + } + + if (isset($this->userIds)) { + $q->whereIn('upn.user_id', $this->userIds); + } + + if (isset($this->count)) { + $q->limit($this->count); + } + + if (isset($this->offset)) { + $q->offset($this->offset); + } + + if ($this->orderBy == self::ORDERBY_ID) { + $q->orderBy('upn.user_private_note_id'); + } + + // Add app-specific query statements + Hook::call('UserPrivateNote::Collector', [&$q, $this]); + + return $q; + } +} diff --git a/classes/userPrivateNote/DAO.php b/classes/userPrivateNote/DAO.php new file mode 100644 index 00000000000..1e9258bbbba --- /dev/null +++ b/classes/userPrivateNote/DAO.php @@ -0,0 +1,141 @@ + + */ +class DAO extends EntityDAO +{ + use EntityWithParent; + + /** @copydoc EntityDAO::$schema */ + public $schema = PKPSchemaService::SCHEMA_USER_PRIVATE_NOTE; + + /** @copydoc EntityDAO::$table */ + public $table = 'user_private_notes'; + + /** @copydoc EntityDAO::$primaryKeyColumn */ + public $primaryKeyColumn = 'user_private_note_id'; + + /** @copydoc EntityDAO::$primaryTableColumns */ + public $primaryTableColumns = [ + 'id' => 'user_private_note_id', + 'contextId' => 'context_id', + 'userId' => 'user_id', + 'note' => 'note', + ]; + + /** + * Get the parent object ID column name + */ + public function getParentColumn(): string + { + return 'context_id'; + } + + /** + * Instantiate a new DataObject + */ + public function newDataObject(): UserPrivateNote + { + return app(UserPrivateNote::class); + } + + /** + * Get the total count of rows matching the configured query + */ + public function getCount(Collector $query): int + { + return $query + ->getQueryBuilder() + ->count(); + } + + /** + * Get a list of ids matching the configured query + * + * @return Collection + */ + public function getIds(Collector $query): Collection + { + return $query + ->getQueryBuilder() + ->select('upn.' . $this->primaryKeyColumn) + ->pluck('upn.' . $this->primaryKeyColumn); + } + + /** + * Get a collection of publications matching the configured query + * + * @return LazyCollection + */ + public function getMany(Collector $query): LazyCollection + { + $rows = $query + ->getQueryBuilder() + ->get(); + + return LazyCollection::make(function () use ($rows) { + foreach ($rows as $row) { + yield $row->user_private_note_id => $this->fromRow($row); + } + }); + } + + /** + * @copydoc EntityDAO::fromRow() + */ + public function fromRow(object $row): UserPrivateNote + { + return parent::fromRow($row); + } + + /** + * @copydoc EntityDAO::insert() + * @throws Exception + */ + public function insert(UserPrivateNote $privateNote): int + { + return parent::_insert($privateNote); + } + + /** + * @copydoc EntityDAO::update() + */ + public function update(UserPrivateNote $privateNote): void + { + parent::_update($privateNote); + } + + /** + * @copydoc EntityDAO::delete() + */ + public function delete(UserPrivateNote $privateNote): void + { + parent::_delete($privateNote); + } +} diff --git a/classes/userPrivateNote/Repository.php b/classes/userPrivateNote/Repository.php new file mode 100644 index 00000000000..004c7345519 --- /dev/null +++ b/classes/userPrivateNote/Repository.php @@ -0,0 +1,128 @@ + */ + protected PKPSchemaService $schemaService; + + public function __construct(DAO $dao, Request $request, PKPSchemaService $schemaService) + { + $this->dao = $dao; + $this->request = $request; + $this->schemaService = $schemaService; + } + + /** @copydoc DAO::newDataObject() */ + public function newDataObject(array $params = []): UserPrivateNote + { + $object = $this->dao->newDataObject(); + if (!empty($params)) { + $object->setAllData($params); + } + return $object; + } + + /** @copydoc DAO::get() */ + public function get(int $id, int $contextId = null): ?UserPrivateNote + { + return $this->dao->get($id, $contextId); + } + + /** @copydoc DAO::exists() */ + public function exists(int $id, int $contextId = null): bool + { + return $this->dao->exists($id, $contextId); + } + + /** @copydoc DAO::getCollector() */ + public function getCollector(): Collector + { + return app(Collector::class); + } + + /** + * Get an instance of the map class for mapping + * user private notes to their schema + */ + public function getSchemaMap(): maps\Schema + { + return app('maps')->withExtensions($this->schemaMap); + } + + /** + * @throws Exception + */ + public function add(UserPrivateNote $userPrivateNote): int + { + $userPrivateNoteId = $this->dao->insert($userPrivateNote); + $userPrivateNote = Repo::userPrivateNote()->get($userPrivateNoteId); + + Hook::call('UserPrivateNote::add', [$userPrivateNote]); + + return $userPrivateNote->getId(); + } + + public function edit(UserPrivateNote $userPrivateNote, array $params): void + { + $newUserPrivateNote = Repo::userPrivateNote()->newDataObject(array_merge($userPrivateNote->_data, $params)); + + Hook::call('UserPrivateNote::edit', [$newUserPrivateNote, $userPrivateNote, $params]); + + $this->dao->update($newUserPrivateNote); + + Repo::userPrivateNote()->get($newUserPrivateNote->getId()); + } + + public function delete(UserPrivateNote $userPrivateNote): void + { + Hook::call('UserPrivateNote::delete::before', [$userPrivateNote]); + + $this->dao->delete($userPrivateNote); + + Hook::call('UserPrivateNote::delete', [$userPrivateNote]); + } + + /** + * 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. + */ + public function getFirstUserPrivateNote(int $userId, int $contextId): ?UserPrivateNote + { + return Repo::userPrivateNote() + ->getCollector() + ->filterByUserIds([$userId]) + ->filterByContextIds([$contextId]) + ->limit(1) + ->getMany() + ->first(); + } +} diff --git a/classes/user/PrivateNote.php b/classes/userPrivateNote/UserPrivateNote.php similarity index 87% rename from classes/user/PrivateNote.php rename to classes/userPrivateNote/UserPrivateNote.php index ea733d2732e..5e19574444e 100644 --- a/classes/user/PrivateNote.php +++ b/classes/userPrivateNote/UserPrivateNote.php @@ -1,26 +1,26 @@ mapByProperties($this->getProps(), $item); + } + + /** + * Summarize a user private note + * + * Includes properties with the apiSummary flag in the user private note schema. + */ + public function summarize(UserPrivateNote $item): array + { + return $this->mapByProperties($this->getSummaryProps(), $item); + } + + /** + * Map a collection of user private notes + * + * @see self::map + */ + public function mapMany(Enumerable $collection): Enumerable + { + $this->collection = $collection; + return $collection->map(function ($item) { + return $this->map($item); + }); + } + + /** + * Summarize a collection of user private notes + * + * @see self::summarize + */ + public function summarizeMany(Enumerable $collection): Enumerable + { + $this->collection = $collection; + return $collection->map(function ($item) { + return $this->summarize($item); + }); + } + + /** + * Map schema properties of a user private note to an assoc array + */ + protected function mapByProperties(array $props, UserPrivateNote $item): array + { + $output = []; + foreach ($props as $prop) { + $output[$prop] = $item->getData($prop); + } + + $output = $this->schemaService->addMissingMultilingualValues($this->schema, $output, $this->context->getSupportedSubmissionLocales()); + + ksort($output); + + return $this->withExtensions($output, $item); + } +} diff --git a/controllers/grid/settings/user/form/UserDetailsForm.php b/controllers/grid/settings/user/form/UserDetailsForm.php index 4fa5c154d8d..7e0e5833433 100644 --- a/controllers/grid/settings/user/form/UserDetailsForm.php +++ b/controllers/grid/settings/user/form/UserDetailsForm.php @@ -177,9 +177,9 @@ public function initData() $data['canCurrentUserGossip'] = Repo::user()->canCurrentUserGossip($user->getId()); if ($data['canCurrentUserGossip']) { $data['gossip'] = $user->getGossip(); - $privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO'); - $privateNote = $privateNotesDAO->getPrivateNote($request->getContext()->getId(), $user->getId()); - $data['privateNote'] = $privateNote ? $privateNote->getNote() : ''; + $userPrivateNote = Repo::userPrivateNote() + ->getFirstUserPrivateNote($user->getId(), $request->getContext()->getId()); + $data['userPrivateNote'] = $userPrivateNote ? $userPrivateNote->getNote() : ''; } } elseif (isset($this->author)) { $author = $this->author; @@ -271,7 +271,7 @@ public function readInputData() 'country', 'biography', 'gossip', - 'privateNote', + 'userPrivateNote', 'interests', 'locales', 'generatePassword', @@ -405,8 +405,8 @@ public function execute(...$functionParams) // Users can never view/edit their own private notes fields if (Repo::user()->canCurrentUserGossip($userId)) { - $privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO'); - $privateNotesDAO->setPrivateNote($context->getId(), $userId, $this->getData('privateNote')); + $userPrivateNote = Repo::userPrivateNote()->getFirstUserPrivateNote($userId, $context->getId()); + Repo::userPrivateNote()->edit($userPrivateNote, ['note', $this->getData('userPrivateNote')]); } $interestManager = new InterestManager(); diff --git a/controllers/grid/users/reviewer/form/ReviewerGossipForm.php b/controllers/grid/users/reviewer/form/ReviewerGossipForm.php index 0c52a62d17c..7729f349d93 100644 --- a/controllers/grid/users/reviewer/form/ReviewerGossipForm.php +++ b/controllers/grid/users/reviewer/form/ReviewerGossipForm.php @@ -19,16 +19,16 @@ use APP\facades\Repo; use APP\template\TemplateManager; use PKP\form\Form; -use PKP\user\PrivateNote; use PKP\user\User; +use PKP\userPrivateNote\UserPrivateNote; class ReviewerGossipForm extends Form { /** @var User The user to gossip about */ public $_user; - /** @var PrivateNote The user's private note */ - public $_privateNote; + /** @var UserPrivateNote The user's private note */ + public UserPrivateNote $_userPrivateNote; /** @var array Arguments used to route the form op */ public $_requestArgs; @@ -37,15 +37,15 @@ class ReviewerGossipForm extends Form * Constructor. * * @param User $user The user to gossip about - * @param PrivateNote $privateNote The user's private note + * @param UserPrivateNote $userPrivateNote The user's private note * @param array $requestArgs Arguments used to route the form op to the * correct submission, stage and review round */ - public function __construct($user, $privateNote, $requestArgs) + public function __construct($user, $userPrivateNote, $requestArgs) { parent::__construct('controllers/grid/users/reviewer/form/reviewerGossipForm.tpl'); $this->_user = $user; - $this->_privateNote = $privateNote; + $this->_userPrivateNote = $userPrivateNote; $this->_requestArgs = $requestArgs; $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); @@ -58,7 +58,7 @@ public function readInputData() { $this->readUserVars([ 'gossip', - 'privateNote', + 'userPrivateNote', ]); } @@ -73,7 +73,7 @@ public function fetch($request, $template = null, $display = false) $templateMgr->assign([ 'requestArgs' => $this->_requestArgs, 'gossip' => $this->_user->getGossip(), - 'privateNote' => $this->_privateNote->getNote(), + 'userPrivateNote' => $this->_userPrivateNote->getNote(), ]); return parent::fetch($request, $template, $display); @@ -86,12 +86,7 @@ public function execute(...$functionArgs) { $this->_user->setGossip($this->getData('gossip')); Repo::user()->edit($this->_user); - $privateNotesDAO = DAORegistry::getDAO('PrivateNotesDAO'); - $privateNotesDAO->setPrivateNote( - $this->_privateNote->getContextId(), - $this->_privateNote->getUserId(), - $this->getData('privateNote') - ); + Repo::userPrivateNote()->edit($this->_userPrivateNote, ['note' => $this->getData('userPrivateNote')]); parent::execute(...$functionArgs); } } diff --git a/schemas/userPrivateNotes.json b/schemas/userPrivateNotes.json index a54b7c109bb..7801ae1b7eb 100644 --- a/schemas/userPrivateNotes.json +++ b/schemas/userPrivateNotes.json @@ -2,7 +2,7 @@ "title": "User Private Note", "description": "A private note associated to the user.", "properties": { - "privateNoteId": { + "userPrivateNoteId": { "type": "integer", "readOnly": true }, diff --git a/templates/controllers/grid/settings/user/form/userDetailsForm.tpl b/templates/controllers/grid/settings/user/form/userDetailsForm.tpl index a0414134aaa..a4b122585ed 100644 --- a/templates/controllers/grid/settings/user/form/userDetailsForm.tpl +++ b/templates/controllers/grid/settings/user/form/userDetailsForm.tpl @@ -57,7 +57,7 @@ {fbvElement type="textarea" name="gossip" id="gossip" rich=true value=$gossip} {/fbvFormSection} {fbvFormSection label="user.private.notes" description="user.private.notes.description"} - {fbvElement type="textarea" name="privateNote" id="privateNote" rich=true value=$privateNote} + {fbvElement type="textarea" name="userPrivateNote" id="userPrivateNote" rich=true value=$userPrivateNote} {/fbvFormSection} {/if} {/if} diff --git a/templates/controllers/grid/users/reviewer/form/reviewerGossipForm.tpl b/templates/controllers/grid/users/reviewer/form/reviewerGossipForm.tpl index d2943bac3d2..711310ce31f 100644 --- a/templates/controllers/grid/users/reviewer/form/reviewerGossipForm.tpl +++ b/templates/controllers/grid/users/reviewer/form/reviewerGossipForm.tpl @@ -23,7 +23,7 @@

{translate key="user.private.notes"}

{fbvFormSection} - {fbvElement type="textarea" name="privateNote" id="privateNote" label="user.private.notes.description" rich=true value=$privateNote} + {fbvElement type="textarea" name="userPrivateNote" id="userPrivateNote" label="user.private.notes.description" rich=true value=$userPrivateNote} {/fbvFormSection} {fbvFormButtons} diff --git a/xml/schema/common.xml b/xml/schema/common.xml index aeec3e57844..d132c80df32 100644 --- a/xml/schema/common.xml +++ b/xml/schema/common.xml @@ -237,7 +237,7 @@ * --> - +