]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Work in progress: adding link for managing tag subscriptions. Needs the action still...
authorBrion Vibber <brion@pobox.com>
Wed, 16 Mar 2011 19:28:26 +0000 (12:28 -0700)
committerBrion Vibber <brion@pobox.com>
Wed, 16 Mar 2011 19:28:26 +0000 (12:28 -0700)
plugins/TagSub/TagSubPlugin.php

index e51a7a8b39ff41392d377271326356ae8ab6b580..e3c11ac1ef6d214fce0a9e6eead5322f1b07a30e 100644 (file)
@@ -179,4 +179,60 @@ class TagSubPlugin extends Plugin
         }
         return true;
     }
+
+    /**
+     * Menu item for personal subscriptions/groups area
+     *
+     * @param Widget $widget Widget being executed
+     *
+     * @return boolean hook return
+     */
+
+    function onEndSubGroupNav($widget)
+    {
+        $action = $widget->out;
+        $action_name = $action->trimmed('action');
+
+        $widget->item('tagsubs',
+                      array(),
+                      // TRANS: SubMirror plugin menu item on user settings page.
+                      _m('MENU', 'Tags'),
+                      // TRANS: SubMirror plugin tooltip for user settings menu item.
+                      _m('Configure tag subscriptions'));
+
+        return true;
+    }
+
+    /**
+     * Add a count of mirrored feeds into a user's profile sidebar stats.
+     *
+     * @param Profile $profile
+     * @param array $stats
+     * @return boolean hook return value
+     */
+    function onProfileStats($profile, &$stats)
+    {
+        $cur = common_current_user();
+        if (!empty($cur) && $cur->id == $profile->id) {
+            $tagsub = new TagSub();
+            $tagsub->profile_id = $profile->id;
+            $entry = array(
+                'id' => 'tagsubs',
+                'label' => _m('Tag subscriptions'),
+                'link' => common_local_url('tagsubs'),
+                'value' => $tagsub->count(),
+            );
+
+            $insertAt = count($stats);
+            foreach ($stats as $i => $row) {
+                if ($row['id'] == 'groups') {
+                    // Slip us in after them.
+                    $insertAt = $i + 1;
+                    break;
+                }
+            }
+            array_splice($stats, $insertAt, 0, array($entry));
+        }
+        return true;
+    }
 }