From 8248e75157e6adeaff5b99c76eff9957d81ae6fc Mon Sep 17 00:00:00 2001
From: Ryan Cramer
Date: Wed, 25 Nov 2020 14:55:08 -0500
Subject: [PATCH] =?UTF-8?q?Update=20ProcessCommentsManager=20to=20support?=
=?UTF-8?q?=20changes=20to=20the=20user=E2=80=99s=20selected=20notificatio?=
=?UTF-8?q?n=20settings?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProcessCommentsManager.css | 2 +-
.../ProcessCommentsManager.module | 61 ++++++++++++++++++-
.../ProcessCommentsManager.scss | 3 +
3 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.css b/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.css
index 0444b43f..296cc324 100644
--- a/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.css
+++ b/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.css
@@ -1 +1 @@
-#CommentListHeader{padding-top:.5em;padding-bottom:.5em}#CommentListHeader>p{line-height:2.25em;padding-right:1em;margin-top:.25em;margin-bottom:.25em}#CommentListHeader .MarkupPagerNav{margin-top:0;margin-bottom:.5em}#CommentListHeader .CommentLimitSelect{float:left}#CommentListHeader .CommentCheckAll{display:block;float:left;padding-left:.75em}#CommentListHeader .CommentActions{float:left}#CommentListHeader .CommentSorts{float:left}.CommentItems{clear:both;border-bottom:1px solid #777}.CommentItems+button.ui-button{margin-top:1em}.CommentItem{clear:both;border-top:1px solid #777;padding:.75em 0;margin:0;width:100%}.CommentItem.CommentChecked{background-color:#eee}.CommentItem.CommentChecked th{color:#999}.CommentItem table{width:45%;float:left}.CommentItem table th,.CommentItem table td{padding:4px 10px 4px 0;border-bottom:1px solid #ddd;vertical-align:top;line-height:1.8}.CommentItem table th{font-weight:bold;white-space:nowrap;text-align:left;padding-left:.75em !important}.CommentItem table th:first-child{width:80px}.CommentItem table tr:last-child td,.CommentItem table tr:last-child th{border-bottom:none}.CommentItem .CommentTitle th,.CommentItem .CommentTitle td{padding-top:0}.CommentItem .CommentInput{max-width:80%}.CommentItem .CommentChangedIcon{display:none}.CommentItem.CommentItemChanged .CommentChangedIcon{display:inline;float:right;opacity:.3}.CommentItem input[type=number]{width:4em}.CommentItem .CommentVotes label{margin-right:5px}.CommentItem .CommentVotes .CommentUpvotes span{font-weight:bold;color:green;margin-right:2px}.CommentItem .CommentVotes .CommentDownvotes span{font-weight:bold;color:red;margin-right:2px}.CommentItem .CommentID{font-weight:normal;color:#333}.CommentItem .CommentWhere small{margin-right:2px}.CommentItem .CommentWhere input{width:80px}.CommentItem .CommentStars>span{display:inline;cursor:pointer;padding-right:3px}.CommentItem .CommentStars>span i.fa{font-size:18px !important}.CommentItem .CommentContent{float:left;width:55%;padding-left:1em;border:none}.CommentItem .CommentContent .CommentChildrenInfo{margin-top:.5em}.CommentItem .CommentContent .CommentReplyInfo{margin-bottom:0}.CommentItem .CommentContent .CommentText{cursor:pointer;padding-right:1em}.CommentItem .CommentContent .CommentText textarea{font-size:1em;width:100%;min-height:18em;margin-top:1em;margin-bottom:1em}.CommentItem .CommentContent .CommentText .CommentTextEdit{white-space:nowrap}.CommentItem .CommentContent .CommentTextOverflow{overflow-y:scroll;max-height:18em}.CommentItem label.CommentStatus{white-space:nowrap;display:inline-block}.CommentItem.CommentItemStatus999{display:none}.CommentCheckAll label .detail,.CommentItem .CommentTitle th label .detail{font-weight:bold;color:#444}.pw-content .MarkupPagerNav{padding-top:.5em;float:right}.pw-content .MarkupPagerNav+button{margin-top:1em}.AdminThemeReno .pw-content .MarkupPagerNav li a,.AdminThemeReno .pw-content .MarkupPagerNav li:first-child a,.AdminThemeReno .pw-content .MarkupPagerNav li.MarkupPagerNavOn a{border-color:#fff !important;border:none !important;border-left:1px solid #fff !important}.AdminThemeReno .pw-content .MarkupPagerNav li{margin-bottom:1px}.AdminThemeReno .pw-content #CommentListHeader{border-top:1px solid #eee}.AdminThemeReno .pw-content #CommentListHeader .MarkupPagerNav{margin-top:.5em}@media only screen and (max-width: 960px){.pw-content .MarkupPagerNav{float:none}#CommentListHeader{padding-bottom:1em;padding-top:1em}#CommentListHeader .MarkupPagerNav{float:none}#CommentListHeader p{margin-top:0;margin-bottom:0;padding-right:1em;padding-left:0 !important}#CommentListHeader .CommentCheckAll{width:auto}}@media only screen and (max-width: 768px){.CommentItem table{width:100%;float:none}.CommentItem table th{padding-left:0 !important}.CommentItem .CommentContent{width:100%;float:none;padding-left:0}.CommentItem .CommentContent .CommentText{padding-right:0}.CommentItem .CommentContent .CommentTextOverflow{overflow-y:auto;max-height:inherit}}.WireTabs{opacity:0}
+#CommentListHeader{padding-top:.5em;padding-bottom:.5em}#CommentListHeader>p{line-height:2.25em;padding-right:1em;margin-top:.25em;margin-bottom:.25em}#CommentListHeader .MarkupPagerNav{margin-top:0;margin-bottom:.5em}#CommentListHeader .CommentLimitSelect{float:left}#CommentListHeader .CommentCheckAll{display:block;float:left;padding-left:.75em}#CommentListHeader .CommentActions{float:left}#CommentListHeader .CommentSorts{float:left}.CommentItems{clear:both;border-bottom:1px solid #777}.CommentItems+button.ui-button{margin-top:1em}.CommentItem{clear:both;border-top:1px solid #777;padding:.75em 0;margin:0;width:100%}.CommentItem.CommentChecked{background-color:#eee}.CommentItem.CommentChecked th{color:#999}.CommentItem table{width:45%;float:left}.CommentItem table th,.CommentItem table td{padding:4px 10px 4px 0;border-bottom:1px solid #ddd;vertical-align:top;line-height:1.8}.CommentItem table th{font-weight:bold;white-space:nowrap;text-align:left;padding-left:.75em !important}.CommentItem table th:first-child{width:80px}.CommentItem table tr:last-child td,.CommentItem table tr:last-child th{border-bottom:none}.CommentItem .CommentTitle th,.CommentItem .CommentTitle td{padding-top:0}.CommentItem .CommentInput{max-width:80%}.CommentItem .CommentChangedIcon{display:none}.CommentItem.CommentItemChanged .CommentChangedIcon{display:inline;float:right;opacity:.3}.CommentItem input[type=number]{width:4em}.CommentItem .CommentVotes label{margin-right:5px}.CommentItem .CommentVotes .CommentUpvotes span{font-weight:bold;color:green;margin-right:2px}.CommentItem .CommentVotes .CommentDownvotes span{font-weight:bold;color:red;margin-right:2px}.CommentItem .CommentID{font-weight:normal;color:#333}.CommentItem .CommentWhere small{margin-right:2px}.CommentItem .CommentWhere input{width:80px}.CommentItem .CommentStars>span{display:inline;cursor:pointer;padding-right:3px}.CommentItem .CommentStars>span i.fa{font-size:18px !important}.CommentItem .CommentContent{float:left;width:55%;padding-left:1em;border:none}.CommentItem .CommentContent .CommentChildrenInfo{margin-top:.5em}.CommentItem .CommentContent .CommentReplyInfo{margin-bottom:0}.CommentItem .CommentContent .CommentText{cursor:pointer;padding-right:1em}.CommentItem .CommentContent .CommentText textarea{font-size:1em;width:100%;min-height:18em;margin-top:1em;margin-bottom:1em}.CommentItem .CommentContent .CommentText .CommentTextEdit{white-space:nowrap}.CommentItem .CommentContent .CommentTextOverflow{overflow-y:scroll;max-height:18em}.CommentItem .CommentContent.CommentContentLarge .CommentTextOverflow{max-height:24em}.CommentItem label.CommentStatus{white-space:nowrap;display:inline-block}.CommentItem.CommentItemStatus999{display:none}.CommentCheckAll label .detail,.CommentItem .CommentTitle th label .detail{font-weight:bold;color:#444}.pw-content .MarkupPagerNav{padding-top:.5em;float:right}.pw-content .MarkupPagerNav+button{margin-top:1em}.AdminThemeReno .pw-content .MarkupPagerNav li a,.AdminThemeReno .pw-content .MarkupPagerNav li:first-child a,.AdminThemeReno .pw-content .MarkupPagerNav li.MarkupPagerNavOn a{border-color:#fff !important;border:none !important;border-left:1px solid #fff !important}.AdminThemeReno .pw-content .MarkupPagerNav li{margin-bottom:1px}.AdminThemeReno .pw-content #CommentListHeader{border-top:1px solid #eee}.AdminThemeReno .pw-content #CommentListHeader .MarkupPagerNav{margin-top:.5em}@media only screen and (max-width: 960px){.pw-content .MarkupPagerNav{float:none}#CommentListHeader{padding-bottom:1em;padding-top:1em}#CommentListHeader .MarkupPagerNav{float:none}#CommentListHeader p{margin-top:0;margin-bottom:0;padding-right:1em;padding-left:0 !important}#CommentListHeader .CommentCheckAll{width:auto}}@media only screen and (max-width: 768px){.CommentItem table{width:100%;float:none}.CommentItem table th{padding-left:0 !important}.CommentItem .CommentContent{width:100%;float:none;padding-left:0}.CommentItem .CommentContent .CommentText{padding-right:0}.CommentItem .CommentContent .CommentTextOverflow{overflow-y:auto;max-height:inherit}}.WireTabs{opacity:0}
diff --git a/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.module b/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.module
index ec8dd583..baf02ff7 100644
--- a/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.module
+++ b/wire/modules/Process/ProcessCommentsManager/ProcessCommentsManager.module
@@ -71,6 +71,14 @@ class ProcessCommentsManager extends Process {
*/
protected $statusTranslations = array();
+ /**
+ * Translated flags
+ *
+ * @var array
+ *
+ */
+ protected $notifyFlagsTranslations = array();
+
/**
* Number of comments to show per page
*
@@ -112,6 +120,11 @@ class ProcessCommentsManager extends Process {
Comment::statusSpam => $this->_('Spam'),
Comment::statusDelete => $this->_('Delete')
);
+ $this->notifyFlagsTranslations = array(
+ 0 => $this->_('No'),
+ Comment::flagNotifyAll => $this->_('All'),
+ Comment::flagNotifyReply => $this->_('Replies'),
+ );
$this->labelAll = $this->_('All');
}
@@ -357,6 +370,23 @@ class ProcessCommentsManager extends Process {
$numChanged++;
$properties['status'] = $comment->status;
}
+
+ $notify = $input->post("CommentNotify{$comment->id}");
+ if($field->useNotify && ctype_digit($notify)) {
+ $notify = (int) $notify;
+ if($notify === 0 && $comment->flags) {
+ if($comment->flags & Comment::flagNotifyAll) $comment->flags = $comment->flags & ~Comment::flagNotifyAll;
+ if($comment->flags & Comment::flagNotifyReply) $comment->flags = $comment->flags & ~Comment::flagNotifyReply;
+ if($comment->flags & Comment::flagNotifyConfirmed) $comment->flags = $comment->flags & ~Comment::flagNotifyConfirmed;
+ $properties['flags'] = $comment->flags;
+ } else if($notify === Comment::flagNotifyAll && !($comment->flags & Comment::flagNotifyAll)) {
+ $comment->flags = $comment->flags | Comment::flagNotifyAll;
+ $properties['flags'] = $comment['flags'];
+ } else if($notify === Comment::flagNotifyReply) {
+ $comment->flags = $comment->flags | Comment::flagNotifyReply;
+ $properties['flags'] = $comment['flags'];
+ }
+ }
$changePage = null;
if($allowChangePage) {
@@ -476,6 +506,7 @@ class ProcessCommentsManager extends Process {
$outs = array(
'status' => '',
+ 'notify' => '',
'website' => '',
'stars' => '',
'votes' => '',
@@ -509,6 +540,7 @@ class ProcessCommentsManager extends Process {
'replyTo' => $this->_('Reply to %s'),
'stars' => $this->_('Stars'),
'votes' => $this->_('Votes'),
+ 'notify' => $this->_('Notify'),
'commentId' => $this->_('Comment ID'),
);
@@ -627,6 +659,24 @@ class ProcessCommentsManager extends Process {
" " .
"" .
"";
+
+ if($field->useNotify) {
+ foreach($this->notifyFlagsTranslations as $flag => $label) {
+ $checked = false;
+ if($flag && $comment->flags & $flag) {
+ $checked = true; // All or Replies
+ } else if(!$flag && !($comment->flags & 2) && !($comment->flags & 4) && !($comment->flags & 8)) {
+ $checked = true; // None
+ }
+ $checked = $checked ? "checked='checked' " : '';
+ $outs['notify'] .=
+ " ";
+ }
+ $outs['notify'] = "$labels[notify] | $outs[notify] |
";
+ }
if($parent) {
$a = $sanitizer->entities($parent->cite) . " $parent->id";
@@ -645,6 +695,14 @@ class ProcessCommentsManager extends Process {
"" .
"
";
+ /** @var FieldtypeComments $fieldtype */
+ // $fieldtype = $field->type;
+ // $who = $fieldtype->getNotifyEmails($page, $field, $comment);
+ // $text .= "" . htmlentities(print_r($who, true)) . "
";
+ $numRows = 0;
+ foreach($outs as $out) if(!empty($out)) $numRows++;
+ $contentClass = 'CommentContent';
+ if($numRows >= 7) $contentClass .= ' CommentContentLarge';
$out =
"