]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Directory/lib/sortablegrouplist.php
Don't check Link header if not set
[quix0rs-gnu-social.git] / plugins / Directory / lib / sortablegrouplist.php
index fbb8ba826fcafcdb8005e1ee3289ffa94a4d09f2..ab00068f6d20a5f438794e1986dc3d07a98db8b8 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-require_once INSTALLDIR . '/lib/subscriptionlist.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Widget to show a sortable list of subscriptions
@@ -44,16 +40,6 @@ require_once INSTALLDIR . '/lib/subscriptionlist.php';
  */
 class SortableGroupList extends SortableSubscriptionList
 {
-    /** Owner of this list */
-    var $owner = null;
-
-    function __construct($profile, $owner=null, $action=null)
-    {
-        parent::__construct($profile, $owner, $action);
-
-        $this->owner = $owner;
-    }
-
     function startList()
     {
         $this->out->elementStart('table', array('class' => 'profile_list xoxo'));
@@ -119,25 +105,14 @@ class SortableGroupList extends SortableSubscriptionList
         $this->out->elementStart('tbody');
     }
 
-    function newListItem($profile, $odd)
+    function newListItem($profile)
     {
-        return new SortableGroupListItem($profile, $this->owner, $this->action, $odd);
+        return new SortableGroupListItem($profile, $this->owner, $this->action);
     }
 }
 
 class SortableGroupListItem extends SortableSubscriptionListItem
 {
-    /** Owner of this list */
-    var $owner = null;
-
-    function __construct($profile, $owner, $action, $alt)
-    {
-        parent::__construct($profile, $owner, $action, $alt);
-
-        $this->alt   = $alt; // is this row alternate?
-        $this->owner = $owner;
-    }
-
     function showHomepage()
     {
         if (!empty($this->profile->homepage)) {
@@ -167,12 +142,13 @@ class SortableGroupListItem extends SortableSubscriptionListItem
 
     }
 
+    // TODO: Make sure we can do ->getAvatar() for group profiles too!
     function showAvatar(Profile $profile, $size=null)
     {
         $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize());
 
         $this->out->element('img', array('src'    => $logo,
-                                         'class'  => 'photo avatar',
+                                         'class'  => 'avatar u-photo',
                                          'width'  => AVATAR_STREAM_SIZE,
                                          'height' => AVATAR_STREAM_SIZE,
                                          'alt'    => $profile->getBestName()));
@@ -205,14 +181,11 @@ class SortableGroupListItem extends SortableSubscriptionListItem
     {
         $this->startProfile();
 
-        $this->out->elementStart('a', array('href'  => $this->profile->homeUrl(),
-                                            'class' => 'h-card p-org p-nickname',
-                                            'rel'   => 'contact group'));
-        // getProfile here is because $this->profile is a User_group, which it should stop
-        // being by making sure the group listing runs a ->getGroup when it's necessary.
         $this->showAvatar($this->profile->getProfile());
-        $this->out->text($this->profile->getNickname());
-        $this->out->elementEnd('a');
+        $this->out->element('a', array('href'  => $this->profile->homeUrl(),
+                                            'class' => 'p-org p-nickname',
+                                            'rel'   => 'contact group'),
+                                 $this->profile->getNickname());
 
         $this->showFullName();
         $this->showLocation();
@@ -223,6 +196,23 @@ class SortableGroupListItem extends SortableSubscriptionListItem
         $this->endProfile();
     }
 
+    function endActions()
+    {
+        // delete button
+        $cur = common_current_user();
+        list($action, $r2args) = $this->out->returnToArgs();
+        $r2args['action'] = $action;
+        if ($cur instanceof User && $cur->hasRight(Right::DELETEGROUP)) {
+            $this->out->elementStart('li', 'entity_delete');
+            $df = new DeleteGroupForm($this->out, $this->profile, $r2args);
+            $df->show();
+            $this->out->elementEnd('li');
+        }
+
+        $this->out->elementEnd('ul');
+        $this->out->elementEnd('td');
+    }
+
     function showActions()
     {
         $this->startActions();