]> git.mxchange.org Git - friendica-addons.git/commitdiff
[widget_like] Add support for system.hide_dislike user config key
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 25 Feb 2020 12:46:08 +0000 (07:46 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 25 Feb 2020 12:46:08 +0000 (07:46 -0500)
widgets/templates/widget_like.tpl
widgets/widget_like.php

index ad5295754bc7b8ccfca03c303a62aa787ff379fe..b99dbda462bba0bf28274129196909d6342136b5 100644 (file)
@@ -1,3 +1,5 @@
 <style>body {font-size: 0.8em; margin: 0px; padding: 0px;}</style>
-<span class='f9k_like' title="{{$strlike}}">{{$like}} <img src="{{$baseurl}}/images/like.gif" alt="like"/></span> 
+<span class='f9k_like' title="{{$strlike}}">{{$like}} <img src="{{$baseurl}}/images/like.gif" alt="like"/></span>
+{{if $dislike}}
 <span class='f9k_dislike' title="{{$strdislike}}">{{$dislike}} <img src="{{$baseurl}}/images/dislike.gif" alt="dislike"/></span>
+{{/if}}
index 464e610102d5c2c8c7b4b6ef13a548cf38f86498..8dd6b8a7a22dd63ede0f1119889d1f673d6b36ff 100644 (file)
@@ -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;