From d80aaf904592a2a3fa414918bd5b71737112e4ad Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 25 Feb 2020 07:46:08 -0500 Subject: [PATCH] [widget_like] Add support for system.hide_dislike user config key --- widgets/templates/widget_like.tpl | 4 +++- widgets/widget_like.php | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/widgets/templates/widget_like.tpl b/widgets/templates/widget_like.tpl index ad529575..b99dbda4 100644 --- a/widgets/templates/widget_like.tpl +++ b/widgets/templates/widget_like.tpl @@ -1,3 +1,5 @@ -{{$like}} like +{{$like}} like +{{if $dislike}} {{$dislike}} dislike +{{/if}} diff --git a/widgets/widget_like.php b/widgets/widget_like.php index 464e6101..8dd6b8a7 100644 --- a/widgets/widget_like.php +++ b/widgets/widget_like.php @@ -43,14 +43,18 @@ function like_widget_content(&$a, $conf){ DBA::escape($args[0]) ); $likes = $r[0]['c']; - $iid = $r[0]['id']; - // count dislikes - $r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'", - intval($conf['uid']), - DBA::escape($args[0]) - ); - $dislikes = $r[0]['c']; + $dislikes = 0; + $strdislike = ''; + if (!DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { + // count dislikes + $r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'", + intval($conf['uid']), + DBA::escape($args[0]) + ); + $dislikes = $r[0]['c']; + $strdislike = DI::l10n()->tt("%d person doesn't like this", "%d people don't like this", $dislikes); + } $o = ""; @@ -62,7 +66,7 @@ function like_widget_content(&$a, $conf){ '$strlike' => DI::l10n()->tt("%d person likes this", "%d people like this", $likes), '$dislike' => $dislikes, - '$strdislike'=> DI::l10n()->tt("%d person doesn't like this", "%d people don't like this", $dislikes), + '$strdislike'=> $strdislike, ]); return $o;