We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

groups.php 3.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<?php
/**
 * Laconica, the distributed open-source microblogging tool
 *
 * Latest groups information
 *
 * 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  Personal
 * @package   Laconica
 * @author    Evan Prodromou <evan@controlyourself.ca>
 * @author    Sarven Capadisli <csarven@controlyourself.ca>
 * @copyright 2008-2009 Control Yourself, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://laconi.ca/
 */

if (!defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR.'/lib/grouplist.php';

/**
 * Latest groups
 *
 * Show the latest groups on the site
 *
 * @category Personal
 * @package  Laconica
 * @author   Evan Prodromou <evan@controlyourself.ca>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://laconi.ca/
 */

class GroupsAction extends Action
{
    var $page = null;
    var $profile = null;

54
    function isReadOnly($args)
Evan Prodromou's avatar
Evan Prodromou committed
55 56 57 58
    {
        return true;
    }

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
    function title()
    {
        if ($this->page == 1) {
            return _("Groups");
        } else {
            return sprintf(_("Groups, page %d"), $this->page);
        }
    }

    function prepare($args)
    {
        parent::prepare($args);
        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
        return true;
    }

    function handle($args)
    {
        parent::handle($args);
        $this->showPage();
    }

    function showLocalNav()
    {
        $nav = new PublicGroupNav($this);
        $nav->show();
    }

    function showPageNotice()
    {
        $notice =
          sprintf(_('%%%%site.name%%%% groups let you find and talk with ' .
                    'people of similar interests. After you join a group ' .
                    'you can send messages to all other members using the ' .
                    'syntax "!groupname". Don\'t see a group you like? Try ' .
                    '[searching for one](%%%%action.groupsearch%%%%) or ' .
                    '[start your own!](%%%%action.newgroup%%%%)'));
        $this->elementStart('div', 'instructions');
        $this->raw(common_markup_to_html($notice));
        $this->elementEnd('div');
    }

    function showContent()
    {
sarven's avatar
sarven committed
103
        $this->elementStart('p', array('id' => 'new_group'));
104
        $this->element('a', array('href' => common_local_url('newgroup'),
sarven's avatar
sarven committed
105
                                  'class' => 'more'),
106
                       _('Create a new group'));
sarven's avatar
sarven committed
107
        $this->elementEnd('p');
108 109

        $offset = ($this->page-1) * GROUPS_PER_PAGE;
110
        $limit =  GROUPS_PER_PAGE + 1;
111 112

        $groups = new User_group();
113 114
        $groups->orderBy('created DESC');
        $groups->limit($offset, $limit);
115 116 117 118 119 120 121

        if ($groups->find()) {
            $gl = new GroupList($groups, null, $this);
            $cnt = $gl->show();
        }

        $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
122
                          $this->page, 'groups');
123
    }
Evan Prodromou's avatar
Evan Prodromou committed
124 125 126 127 128

    function showSections()
    {
        $gbp = new GroupsByPostsSection($this);
        $gbp->show();
Evan Prodromou's avatar
Evan Prodromou committed
129 130
        $gbm = new GroupsByMembersSection($this);
        $gbm->show();
Evan Prodromou's avatar
Evan Prodromou committed
131
    }
132
}