groupsbymemberssection.php 2.62 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1 2
<?php
/**
3
 * StatusNet, the distributed open-source microblogging tool
Evan Prodromou's avatar
Evan Prodromou committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * Groups with the most members section
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Widget
23
 * @package   StatusNet
24
 * @author    Evan Prodromou <evan@status.net>
25
 * @copyright 2009 StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
26
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27
 * @link      http://status.net/
Evan Prodromou's avatar
Evan Prodromou committed
28 29
 */

30
if (!defined('STATUSNET') && !defined('LACONICA')) {
Evan Prodromou's avatar
Evan Prodromou committed
31 32 33 34 35 36 37
    exit(1);
}

/**
 * Groups with the most members section
 *
 * @category Widget
38
 * @package  StatusNet
39
 * @author   Evan Prodromou <evan@status.net>
Evan Prodromou's avatar
Evan Prodromou committed
40
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41
 * @link     http://status.net/
Evan Prodromou's avatar
Evan Prodromou committed
42 43 44 45 46
 */
class GroupsByMembersSection extends GroupSection
{
    function getGroups()
    {
47
        $qry = 'SELECT user_group.*, count(*) as value ' .
Evan Prodromou's avatar
Evan Prodromou committed
48 49
          'FROM user_group JOIN group_member '.
          'ON user_group.id = group_member.group_id ' .
50
          'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' .
Evan Prodromou's avatar
Evan Prodromou committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
          'ORDER BY value DESC ';

        $limit = GROUPS_PER_SECTION;
        $offset = 0;

        if (common_config('db','type') == 'pgsql') {
            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
        } else {
            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
        }

        $group = Memcached_DataObject::cachedQuery('User_group',
                                                   $qry,
                                                   3600);
        return $group;
    }

    function title()
    {
70
        // TRANS: Title for groups with the most members section.
71
        return _('Popular groups');
Evan Prodromou's avatar
Evan Prodromou committed
72 73 74 75 76 77 78
    }

    function divId()
    {
        return 'top_groups_by_member';
    }
}