forked from GNUsocial/gnu-social
Merge branch 'master' of ../trunk
This commit is contained in:
commit
8ba19b0686
125
actions/groups.php
Normal file
125
actions/groups.php
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
$this->element('a', array('href' => common_local_url('newgroup'),
|
||||||
|
'id' => 'new_group'),
|
||||||
|
_('Create a new group'));
|
||||||
|
|
||||||
|
$offset = ($this->page-1) * GROUPS_PER_PAGE;
|
||||||
|
$limit = GROUPS_PER_PAGE + 1;
|
||||||
|
|
||||||
|
$groups = new User_group();
|
||||||
|
$groups->orderBy('created DESC');
|
||||||
|
$groups->limit($offset, $limit);
|
||||||
|
|
||||||
|
if ($groups->find()) {
|
||||||
|
$gl = new GroupList($groups, null, $this);
|
||||||
|
$cnt = $gl->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
|
||||||
|
$this->page, 'groups');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSections()
|
||||||
|
{
|
||||||
|
$gbp = new GroupsByPostsSection($this);
|
||||||
|
$gbp->show();
|
||||||
|
$gbm = new GroupsByMembersSection($this);
|
||||||
|
$gbm->show();
|
||||||
|
}
|
||||||
|
}
|
@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
define('GROUPS_PER_PAGE', 20);
|
require_once INSTALLDIR.'/lib/grouplist.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User groups page
|
* User groups page
|
||||||
|
@ -93,6 +93,7 @@ RewriteRule ^group/([a-zA-Z0-9]+)/members index.php?action=groupmembers&nickname
|
|||||||
RewriteRule ^group/([0-9]+)/id index.php?action=groupbyid&id=$1 [L,QSA]
|
RewriteRule ^group/([0-9]+)/id index.php?action=groupbyid&id=$1 [L,QSA]
|
||||||
RewriteRule ^group/([a-zA-Z0-9]+)/rss index.php?action=grouprss&nickname=$1 [L,QSA]
|
RewriteRule ^group/([a-zA-Z0-9]+)/rss index.php?action=grouprss&nickname=$1 [L,QSA]
|
||||||
RewriteRule ^group/([a-zA-Z0-9]+)$ index.php?action=showgroup&nickname=$1 [L,QSA]
|
RewriteRule ^group/([a-zA-Z0-9]+)$ index.php?action=showgroup&nickname=$1 [L,QSA]
|
||||||
|
RewriteRule ^group$ index.php?action=groups [L,QSA]
|
||||||
|
|
||||||
# Twitter-compatible API rewrites
|
# Twitter-compatible API rewrites
|
||||||
# XXX: Surely these can be refactored a little -- Zach
|
# XXX: Surely these can be refactored a little -- Zach
|
||||||
|
@ -65,7 +65,7 @@ class Form extends Widget
|
|||||||
{
|
{
|
||||||
$this->out->elementStart('form',
|
$this->out->elementStart('form',
|
||||||
array('id' => $this->id(),
|
array('id' => $this->id(),
|
||||||
'class' => $this->formClass(),
|
'class' => $this->formClass(),
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'action' => $this->action()));
|
'action' => $this->action()));
|
||||||
$this->out->elementStart('fieldset');
|
$this->out->elementStart('fieldset');
|
||||||
@ -88,7 +88,6 @@ class Form extends Widget
|
|||||||
$this->out->hidden('token', common_session_token());
|
$this->out->hidden('token', common_session_token());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the form
|
* Name of the form
|
||||||
*
|
*
|
||||||
@ -101,7 +100,6 @@ class Form extends Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visible or invisible data elements
|
* Visible or invisible data elements
|
||||||
*
|
*
|
||||||
@ -154,7 +152,7 @@ class Form extends Widget
|
|||||||
function action()
|
function action()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class of the form.
|
* Class of the form.
|
||||||
*
|
*
|
||||||
@ -163,6 +161,6 @@ class Form extends Widget
|
|||||||
|
|
||||||
function formClass()
|
function formClass()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'form';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ if (!defined('LACONICA')) {
|
|||||||
|
|
||||||
require_once INSTALLDIR.'/lib/widget.php';
|
require_once INSTALLDIR.'/lib/widget.php';
|
||||||
|
|
||||||
define('groupS_PER_PAGE', 20);
|
define('GROUPS_PER_PAGE', 20);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget to show a list of groups
|
* Widget to show a list of groups
|
||||||
@ -72,7 +72,7 @@ class GroupList extends Widget
|
|||||||
|
|
||||||
while ($this->group->fetch()) {
|
while ($this->group->fetch()) {
|
||||||
$cnt++;
|
$cnt++;
|
||||||
if($cnt > groupS_PER_PAGE) {
|
if($cnt > GROUPS_PER_PAGE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->showgroup();
|
$this->showgroup();
|
||||||
@ -99,12 +99,12 @@ class GroupList extends Widget
|
|||||||
'class' => 'url',
|
'class' => 'url',
|
||||||
'rel' => 'group'));
|
'rel' => 'group'));
|
||||||
$this->out->element('img', array('src' => $logo,
|
$this->out->element('img', array('src' => $logo,
|
||||||
'class' => 'photo avatar',
|
'class' => 'photo avatar',
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
'alt' =>
|
'alt' =>
|
||||||
($this->group->fullname) ? $this->group->fullname :
|
($this->group->fullname) ? $this->group->fullname :
|
||||||
$this->group->nickname));
|
$this->group->nickname));
|
||||||
$hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn org nickname url uid';
|
$hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn org nickname url uid';
|
||||||
$this->out->elementStart('span', $hasFN);
|
$this->out->elementStart('span', $hasFN);
|
||||||
$this->out->raw($this->highlight($this->group->nickname));
|
$this->out->raw($this->highlight($this->group->nickname));
|
||||||
@ -164,7 +164,7 @@ class GroupList extends Widget
|
|||||||
$lf = new LeaveForm($this->out, $this->group);
|
$lf = new LeaveForm($this->out, $this->group);
|
||||||
$lf->show();
|
$lf->show();
|
||||||
} else {
|
} else {
|
||||||
$jf = new JoinForm();
|
$jf = new JoinForm($this->out, $this->group);
|
||||||
$jf->show();
|
$jf->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
78
lib/groupsbymemberssection.php
Normal file
78
lib/groupsbymemberssection.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Laconica, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* @package Laconica
|
||||||
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||||
|
* @copyright 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Groups with the most members section
|
||||||
|
*
|
||||||
|
* @category Widget
|
||||||
|
* @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 GroupsByMembersSection extends GroupSection
|
||||||
|
{
|
||||||
|
function getGroups()
|
||||||
|
{
|
||||||
|
$qry = 'SELECT user_group.*, count(*) as value ' .
|
||||||
|
'FROM user_group JOIN group_member '.
|
||||||
|
'ON user_group.id = group_member.group_id ' .
|
||||||
|
'GROUP BY user_group.id ' .
|
||||||
|
'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()
|
||||||
|
{
|
||||||
|
return _('Groups with most members');
|
||||||
|
}
|
||||||
|
|
||||||
|
function divId()
|
||||||
|
{
|
||||||
|
return 'top_groups_by_member';
|
||||||
|
}
|
||||||
|
}
|
@ -76,6 +76,9 @@ class PublicGroupNav extends Widget
|
|||||||
$this->out->menuItem(common_local_url('public'), _('Public'),
|
$this->out->menuItem(common_local_url('public'), _('Public'),
|
||||||
_('Public timeline'), $action_name == 'public', 'nav_timeline_public');
|
_('Public timeline'), $action_name == 'public', 'nav_timeline_public');
|
||||||
|
|
||||||
|
$this->out->menuItem(common_local_url('groups'), _('Groups'),
|
||||||
|
_('User groups'), $action_name == 'groups', 'nav_groups');
|
||||||
|
|
||||||
$this->out->menuItem(common_local_url('publictagcloud'), _('Recent tags'),
|
$this->out->menuItem(common_local_url('publictagcloud'), _('Recent tags'),
|
||||||
_('Recent tags'), $action_name == 'publictagcloud', 'nav_recent-tags');
|
_('Recent tags'), $action_name == 'publictagcloud', 'nav_recent-tags');
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ define('DEFAULT_RSS_LIMIT', 48);
|
|||||||
class Rss10Action extends Action
|
class Rss10Action extends Action
|
||||||
{
|
{
|
||||||
# This will contain the details of each feed item's author and be used to generate SIOC data.
|
# This will contain the details of each feed item's author and be used to generate SIOC data.
|
||||||
|
|
||||||
var $creators = array();
|
var $creators = array();
|
||||||
var $limit = DEFAULT_RSS_LIMIT;
|
var $limit = DEFAULT_RSS_LIMIT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -57,10 +57,10 @@ class Rss10Action extends Action
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do we need to write to the database?
|
* Do we need to write to the database?
|
||||||
*
|
*
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function isReadonly()
|
function isReadonly()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -68,11 +68,11 @@ class Rss10Action extends Action
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read arguments and initialize members
|
* Read arguments and initialize members
|
||||||
*
|
*
|
||||||
* @param array $args Arguments from $_REQUEST
|
* @param array $args Arguments from $_REQUEST
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
$this->limit = (int) $this->trimmed('limit');
|
$this->limit = (int) $this->trimmed('limit');
|
||||||
@ -81,15 +81,15 @@ class Rss10Action extends Action
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a request
|
* Handle a request
|
||||||
*
|
*
|
||||||
* @param array $args Arguments from $_REQUEST
|
* @param array $args Arguments from $_REQUEST
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handle($args)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
@ -98,10 +98,10 @@ class Rss10Action extends Action
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the notices to output in this stream
|
* Get the notices to output in this stream
|
||||||
*
|
*
|
||||||
* @return array an array of Notice objects sorted in reverse chron
|
* @return array an array of Notice objects sorted in reverse chron
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNotices()
|
function getNotices()
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
@ -109,9 +109,11 @@ class Rss10Action extends Action
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a description of the channel
|
* Get a description of the channel
|
||||||
*
|
*
|
||||||
* Returns an array with the following
|
* Returns an array with the following
|
||||||
* @return array
|
* @return array
|
||||||
|
*/
|
||||||
|
|
||||||
function get_channel()
|
function get_channel()
|
||||||
{
|
{
|
||||||
return array('url' => '',
|
return array('url' => '',
|
||||||
|
@ -73,7 +73,7 @@ class SearchAction extends Action
|
|||||||
|
|
||||||
function showLocalNav()
|
function showLocalNav()
|
||||||
{
|
{
|
||||||
$nav = new SearchGroupNav($this);
|
$nav = new SearchGroupNav($this, $this->trimmed('q'));
|
||||||
$nav->show();
|
$nav->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +98,6 @@ class SearchAction extends Action
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_header($arr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showNoticeForm() {
|
function showNoticeForm() {
|
||||||
// remote post notice form
|
// remote post notice form
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ require_once INSTALLDIR.'/lib/widget.php';
|
|||||||
class SearchGroupNav extends Widget
|
class SearchGroupNav extends Widget
|
||||||
{
|
{
|
||||||
var $action = null;
|
var $action = null;
|
||||||
|
var $q = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction
|
* Construction
|
||||||
@ -55,10 +56,11 @@ class SearchGroupNav extends Widget
|
|||||||
* @param Action $action current action, used for output
|
* @param Action $action current action, used for output
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($action=null)
|
function __construct($action=null, $q = null)
|
||||||
{
|
{
|
||||||
parent::__construct($action);
|
parent::__construct($action);
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
|
$this->q = $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,9 +73,13 @@ class SearchGroupNav extends Widget
|
|||||||
{
|
{
|
||||||
$action_name = $this->action->trimmed('action');
|
$action_name = $this->action->trimmed('action');
|
||||||
$this->action->elementStart('ul', array('class' => 'nav'));
|
$this->action->elementStart('ul', array('class' => 'nav'));
|
||||||
$this->out->menuItem(common_local_url('peoplesearch'), _('People'),
|
$args = array();
|
||||||
|
if ($this->q) {
|
||||||
|
$args['q'] = $this->q;
|
||||||
|
}
|
||||||
|
$this->out->menuItem(common_local_url('peoplesearch', $args), _('People'),
|
||||||
_('Find people on this site'), $action_name == 'peoplesearch', 'nav_search_people');
|
_('Find people on this site'), $action_name == 'peoplesearch', 'nav_search_people');
|
||||||
$this->out->menuItem(common_local_url('noticesearch'), _('Notice'),
|
$this->out->menuItem(common_local_url('noticesearch', $args), _('Notice'),
|
||||||
_('Find content of notices'), $action_name == 'noticesearch', 'nav_search_notice');
|
_('Find content of notices'), $action_name == 'noticesearch', 'nav_search_notice');
|
||||||
$this->action->elementEnd('ul');
|
$this->action->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
@ -945,6 +945,8 @@ function common_fancy_url($action, $args=null)
|
|||||||
return common_path('group/'.$args['nickname'].'/members');
|
return common_path('group/'.$args['nickname'].'/members');
|
||||||
case 'usergroups':
|
case 'usergroups':
|
||||||
return common_path($args['nickname'].'/groups');
|
return common_path($args['nickname'].'/groups');
|
||||||
|
case 'groups':
|
||||||
|
return common_path('group');
|
||||||
default:
|
default:
|
||||||
return common_simple_url($action, $args);
|
return common_simple_url($action, $args);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user