forked from GNUsocial/gnu-social
Make Group actions ManagedAction so groupbyid works
This commit is contained in:
parent
cb5bcf4937
commit
af6a3aa456
@ -42,7 +42,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class GroupbyidAction extends ManagedAction
|
||||
class GroupbyidAction extends ShowgroupAction
|
||||
{
|
||||
/** group we're viewing. */
|
||||
protected $group = null;
|
||||
@ -55,10 +55,10 @@ class GroupbyidAction extends ManagedAction
|
||||
protected function doPreparation()
|
||||
{
|
||||
$this->group = User_group::getByID($this->arg('id'));
|
||||
}
|
||||
$this->target = $this->group->getProfile();
|
||||
|
||||
public function showPage()
|
||||
{
|
||||
common_redirect($this->group->homeUrl(), 303);
|
||||
if ($this->target->isLocal()) {
|
||||
common_redirect($this->target->getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,7 @@
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||
if (!defined('GNUSOCIAL)') { exit(1); }
|
||||
|
||||
/**
|
||||
* List of group members
|
||||
@ -52,15 +47,6 @@ class GroupmembersAction extends GroupAction
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepare(array $args=array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
|
@ -76,79 +76,15 @@ class ShowgroupAction extends GroupAction
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the action
|
||||
*
|
||||
* Reads and validates arguments and instantiates the attributes.
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
protected function prepare(array $args=array())
|
||||
public function getStream()
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
|
||||
$stream = new GroupNoticeStream($this->group, $this->scoped);
|
||||
} else {
|
||||
$stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
|
||||
}
|
||||
|
||||
$this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
|
||||
NOTICES_PER_PAGE + 1);
|
||||
|
||||
common_set_returnto($this->selfUrl());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the request
|
||||
*
|
||||
* Shows a profile for the group, some controls, and a list of
|
||||
* group notices.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handle()
|
||||
{
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the page content
|
||||
*
|
||||
* Shows a group profile and a list of group notices
|
||||
*/
|
||||
function showContent()
|
||||
{
|
||||
$this->showGroupNotices();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the group notices
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showGroupNotices()
|
||||
{
|
||||
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
|
||||
$nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
|
||||
} else {
|
||||
$nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
|
||||
}
|
||||
|
||||
$cnt = $nl->show();
|
||||
|
||||
$this->pagination($this->page > 1,
|
||||
$cnt > NOTICES_PER_PAGE,
|
||||
$this->page,
|
||||
'showgroup',
|
||||
array('nickname' => $this->group->nickname));
|
||||
return $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,25 +40,23 @@ define('MEMBERS_PER_SECTION', 27);
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class GroupAction extends Action
|
||||
class GroupAction extends ShowstreamAction
|
||||
{
|
||||
protected $group;
|
||||
|
||||
protected function prepare(array $args=array())
|
||||
protected function doPreparation()
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
$nickname_arg = $this->arg('nickname');
|
||||
$nickname = common_canonical_nickname($nickname_arg);
|
||||
|
||||
// Permanent redirect on non-canonical nickname
|
||||
|
||||
if ($nickname_arg != $nickname) {
|
||||
if ($nickname_arg !== $nickname) {
|
||||
$args = array('nickname' => $nickname);
|
||||
if ($this->page != 1) {
|
||||
$args['page'] = $this->page;
|
||||
}
|
||||
common_redirect(common_local_url('showgroup', $args), 301);
|
||||
common_redirect(common_local_url($this->getActionName(), $args), 301);
|
||||
}
|
||||
|
||||
if (!$nickname) {
|
||||
@ -79,15 +77,16 @@ class GroupAction extends Action
|
||||
} else {
|
||||
common_log(LOG_NOTICE, "Couldn't find local group for nickname '$nickname'");
|
||||
// TRANS: Client error displayed if no remote group with a given name was found requesting group page.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
throw new ClientException(_('No such group.'), 404);
|
||||
}
|
||||
}
|
||||
|
||||
$this->group = User_group::getKV('id', $local->group_id);
|
||||
$this->target = $this->group->getProfile();
|
||||
|
||||
if (!$this->group instanceof User_group) {
|
||||
// TRANS: Client error displayed if no local group with a given name was found requesting group page.
|
||||
$this->clientError(_('No such group.'), 404);
|
||||
throw new ClientException(_('No such group.'), 404);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,8 +104,7 @@ class GroupAction extends Action
|
||||
function showSections()
|
||||
{
|
||||
$this->showMembers();
|
||||
$cur = common_current_user();
|
||||
if ($cur && $cur->isAdmin($this->group)) {
|
||||
if ($this->scoped instanceof Profile && $this->scoped->isAdmin($this->group)) {
|
||||
$this->showPending();
|
||||
$this->showBlocked();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ abstract class ProfileAction extends ManagedAction
|
||||
$nickname = common_canonical_nickname($nickname_arg);
|
||||
|
||||
// Permanent redirect on non-canonical nickname
|
||||
if ($nickname_arg != $nickname) {
|
||||
if ($nickname_arg !== $nickname) {
|
||||
$args = array('nickname' => $nickname);
|
||||
if ($this->arg('page') && $this->arg('page') != 1) {
|
||||
$args['page'] = $this->arg['page'];
|
||||
@ -83,7 +83,7 @@ abstract class ProfileAction extends ManagedAction
|
||||
// this will call ->doPreparation() which child classes use to set $this->target
|
||||
parent::prepare($args);
|
||||
|
||||
if ($this->target->hasRole(Profile_role::SILENCED)
|
||||
if ($this->target->isPerson() && $this->target->hasRole(Profile_role::SILENCED)
|
||||
&& (!$this->scoped instanceof Profile || !$this->scoped->hasRight(Right::SILENCEUSER))) {
|
||||
throw new ClientException(_('This profile has been silenced by site moderators'), 403);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user