Peer reviewed article subscribe to discussion updates #281
No reviewers
Labels
No labels
Component: User interface
Component: Wymeditor
Help wanted
Level: Difficult
Level: Easy
Level: Moderate
Pagetype: Festival
Pagetype: Mailinglist
Pagetype: Peer reviewed article
Pagetype: Text
Privacy GDPR AVG
status: has conflicts
Status: Needs changes
Status: Needs discussion
Status: Needs review
Status: Ready to merge
Status: Waiting for response
Type: Bug
Type: Enhancement
Type: Question
Usecase: De Stadsbron
Usecase: Koppelting
Usecase: MeetjeStad
Value: Coders
Value: Security
Value: Users
Value: Visitors
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
harmen/hypha!281
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "peer-reviewed-article-subscribe-to-discussion-updates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Moet zijn: "Houd me op de hoogte."
I left some inline comments.
Overall, I wonder: Are you subscribing to an article as a whole? Or a single discussion? Should this be a choice to make?
@ -522,3 +530,3 @@$dataFieldSuffix = '/new_' . $type;$dataFieldSuffix = $this->constructDiscussionFieldSuffix($type);I do not really like using a ternary if in this way (where it does not produce a meaningful value but is only used for the side effects), for clarity I would prefer a normal if here (and below). Mostly preference, though.
@ -745,2 +733,2 @@notify('success', ucfirst(__('art-comment-posted')));return ['redirect', $this->constructFullPath($this->pagename)];$confirmedComment = false;$confirmedSubscriber = false;I think pending is no longer a good variable name here. Something like
$confirmedis better, since it indicates that something was confirmed (even though that does mean it used to be pending). Also, I think that simply splitting this into two variables (e.g.$confirmedCommentand$confirmedSubscription) is more clear.Finally: Is there ever a case where you can confirm a subscription without confirming a comment? Probably not in practice, but maybe it is enough to track this separately just for abnormal circumstances?
@ -1133,2 +1239,4 @@$vars['email'] = __('art-email');$vars['field-name-email'] = self::FIELD_NAME_DISCUSSION_COMMENTER_EMAIL . $dataFieldSuffix;$vars['subscribe'] = __('art-subscribe');$vars['info-button-subscribe'] = makeInfoButton('help-art-subscribe');Why so much code over the checkbox value here? Just any non-empty value would be sufficient, and then in the handling just check to see if the value is set?
There is also some code to pass a value for the checkbox as part of
$formData, which just sets the same value again, which also seems pointless to me? Why is all this needed?@ -1241,2 +1359,4 @@]);$messageArgs = ['name' => htmlspecialchars($name),'link' => htmlspecialchars($linkToPage),I think this should not do
htmlspecialchars, if anything it should dorawurlencode(since you're building a URL here. Thehtmlspecialcharsshould be done below, on the full$linkToUnsubscribewhen it is inserted into thehrefattribute.I wonder if this unsubsribe stuff should be appended, or maybe included in the
__('art-comment-subscriber-body')string?I haven't checked, but this looks like the subscribe checkbox is always shown, even for logged in users that are automatically subscribed currently (and do not need to enter or confirm their e-mail). Or am I mistaken?
Should this be "Keep me informed..."?
Or maybe "Stay informed..."?
@ -339,9 +339,11 @@"art-block-resolved-subject" => "Breekpunt opgelost bij '[[title]]'",This seems like an unrelated change?
fixed
@ -522,3 +530,3 @@$dataFieldSuffix = '/new_' . $type;$dataFieldSuffix = $this->constructDiscussionFieldSuffix($type);fixed
@ -745,2 +733,2 @@notify('success', ucfirst(__('art-comment-posted')));return ['redirect', $this->constructFullPath($this->pagename)];$confirmedComment = false;$confirmedSubscriber = false;fixed
@ -1241,2 +1359,4 @@]);$messageArgs = ['name' => htmlspecialchars($name),'link' => htmlspecialchars($linkToPage),Don't want to risk it being excluded.
@ -1241,2 +1359,4 @@]);$messageArgs = ['name' => htmlspecialchars($name),'link' => htmlspecialchars($linkToPage),fixed
@ -1133,2 +1239,4 @@$vars['email'] = __('art-email');$vars['field-name-email'] = self::FIELD_NAME_DISCUSSION_COMMENTER_EMAIL . $dataFieldSuffix;$vars['subscribe'] = __('art-subscribe');$vars['info-button-subscribe'] = makeInfoButton('help-art-subscribe');Good to know. And a good indication that the workings of the HTMLForm is obscure.
Removed redundant code.
This part of the code is only used for non-users.
fixed
@ -339,9 +339,11 @@"art-block-resolved-subject" => "Breekpunt opgelost bij '[[title]]'",moved from this commit
Looks almost good to me. I left a few inline comments, which I also fixed in a fixup commit which I'll push in a minute.
I also added one new commit to prevent subscribers from being notified of their own comments (which seems unnecessary and maybe even confusing).
@laurensmartina, if you don't find anything wrong with these additions, I think the fixup commit can be squashed and the PR can be merged.
I did have two more usability questions (maybe for @tammoterhark or @giplt), which should not block merging this I think:
@ -737,3 +726,4 @@$comment = $commentNodeList->first();if (!$comment instanceof HyphaDomElement) {$this->xml->unlock();notify('error', __('art-invalid-code'));This does not actually contain the container, it's a list of matched subcribers. I would just take the first one of that directly, e.g.:
Which returns
nullwhen not subscribers were matched.@ -848,4 +905,4 @@if (!$review) {if (isUser()) {$userEmail = $this->O_O->getUser()->getAttribute('email');$userName = $this->O_O->getUser()->getAttribute('fullname');This check for equal to 'on' seems overly specific to me, especially since it is never explicitly given anywhere. The value passed in the POST request is normally equal to the HTML input checkbox element's "value" attribute, which is omitted here. It seems HTML5 explicitly specifies this to default to "on" when omitted, but I'm not sure it is nice to rely on that here (also HTML4 does not specify any default but requires the "value" attribute, so who knows what browsers might be sending?).
I would suggest simply relying on HTML-for to do the right thing and provide true-y or falsy value directly from
dataFor, which matches thetruethat is entered as the default value. In practice, this works since when the checkbox is not checked, it is not part of the POST request at all, so thedataForcall will returnnull, which is falsey.This also returns subscribers with status "unsubscribed", which are not changed to pending, so you cannot resubscribe after unsubscribing. I think the best fix would be to exclude unsubscribed entries in this xpath, so a new, pending, subscriber element will be created again.
@ -1235,3 +1355,3 @@$subject = __('art-comment-subject', array($subject = __('art-comment-subject', ['name' => $name,Probably better to use
xpath_encoderather than manually quoting values here.I've also rebased on top of master.
@matthijskooijman I live the changes you made, and rebased the fixup
I think we will have to find out if the functionality is sufficiently clear. We'll see.
@laurensmartina what does "I live the changes you made" mean? Did you mean "reviewed"?
Regardless, shall we merge this, put it in test.destadsbron.nl and include it in the upcoming deployment?
@matthijskooijman , it was a typo..
liveshould have beenlike.