]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/groupsnav.php
List groups with nickname instead of full name in sidebar
[quix0rs-gnu-social.git] / lib / groupsnav.php
index 3d282f5e1d88aa1b10d968ae1b70ea31f4b7a0cd..738604583ca3f07c35391ea6e35b3dd00987a4b9 100644 (file)
@@ -58,7 +58,7 @@ class GroupsNav extends MoreMenu
 
     function haveGroups()
     {
-        return (!empty($this->groups) && ($this->groups->N > 0));
+        return ($this->groups instanceof User_group && $this->groups->N > 0);
     }
 
     function tag()
@@ -70,10 +70,11 @@ class GroupsNav extends MoreMenu
     {
         $items = array();
 
-        while ($this->groups->fetch()) {
-            $items[] = array('showgroup',
-                             array('nickname' => $this->groups->nickname),
-                             $this->groups->getBestName(),
+        while ($this->groups instanceof User_group && $this->groups->fetch()) {
+            $items[] = array('placeholder',
+                             array('nickname' => $this->groups->getNickname(),
+                                   'mainpage' => $this->groups->homeUrl()),
+                             $this->groups->getNickname(),
                              $this->groups->getBestName()
                             );
         }
@@ -90,4 +91,23 @@ class GroupsNav extends MoreMenu
                      _('See all groups you belong to.'));
     }
 
+    function item($actionName, array $args, $label, $description, $id=null, $cls=null)
+    {
+        if ($actionName != 'placeholder') {
+            return parent::item($actionName, $args, $label, $description, $id, $cls);
+        }
+
+        if (empty($id)) {
+            $id = $this->menuItemID('showgroup', array('nickname' => $args['nickname']));
+        }
+
+        $url = $args['mainpage'];
+
+        $this->out->menuItem($url,
+                             $label,
+                             $description,
+                             $this->isCurrent($actionName, $args),
+                             $id,
+                             $cls);
+    }
 }