-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkp/pkp-lib#9456 Add user private notes #9549
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few general comments! Before you start reading these over, I'll start a convo with Devika about the feature; start over there first. Thanks, this is a very clean contribution (as the others have been too)!
* | ||
* @return int | ||
*/ | ||
public function getContextId(): int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is a bit garbled here; there should be a git pre-commit hook that applies automatic formatting. Can you check if that's working?
} | ||
} | ||
|
||
if (!PKP_STRICT_MODE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For new code, it's best not to add class_alias
es like this unless for some reason it's necessary (I think that's only for plugin classes at the moment). We'll remove these at some point in the future; they're only for backward compatibility.
@@ -15,6 +15,7 @@ | |||
namespace PKP\migration\install; | |||
|
|||
use APP\core\Application; | |||
use APP\facades\Repo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably leftover and not necessary.
|
||
use PKP\core\DataObject; | ||
|
||
class UserPrivateNote extends DataObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change this unless you're motivated to -- but in general we're moving towards Eloquent models rather than DataObject
s. At some point in the distant future we'll deprecate DataObject
entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't have the time to look at this before holidays. I will let this class as a DataObject
for now. Do you have any example of an Eloquent model in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far just a few relationship classes -- see lib/pkp/classes/userGroup/relationships
. We'll be adding more soon (including patterns to demo mapping to the API). If these are proven out by the time you return from holiday, then we can look at adopting them here too; otherwise don't worry about it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...but this would be my preference rather than moving to Eloquent.
* | ||
* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's a unique index on this (i.e. it's impossible to have more than one private note per journal per user), I'd suggest dropping First
in the function name.
<?php | ||
|
||
/** | ||
* @file classes/userPrivateNote/DAO.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than a bespoke table for this feature (with all the attendant management that'll require), another option would've been to use NoteDAO
with an assoc_type
of ASSOC_TYPE_CONTEXT
. Notes are currently used for a few things, and the assoc_type/assoc_id pairing is similar to a Laravel "morphs" relationship.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a couple of issues related to notes in 3.3 (ie random blank empty notes, notes which don't belong to the current publication). Also, I'm not familiar to the concept used by the notes for relationships, but if you really want to avoid the creation of a new table, I can take a look at this in january.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think on balance it'll be worth reusing the notes feature. That would be my preference, above e.g. moving to Laravel or sticking with DAOs. We already have >100 tables and all the attendant classes etc. to go with them, and it's a lot of overhead to maintain!
pkp/ojs#4110