From 1472f85b162ea6f1ab9e19e94b86fc4a8ef074be Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Jun 2017 22:25:41 -0700 Subject: allow moderated comments like wordpress if permissions are compatible --- Zotlabs/Lib/Enotify.php | 11 ++++++++++- Zotlabs/Lib/ThreadItem.php | 8 ++++++-- Zotlabs/Lib/ThreadStream.php | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index a10675a87..114021568 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -170,6 +170,7 @@ class Enotify { xchan_query($p); + $moderated = (($p[0]['item_blocked'] = ITEM_MODERATED) ? true : false); $item_post_type = item_post_type($p[0]); // $private = $p[0]['item_private']; @@ -208,13 +209,21 @@ class Enotify { // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. - $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); + if($moderated) + $subject = sprintf( t('[$Projectname:Notify] Moderated Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); + else + $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s commented on an item/conversation you have been following.'), $recip['channel_name'], $sender['xchan_name']); $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); + if($moderated) { + $tsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); + $hsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); + } + } if ($params['type'] == NOTIFY_LIKE) { diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 5910ea672..5bb5982f8 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -743,8 +743,12 @@ class ThreadItem { '$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $conv->get_cipher(), - '$sourceapp' => \App::$sourcename - + '$sourceapp' => \App::$sourcename, + '$observer' => get_observer_hash(), + '$anoncomments' => perm_is_allowed($conv->get_profile_owner(),'','post_comments'), + '$anonname' => [ 'anonname', t('Your full name (required)'),'','' ], + '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','' ], + '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','' ] )); return $comment_box; diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index beb626f31..1fd746c38 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -158,7 +158,7 @@ class ThreadStream { if(intval($item->get_data_value('item_nocomment'))) { $item->set_commentable(false); } - elseif(($this->observer) && (! $item->is_commentable())) { + elseif(! $item->is_commentable()) { if((array_key_exists('owner',$item->data)) && intval($item->data['owner']['abook_self'])) $item->set_commentable(perm_is_allowed($this->profile_owner,$ob_hash,'post_comments')); else -- cgit v1.2.3 From 3b5e1c05b78f72a31eda76b0ff90d08b58ee452d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Jun 2017 22:51:52 -0700 Subject: minor cleanup of moderated comment feature --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 114021568..90662ce84 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -221,7 +221,7 @@ class Enotify { $hsitelink = sprintf( $sitelink, '' . $sitename . ''); if($moderated) { $tsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); - $hsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); + $hsitelink .= "

" . sprintf( t('Please visit %s to approve or reject this comment.'), '' . z_root() . '/moderate' ); } } -- cgit v1.2.3 From 4c96b9778ec056dc0e828302395dc5334e0eac24 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 05:11:07 -0700 Subject: prevent likes/dislikes/etc. from anon commenters --- Zotlabs/Lib/ThreadItem.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 5bb5982f8..97241a7a1 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -153,7 +153,7 @@ class ThreadItem { $response_verbs[] = 'attendyes'; $response_verbs[] = 'attendno'; $response_verbs[] = 'attendmaybe'; - if($this->is_commentable()) { + if($this->is_commentable() && $observer) { $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); } @@ -164,7 +164,7 @@ class ThreadItem { $response_verbs[] = 'agree'; $response_verbs[] = 'disagree'; $response_verbs[] = 'abstain'; - if($this->is_commentable()) { + if($this->is_commentable() && $observer) { $conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); $canvote = true; } @@ -265,7 +265,7 @@ class ThreadItem { if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_channel()) $has_event = true; - if($this->is_commentable()) { + if($this->is_commentable() && $observer) { $like = array( t("I like this \x28toggle\x29"), t("like")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); } @@ -371,7 +371,7 @@ class ThreadItem { 'has_tags' => $has_tags, 'reactions' => $this->reactions, // Item toolbar buttons - 'emojis' => (($this->is_toplevel() && $this->is_commentable() && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''), + 'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''), 'like' => $like, 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''), 'share' => $share, -- cgit v1.2.3 From 76e98091690cf5f2726bf7cefea217d49b23a5b4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 12:45:05 -0700 Subject: more anon comment fixes --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 97241a7a1..917397686 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -745,7 +745,7 @@ class ThreadItem { '$cipher' => $conv->get_cipher(), '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), - '$anoncomments' => perm_is_allowed($conv->get_profile_owner(),'','post_comments'), + '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), '$anonname' => [ 'anonname', t('Your full name (required)'),'','' ], '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','' ], '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','' ] -- cgit v1.2.3