]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/groupsnav.php
Don't trust local HTML either
[quix0rs-gnu-social.git] / lib / groupsnav.php
index b060153f88e5c116d6924fb5c847dfcb673d91ce..738604583ca3f07c35391ea6e35b3dd00987a4b9 100644 (file)
@@ -44,7 +44,7 @@ if (!defined('STATUSNET')) {
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  * @link      http://status.net/
  */
-class GroupsNav extends Menu
+class GroupsNav extends MoreMenu
 {
     protected $user;
     protected $groups;
@@ -58,7 +58,7 @@ class GroupsNav extends Menu
 
     function haveGroups()
     {
-        return (!empty($this->groups) && ($this->groups->N > 0));
+        return ($this->groups instanceof User_group && $this->groups->N > 0);
     }
 
     function tag()
@@ -70,15 +70,44 @@ class GroupsNav extends Menu
     {
         $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()
                             );
         }
 
         return $items;
     }
-    
+
+    function seeAllItem() {
+        return array('usergroups',
+                     array('nickname' => $this->user->nickname),
+                     // TRANS: Link description for seeing all groups.
+                     _('See all'),
+                     // TRANS: Link title for seeing all groups.
+                     _('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);
+    }
 }