]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/AnonymousFave/AnonymousFavePlugin.php
- Increment/decrement notice fave tally
[quix0rs-gnu-social.git] / plugins / AnonymousFave / AnonymousFavePlugin.php
index 98f747748c297ee26043a216fd5a481f691860e8..984625a8811f9238f3e29233df41aed819175dd4 100644 (file)
@@ -136,6 +136,27 @@ class AnonymousFavePlugin extends Plugin {
         return true;
     }
 
+
+    function onEndShowNoticeInfo($item)
+    {
+        common_debug("XXXXXXXXXXX onEndShowNoticeInfo");
+
+        $tally = Fave_tally::ensureTally($item->notice->id);
+
+        if (!empty($tally)) {
+            $item->out->elementStart(
+                'div',
+                array(
+                    'id' => 'notice-' . $item->notice->id . '-tally',
+                    'class' => 'notice-tally'
+                )
+            );
+            $item->out->raw(sprintf(_m("favored %d times"), $tally->count));
+            $item->out->elementEnd('div');
+        }
+        return true;
+    }
+
     function onStartShowNoticeOptions($item) {
 
         if (!common_logged_in()) {
@@ -166,6 +187,16 @@ class AnonymousFavePlugin extends Plugin {
         return true;
     }
 
+    function onEndFavorNotice($profile, $notice)
+    {
+        $tally = Fave_tally::increment($notice->id);
+    }
+
+    function onEndDisfavorNotice($profile, $notice)
+    {
+        $tally = Fave_tally::decrement($notice->id);
+    }
+
     function createAnonProfile() {
 
         // Get the anon user's IP, and turn it into a nickname