2009-01-23 02:00:51 +00:00
|
|
|
<?php
|
2020-09-15 14:59:27 +01:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social 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.
|
|
|
|
//
|
|
|
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-01-23 02:00:51 +00:00
|
|
|
/**
|
|
|
|
* Latest groups information
|
|
|
|
*
|
|
|
|
* @category Personal
|
2020-09-15 14:59:27 +01:00
|
|
|
* @package GNUsocial
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
2009-08-25 23:12:20 +01:00
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
2020-09-15 14:59:27 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2009-01-23 02:00:51 +00:00
|
|
|
*/
|
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
defined('GNUSOCIAL') || die();
|
2009-01-23 02:00:51 +00:00
|
|
|
|
2019-08-23 13:36:02 +01:00
|
|
|
require_once INSTALLDIR . '/lib/groups/grouplist.php';
|
2009-01-23 02:00:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Latest groups
|
|
|
|
*
|
|
|
|
* Show the latest groups on the site
|
|
|
|
*
|
2020-09-15 14:59:27 +01:00
|
|
|
* @category Personal
|
|
|
|
* @package GNUsocial
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2009-01-23 02:00:51 +00:00
|
|
|
*/
|
|
|
|
class GroupsAction extends Action
|
|
|
|
{
|
2020-09-15 14:59:27 +01:00
|
|
|
public $page = null;
|
|
|
|
public $profile = null;
|
2009-01-23 02:00:51 +00:00
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function isReadOnly($args)
|
2009-01-23 08:49:38 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function title()
|
2009-01-23 02:00:51 +00:00
|
|
|
{
|
|
|
|
if ($this->page == 1) {
|
2011-01-31 17:16:55 +00:00
|
|
|
// TRANS: Title for first page of the groups list.
|
2020-09-15 14:59:27 +01:00
|
|
|
return _m('TITLE', 'Groups');
|
2009-01-23 02:00:51 +00:00
|
|
|
} else {
|
2011-01-31 17:16:55 +00:00
|
|
|
// TRANS: Title for all but the first page of the groups list.
|
|
|
|
// TRANS: %d is the page number.
|
2020-09-15 14:59:27 +01:00
|
|
|
return sprintf(_m('TITLE', 'Groups, page %d'), $this->page);
|
2009-01-23 02:00:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function prepare(array $args = [])
|
2009-01-23 02:00:51 +00:00
|
|
|
{
|
|
|
|
parent::prepare($args);
|
|
|
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function handle()
|
2009-01-23 02:00:51 +00:00
|
|
|
{
|
2016-06-01 03:05:11 +01:00
|
|
|
parent::handle();
|
2009-01-23 02:00:51 +00:00
|
|
|
$this->showPage();
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function showPageNotice()
|
2009-01-23 02:00:51 +00:00
|
|
|
{
|
|
|
|
$notice =
|
2011-01-31 17:16:55 +00: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 02:00:51 +00: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-01-31 17:16:55 +00:00
|
|
|
'[start your own](%%%%action.newgroup%%%%)!'));
|
2009-01-23 02:00:51 +00:00
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw(common_markup_to_html($notice));
|
|
|
|
$this->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function showContent()
|
2009-01-23 02:00:51 +00:00
|
|
|
{
|
2009-06-16 00:22:08 +01:00
|
|
|
if (common_logged_in()) {
|
2020-09-15 14:59:27 +01:00
|
|
|
$this->elementStart('p', ['id' => 'new_group']);
|
|
|
|
$this->element(
|
|
|
|
'a',
|
|
|
|
[
|
|
|
|
'href' => common_local_url('newgroup'),
|
|
|
|
'class' => 'more',
|
|
|
|
],
|
|
|
|
// TRANS: Link to create a new group on the group list page.
|
|
|
|
_('Create a new group')
|
|
|
|
);
|
2009-06-16 00:22:08 +01:00
|
|
|
$this->elementEnd('p');
|
|
|
|
}
|
2009-01-23 02:00:51 +00:00
|
|
|
|
|
|
|
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
2010-02-25 13:44:15 +00:00
|
|
|
$limit = GROUPS_PER_PAGE + 1;
|
|
|
|
|
2009-01-23 02:00:51 +00:00
|
|
|
$groups = new User_group();
|
2020-09-15 14:59:27 +01:00
|
|
|
$groups->selectAdd();
|
|
|
|
$groups->selectAdd('user_group.*');
|
|
|
|
$groups->joinAdd(['id', 'local_group:group_id']);
|
|
|
|
$groups->orderBy('user_group.created DESC, user_group.id DESC');
|
|
|
|
$groups->limit($offset, $limit);
|
|
|
|
$groups->find();
|
2010-02-25 13:44:15 +00:00
|
|
|
|
|
|
|
$gl = new GroupList($groups, null, $this);
|
|
|
|
$cnt = $gl->show();
|
2009-01-23 02:00:51 +00:00
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
$this->pagination(
|
|
|
|
$this->page > 1,
|
|
|
|
$cnt > GROUPS_PER_PAGE,
|
|
|
|
$this->page,
|
|
|
|
'groups'
|
|
|
|
);
|
2009-01-23 02:00:51 +00:00
|
|
|
}
|
2009-01-23 02:03:17 +00:00
|
|
|
|
2020-09-15 14:59:27 +01:00
|
|
|
public function showSections()
|
2009-01-23 02:03:17 +00:00
|
|
|
{
|
|
|
|
$gbp = new GroupsByPostsSection($this);
|
|
|
|
$gbp->show();
|
2009-01-23 02:07:03 +00:00
|
|
|
$gbm = new GroupsByMembersSection($this);
|
|
|
|
$gbm->show();
|
2009-01-23 02:03:17 +00:00
|
|
|
}
|
2009-01-23 02:00:51 +00:00
|
|
|
}
|