2009-01-23 11:00:51 +09:00
|
|
|
<?php
|
|
|
|
/**
|
2009-08-26 07:12:20 +09:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2009-01-23 11:00:51 +09:00
|
|
|
*
|
|
|
|
* 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
|
2009-08-26 07:12:20 +09:00
|
|
|
* @package StatusNet
|
2009-08-26 07:19:04 +09:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
2009-08-26 07:12:20 +09:00
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
2009-01-23 11:00:51 +09:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-26 07:16:46 +09:00
|
|
|
* @link http://status.net/
|
2009-01-23 11:00:51 +09:00
|
|
|
*/
|
|
|
|
|
2009-08-26 23:41:36 +09:00
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
2009-01-23 11:00:51 +09:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once INSTALLDIR.'/lib/grouplist.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Latest groups
|
|
|
|
*
|
|
|
|
* Show the latest groups on the site
|
|
|
|
*
|
|
|
|
* @category Personal
|
2009-08-26 07:12:20 +09:00
|
|
|
* @package StatusNet
|
2009-08-26 07:19:04 +09:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-01-23 11:00:51 +09:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-26 07:16:46 +09:00
|
|
|
* @link http://status.net/
|
2009-01-23 11:00:51 +09:00
|
|
|
*/
|
|
|
|
class GroupsAction extends Action
|
|
|
|
{
|
|
|
|
var $page = null;
|
|
|
|
var $profile = null;
|
|
|
|
|
2009-04-14 04:49:26 +09:00
|
|
|
function isReadOnly($args)
|
2009-01-23 17:49:38 +09:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-23 11:00:51 +09:00
|
|
|
function title()
|
|
|
|
{
|
|
|
|
if ($this->page == 1) {
|
2011-02-01 02:16:55 +09:00
|
|
|
// TRANS: Title for first page of the groups list.
|
|
|
|
return _m('TITLE',"Groups");
|
2009-01-23 11:00:51 +09:00
|
|
|
} else {
|
2011-02-01 02:16:55 +09:00
|
|
|
// TRANS: Title for all but the first page of the groups list.
|
|
|
|
// TRANS: %d is the page number.
|
|
|
|
return sprintf(_m('TITLE',"Groups, page %d"), $this->page);
|
2009-01-23 11:00:51 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 =
|
2011-02-01 02:16:55 +09:00
|
|
|
// TRANS: Page notice of group list. %%%%site.name%%%% is the StatusNet site name,
|
|
|
|
// TRANS: %%%%action.groupsearch%%%% and %%%%action.newgroup%%%% are URLs. Do not change them.
|
|
|
|
// TRANS: This message contains Markdown links in the form [link text](link).
|
2009-01-23 11:00:51 +09:00
|
|
|
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 ' .
|
2011-02-01 02:16:55 +09:00
|
|
|
'[start your own](%%%%action.newgroup%%%%)!'));
|
2009-01-23 11:00:51 +09:00
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw(common_markup_to_html($notice));
|
|
|
|
$this->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
|
|
|
function showContent()
|
|
|
|
{
|
2009-06-16 08:22:08 +09:00
|
|
|
if (common_logged_in()) {
|
|
|
|
$this->elementStart('p', array('id' => 'new_group'));
|
|
|
|
$this->element('a', array('href' => common_local_url('newgroup'),
|
|
|
|
'class' => 'more'),
|
2011-02-01 02:16:55 +09:00
|
|
|
// TRANS: Link to create a new group on the group list page.
|
2009-06-16 08:22:08 +09:00
|
|
|
_('Create a new group'));
|
|
|
|
$this->elementEnd('p');
|
|
|
|
}
|
2009-01-23 11:00:51 +09:00
|
|
|
|
|
|
|
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
2010-02-25 22:44:15 +09:00
|
|
|
$limit = GROUPS_PER_PAGE + 1;
|
|
|
|
|
|
|
|
$qry = 'SELECT user_group.* '.
|
|
|
|
'from user_group join local_group on user_group.id = local_group.group_id '.
|
|
|
|
'order by user_group.created desc '.
|
|
|
|
'limit ' . $limit . ' offset ' . $offset;
|
2009-01-23 11:00:51 +09:00
|
|
|
|
|
|
|
$groups = new User_group();
|
|
|
|
|
2009-06-12 20:49:33 +09:00
|
|
|
$cnt = 0;
|
2010-02-25 22:44:15 +09:00
|
|
|
|
|
|
|
$groups->query($qry);
|
|
|
|
|
|
|
|
$gl = new GroupList($groups, null, $this);
|
|
|
|
$cnt = $gl->show();
|
2009-01-23 11:00:51 +09:00
|
|
|
|
|
|
|
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
|
2009-01-24 19:05:38 +09:00
|
|
|
$this->page, 'groups');
|
2009-01-23 11:00:51 +09:00
|
|
|
}
|
2009-01-23 11:03:17 +09:00
|
|
|
|
|
|
|
function showSections()
|
|
|
|
{
|
|
|
|
$gbp = new GroupsByPostsSection($this);
|
|
|
|
$gbp->show();
|
2009-01-23 11:07:03 +09:00
|
|
|
$gbm = new GroupsByMembersSection($this);
|
|
|
|
$gbm->show();
|
2009-01-23 11:03:17 +09:00
|
|
|
}
|
2009-01-23 11:00:51 +09:00
|
|
|
}
|