]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fixes #1088: Show number of group members. Unlike the bugreport requested, the stats...
authorAdrian Lang <mail@adrianlang.de>
Sun, 1 Feb 2009 21:24:54 +0000 (22:24 +0100)
committerAdrian Lang <mail@adrianlang.de>
Sun, 1 Feb 2009 21:24:54 +0000 (22:24 +0100)
actions/showgroup.php
classes/User_group.php
lib/profileminilist.php

index c29b7d4263e814689e6b8d06675beb7637625e95..468990e7ba1051396ddeebc935d2e14fcdb6daeb 100644 (file)
@@ -333,6 +333,7 @@ class ShowgroupAction extends Action
     function showSections()
     {
         $this->showMembers();
+        $this->showStatistics();
         $cloud = new GroupTagCloudSection($this, $this->group);
         $cloud->show();
     }
@@ -356,12 +357,10 @@ class ShowgroupAction extends Action
 
         $this->element('h2', null, _('Members'));
 
-        if ($member) {
-            $pml = new ProfileMiniList($member, null, $this);
-            $cnt = $pml->show();
-            if ($cnt == 0) {
-                $this->element('p', null, _('(None)'));
-            }
+        $pml = new ProfileMiniList($member, null, $this);
+        $cnt = $pml->show();
+        if ($cnt == 0) {
+             $this->element('p', null, _('(None)'));
         }
 
         if ($cnt == MEMBERS_PER_SECTION) {
@@ -373,6 +372,41 @@ class ShowgroupAction extends Action
         $this->elementEnd('div');
     }
 
+    /**
+     * Show some statistics
+     *
+     * @return void
+     */
+
+    function showStatistics()
+    {
+        // XXX: WORM cache this
+        $members = $this->group->getMembers();
+        $members_count = 0;
+        /** $member->count() doesn't work. */
+        while ($members->fetch()) {
+            $members_count++;
+        }
+
+        $this->elementStart('div', array('id' => 'entity_statistics',
+                                         'class' => 'section'));
+
+        $this->element('h2', null, _('Statistics'));
+
+        $this->elementStart('dl', 'entity_created');
+        $this->element('dt', null, _('Created'));
+        $this->element('dd', null, date('j M Y',
+                                                 strtotime($this->group->created)));
+        $this->elementEnd('dl');
+
+        $this->elementStart('dl', 'entity_members');
+        $this->element('dt', null, _('Members'));
+        $this->element('dd', null, (is_int($members_count)) ? $members_count : '0');
+        $this->elementEnd('dl');
+
+        $this->elementEnd('div');
+    }
+
     function showAnonymousMessage()
     {
                $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
index 5b5b102c753f526ac556e9b0b563af8adbd4734c..522dd81436f94402ba18539c9bb49a8f49bbe295 100755 (executable)
@@ -74,16 +74,17 @@ class User_group extends Memcached_DataObject
           'WHERE group_member.group_id = %d ' .
           'ORDER BY group_member.created DESC ';
 
-        if (common_config('db','type') == 'pgsql') {
-            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
-        } else {
-            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+        if ($limit != null) {
+            if (common_config('db','type') == 'pgsql') {
+                $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+            } else {
+                $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+            }
         }
 
         $members = new Profile();
 
-        $cnt = $members->query(sprintf($qry, $this->id));
-
+        $members->query(sprintf($qry, $this->id));
         return $members;
     }
 
index 56b76841945cc4ee0ac1c76bc64dcd6f95376c21..81cd7aed5583f66ffb06ab88e9c597d63cba2f8a 100644 (file)
@@ -69,9 +69,7 @@ class ProfileMiniList extends ProfileList
     function showProfile()
     {
         $this->out->elementStart('li', 'vcard');
-        $this->out->elementStart('a', array('title' => ($this->profile->fullname) ?
-                                       $this->profile->fullname :
-                                       $this->profile->nickname,
+        $this->out->elementStart('a', array('title' => $this->profile->getBestName(),
                                        'href' => $this->profile->profileurl,
                                        'rel' => 'contact member',
                                        'class' => 'url'));