Merge remote-tracking branch 'mainline/1.0.x' into people_tags_rebase
Conflicts: classes/Profile.php
This commit is contained in:
commit
bf121a695a
|
@ -742,19 +742,19 @@ EndUnsubscribe: when an unsubscribe is done
|
||||||
|
|
||||||
StartJoinGroup: when a user is joining a group
|
StartJoinGroup: when a user is joining a group
|
||||||
- $group: the group being joined
|
- $group: the group being joined
|
||||||
- $user: the user joining
|
- $profile: the local or remote user joining
|
||||||
|
|
||||||
EndJoinGroup: when a user finishes joining a group
|
EndJoinGroup: when a user finishes joining a group
|
||||||
- $group: the group being joined
|
- $group: the group being joined
|
||||||
- $user: the user joining
|
- $profile: the local or remote user joining
|
||||||
|
|
||||||
StartLeaveGroup: when a user is leaving a group
|
StartLeaveGroup: when a user is leaving a group
|
||||||
- $group: the group being left
|
- $group: the group being left
|
||||||
- $user: the user leaving
|
- $profile: the local or remote user leaving
|
||||||
|
|
||||||
EndLeaveGroup: when a user has left a group
|
EndLeaveGroup: when a user has left a group
|
||||||
- $group: the group being left
|
- $group: the group being left
|
||||||
- $user: the user leaving
|
- $profile: the local or remote user leaving
|
||||||
|
|
||||||
StartShowContentLicense: Showing the default license for content
|
StartShowContentLicense: Showing the default license for content
|
||||||
- $action: the current action
|
- $action: the current action
|
||||||
|
|
|
@ -126,10 +126,7 @@ class ApiGroupJoinAction extends ApiAuthAction
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartJoinGroup', array($this->group, $this->user))) {
|
$this->user->joinGroup($this->group);
|
||||||
Group_member::join($this->group->id, $this->user->id);
|
|
||||||
Event::handle('EndJoinGroup', array($this->group, $this->user));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error displayed when joining a group failed in the database.
|
// TRANS: Server error displayed when joining a group failed in the database.
|
||||||
// TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
|
// TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
|
||||||
|
|
|
@ -117,10 +117,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartLeaveGroup', array($this->group,$this->user))) {
|
$this->user->leaveGroup($this->group);
|
||||||
Group_member::leave($this->group->id, $this->user->id);
|
|
||||||
Event::handle('EndLeaveGroup', array($this->group, $this->user));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error displayed when leaving a group failed in the database.
|
// TRANS: Server error displayed when leaving a group failed in the database.
|
||||||
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
||||||
|
|
168
actions/approvegroup.php
Normal file
168
actions/approvegroup.php
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Leave a group
|
||||||
|
*
|
||||||
|
* 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 Group
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave a group
|
||||||
|
*
|
||||||
|
* This is the action for leaving a group. It works more or less like the subscribe action
|
||||||
|
* for users.
|
||||||
|
*
|
||||||
|
* @category Group
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
class ApprovegroupAction extends Action
|
||||||
|
{
|
||||||
|
var $group = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare to run
|
||||||
|
*/
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
if (!common_logged_in()) {
|
||||||
|
// TRANS: Client error displayed when trying to leave a group while not logged in.
|
||||||
|
$this->clientError(_('You must be logged in to leave a group.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nickname_arg = $this->trimmed('nickname');
|
||||||
|
$id = intval($this->arg('id'));
|
||||||
|
if ($id) {
|
||||||
|
$this->group = User_group::staticGet('id', $id);
|
||||||
|
} else if ($nickname_arg) {
|
||||||
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
|
if ($nickname_arg != $nickname) {
|
||||||
|
$args = array('nickname' => $nickname);
|
||||||
|
common_redirect(common_local_url('leavegroup', $args), 301);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$local = Local_group::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$local) {
|
||||||
|
// TRANS: Client error displayed when trying to leave a non-local group.
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->group = User_group::staticGet('id', $local->group_id);
|
||||||
|
} else {
|
||||||
|
// TRANS: Client error displayed when trying to leave a group without providing a group name or group ID.
|
||||||
|
$this->clientError(_('No nickname or ID.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->group) {
|
||||||
|
// TRANS: Client error displayed when trying to leave a non-existing group.
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cur = common_current_user();
|
||||||
|
if (empty($cur)) {
|
||||||
|
$this->clientError(_('Must be logged in.'), 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($this->arg('profile_id')) {
|
||||||
|
if ($cur->isAdmin($this->group)) {
|
||||||
|
$this->profile = Profile::staticGet('id', $this->arg('profile_id'));
|
||||||
|
} else {
|
||||||
|
$this->clientError(_('Only group admin can approve or cancel join requests.'), 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->clientError(_('Must specify a profile.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->request = Group_join_queue::pkeyGet(array('profile_id' => $this->profile->id,
|
||||||
|
'group_id' => $this->group->id));
|
||||||
|
|
||||||
|
if (empty($this->request)) {
|
||||||
|
$this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the request
|
||||||
|
*
|
||||||
|
* On POST, add the current user to the group
|
||||||
|
*
|
||||||
|
* @param array $args unused
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->profile->completeJoinGroup($this->group);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
common_log(LOG_ERROR, "Exception canceling group sub: " . $e->getMessage());
|
||||||
|
// TRANS: Server error displayed when cancelling a queued group join request fails.
|
||||||
|
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
||||||
|
$this->serverError(sprintf(_('Could not cancel request for user %1$s to join group %2$s.'),
|
||||||
|
$this->profile->nickname, $this->group->nickname));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->boolean('ajax')) {
|
||||||
|
$this->startHTML('text/xml;charset=utf-8');
|
||||||
|
$this->elementStart('head');
|
||||||
|
// TRANS: Title for leave group page after leaving.
|
||||||
|
$this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'),
|
||||||
|
$this->profile->nickname,
|
||||||
|
$this->group->nickname));
|
||||||
|
$this->elementEnd('head');
|
||||||
|
$this->elementStart('body');
|
||||||
|
$jf = new JoinForm($this, $this->group);
|
||||||
|
$jf->show();
|
||||||
|
$this->elementEnd('body');
|
||||||
|
$this->elementEnd('html');
|
||||||
|
} else {
|
||||||
|
common_redirect(common_local_url('groupmembers', array('nickname' =>
|
||||||
|
$this->group->nickname)),
|
||||||
|
303);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -275,10 +275,7 @@ class AtompubmembershipfeedAction extends ApiAuthAction
|
||||||
throw new ClientException(_('Blocked by admin.'));
|
throw new ClientException(_('Blocked by admin.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('StartJoinGroup', array($group, $this->auth_user))) {
|
$this->auth_user->joinGroup($group);
|
||||||
$membership = Group_member::join($group->id, $this->auth_user->id);
|
|
||||||
Event::handle('EndJoinGroup', array($group, $this->auth_user));
|
|
||||||
}
|
|
||||||
|
|
||||||
Event::handle('EndAtomPubNewActivity', array($activity, $membership));
|
Event::handle('EndAtomPubNewActivity', array($activity, $membership));
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,10 +151,7 @@ class AtompubshowmembershipAction extends ApiAuthAction
|
||||||
" membership."), 403);
|
" membership."), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('StartLeaveGroup', array($this->_group, $this->auth_user))) {
|
$this->auth_user->leaveGroup($this->_group);
|
||||||
Group_member::leave($this->_group->id, $this->auth_user->id);
|
|
||||||
Event::handle('EndLeaveGroup', array($this->_group, $this->auth_user));
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
167
actions/cancelgroup.php
Normal file
167
actions/cancelgroup.php
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Leave a group
|
||||||
|
*
|
||||||
|
* 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 Group
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave a group
|
||||||
|
*
|
||||||
|
* This is the action for leaving a group. It works more or less like the subscribe action
|
||||||
|
* for users.
|
||||||
|
*
|
||||||
|
* @category Group
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
class CancelgroupAction extends Action
|
||||||
|
{
|
||||||
|
var $group = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare to run
|
||||||
|
*/
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
if (!common_logged_in()) {
|
||||||
|
// TRANS: Client error displayed when trying to leave a group while not logged in.
|
||||||
|
$this->clientError(_('You must be logged in to leave a group.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nickname_arg = $this->trimmed('nickname');
|
||||||
|
$id = intval($this->arg('id'));
|
||||||
|
if ($id) {
|
||||||
|
$this->group = User_group::staticGet('id', $id);
|
||||||
|
} else if ($nickname_arg) {
|
||||||
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
|
if ($nickname_arg != $nickname) {
|
||||||
|
$args = array('nickname' => $nickname);
|
||||||
|
common_redirect(common_local_url('leavegroup', $args), 301);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$local = Local_group::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$local) {
|
||||||
|
// TRANS: Client error displayed when trying to leave a non-local group.
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->group = User_group::staticGet('id', $local->group_id);
|
||||||
|
} else {
|
||||||
|
// TRANS: Client error displayed when trying to leave a group without providing a group name or group ID.
|
||||||
|
$this->clientError(_('No nickname or ID.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->group) {
|
||||||
|
// TRANS: Client error displayed when trying to leave a non-existing group.
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cur = common_current_user();
|
||||||
|
if (empty($cur)) {
|
||||||
|
$this->clientError(_('Must be logged in.'), 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($this->arg('profile_id')) {
|
||||||
|
if ($cur->isAdmin($this->group)) {
|
||||||
|
$this->profile = Profile::staticGet('id', $this->arg('profile_id'));
|
||||||
|
} else {
|
||||||
|
$this->clientError(_('Only group admin can approve or cancel join requests.'), 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->profile = $cur->getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->request = Group_join_queue::pkeyGet(array('profile_id' => $this->profile->id,
|
||||||
|
'group_id' => $this->group->id));
|
||||||
|
|
||||||
|
if (empty($this->request)) {
|
||||||
|
$this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the request
|
||||||
|
*
|
||||||
|
* On POST, add the current user to the group
|
||||||
|
*
|
||||||
|
* @param array $args unused
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->profile->cancelJoinGroup($this->group);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
common_log(LOG_ERROR, "Exception canceling group sub: " . $e->getMessage());
|
||||||
|
// TRANS: Server error displayed when cancelling a queued group join request fails.
|
||||||
|
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
||||||
|
$this->serverError(sprintf(_('Could not cancel request for user %1$s to join group %2$s.'),
|
||||||
|
$this->profile->nickname, $this->group->nickname));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->boolean('ajax')) {
|
||||||
|
$this->startHTML('text/xml;charset=utf-8');
|
||||||
|
$this->elementStart('head');
|
||||||
|
// TRANS: Title for leave group page after leaving.
|
||||||
|
$this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'),
|
||||||
|
$this->profile->nickname,
|
||||||
|
$this->group->nickname));
|
||||||
|
$this->elementEnd('head');
|
||||||
|
$this->elementStart('body');
|
||||||
|
$jf = new JoinForm($this, $this->group);
|
||||||
|
$jf->show();
|
||||||
|
$this->elementEnd('body');
|
||||||
|
$this->elementEnd('html');
|
||||||
|
} else {
|
||||||
|
common_redirect(common_local_url('groupmembers', array('nickname' =>
|
||||||
|
$this->group->nickname)),
|
||||||
|
303);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -185,6 +185,7 @@ class EditgroupAction extends GroupDesignAction
|
||||||
$description = $this->trimmed('description');
|
$description = $this->trimmed('description');
|
||||||
$location = $this->trimmed('location');
|
$location = $this->trimmed('location');
|
||||||
$aliasstring = $this->trimmed('aliases');
|
$aliasstring = $this->trimmed('aliases');
|
||||||
|
$join_policy = intval($this->arg('join_policy'));
|
||||||
|
|
||||||
if ($this->nicknameExists($nickname)) {
|
if ($this->nicknameExists($nickname)) {
|
||||||
// TRANS: Group edit form validation error.
|
// TRANS: Group edit form validation error.
|
||||||
|
@ -265,6 +266,7 @@ class EditgroupAction extends GroupDesignAction
|
||||||
$this->group->description = $description;
|
$this->group->description = $description;
|
||||||
$this->group->location = $location;
|
$this->group->location = $location;
|
||||||
$this->group->mainpage = common_local_url('showgroup', array('nickname' => $nickname));
|
$this->group->mainpage = common_local_url('showgroup', array('nickname' => $nickname));
|
||||||
|
$this->group->join_policy = $join_policy;
|
||||||
|
|
||||||
$result = $this->group->update($orig);
|
$result = $this->group->update($orig);
|
||||||
|
|
||||||
|
|
|
@ -152,376 +152,3 @@ class GroupmembersAction extends GroupDesignAction
|
||||||
array('nickname' => $this->group->nickname));
|
array('nickname' => $this->group->nickname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GroupMemberList extends ProfileList
|
|
||||||
{
|
|
||||||
var $group = null;
|
|
||||||
|
|
||||||
function __construct($profile, $group, $action)
|
|
||||||
{
|
|
||||||
parent::__construct($profile, $action);
|
|
||||||
|
|
||||||
$this->group = $group;
|
|
||||||
}
|
|
||||||
|
|
||||||
function newListItem($profile)
|
|
||||||
{
|
|
||||||
return new GroupMemberListItem($profile, $this->group, $this->action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GroupMemberListItem extends ProfileListItem
|
|
||||||
{
|
|
||||||
var $group = null;
|
|
||||||
|
|
||||||
function __construct($profile, $group, $action)
|
|
||||||
{
|
|
||||||
parent::__construct($profile, $action);
|
|
||||||
|
|
||||||
$this->group = $group;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showFullName()
|
|
||||||
{
|
|
||||||
parent::showFullName();
|
|
||||||
if ($this->profile->isAdmin($this->group)) {
|
|
||||||
$this->out->text(' '); // for separating the classes.
|
|
||||||
// TRANS: Indicator in group members list that this user is a group administrator.
|
|
||||||
$this->out->element('span', 'role', _('Admin'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showActions()
|
|
||||||
{
|
|
||||||
$this->startActions();
|
|
||||||
if (Event::handle('StartProfileListItemActionElements', array($this))) {
|
|
||||||
$this->showSubscribeButton();
|
|
||||||
$this->showMakeAdminForm();
|
|
||||||
$this->showGroupBlockForm();
|
|
||||||
Event::handle('EndProfileListItemActionElements', array($this));
|
|
||||||
}
|
|
||||||
$this->endActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
function showMakeAdminForm()
|
|
||||||
{
|
|
||||||
$user = common_current_user();
|
|
||||||
|
|
||||||
if (!empty($user) &&
|
|
||||||
$user->id != $this->profile->id &&
|
|
||||||
($user->isAdmin($this->group) || $user->hasRight(Right::MAKEGROUPADMIN)) &&
|
|
||||||
!$this->profile->isAdmin($this->group)) {
|
|
||||||
$this->out->elementStart('li', 'entity_make_admin');
|
|
||||||
$maf = new MakeAdminForm($this->out, $this->profile, $this->group,
|
|
||||||
$this->returnToArgs());
|
|
||||||
$maf->show();
|
|
||||||
$this->out->elementEnd('li');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function showGroupBlockForm()
|
|
||||||
{
|
|
||||||
$user = common_current_user();
|
|
||||||
|
|
||||||
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
|
|
||||||
$this->out->elementStart('li', 'entity_block');
|
|
||||||
$bf = new GroupBlockForm($this->out, $this->profile, $this->group,
|
|
||||||
$this->returnToArgs());
|
|
||||||
$bf->show();
|
|
||||||
$this->out->elementEnd('li');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function linkAttributes()
|
|
||||||
{
|
|
||||||
$aAttrs = parent::linkAttributes();
|
|
||||||
|
|
||||||
if (common_config('nofollow', 'members')) {
|
|
||||||
$aAttrs['rel'] .= ' nofollow';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $aAttrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
function homepageAttributes()
|
|
||||||
{
|
|
||||||
$aAttrs = parent::linkAttributes();
|
|
||||||
|
|
||||||
if (common_config('nofollow', 'members')) {
|
|
||||||
$aAttrs['rel'] = 'nofollow';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $aAttrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch necessary return-to arguments for the profile forms
|
|
||||||
* to return to this list when they're done.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function returnToArgs()
|
|
||||||
{
|
|
||||||
$args = array('action' => 'groupmembers',
|
|
||||||
'nickname' => $this->group->nickname);
|
|
||||||
$page = $this->out->arg('page');
|
|
||||||
if ($page) {
|
|
||||||
$args['param-page'] = $page;
|
|
||||||
}
|
|
||||||
return $args;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form for blocking a user from a group
|
|
||||||
*
|
|
||||||
* @category Form
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @author Sarven Capadisli <csarven@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* @see BlockForm
|
|
||||||
*/
|
|
||||||
class GroupBlockForm extends Form
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Profile of user to block
|
|
||||||
*/
|
|
||||||
|
|
||||||
var $profile = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Group to block the user from
|
|
||||||
*/
|
|
||||||
|
|
||||||
var $group = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return-to args
|
|
||||||
*/
|
|
||||||
|
|
||||||
var $args = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param HTMLOutputter $out output channel
|
|
||||||
* @param Profile $profile profile of user to block
|
|
||||||
* @param User_group $group group to block user from
|
|
||||||
* @param array $args return-to args
|
|
||||||
*/
|
|
||||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
|
||||||
{
|
|
||||||
parent::__construct($out);
|
|
||||||
|
|
||||||
$this->profile = $profile;
|
|
||||||
$this->group = $group;
|
|
||||||
$this->args = $args;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID of the form
|
|
||||||
*
|
|
||||||
* @return int ID of the form
|
|
||||||
*/
|
|
||||||
function id()
|
|
||||||
{
|
|
||||||
// This should be unique for the page.
|
|
||||||
return 'block-' . $this->profile->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* class of the form
|
|
||||||
*
|
|
||||||
* @return string class of the form
|
|
||||||
*/
|
|
||||||
function formClass()
|
|
||||||
{
|
|
||||||
return 'form_group_block';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action of the form
|
|
||||||
*
|
|
||||||
* @return string URL of the action
|
|
||||||
*/
|
|
||||||
function action()
|
|
||||||
{
|
|
||||||
return common_local_url('groupblock');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legend of the Form
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formLegend()
|
|
||||||
{
|
|
||||||
// TRANS: Form legend for form to block user from a group.
|
|
||||||
$this->out->element('legend', null, _('Block user from group'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data elements of the form
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formData()
|
|
||||||
{
|
|
||||||
$this->out->hidden('blockto-' . $this->profile->id,
|
|
||||||
$this->profile->id,
|
|
||||||
'blockto');
|
|
||||||
$this->out->hidden('blockgroup-' . $this->group->id,
|
|
||||||
$this->group->id,
|
|
||||||
'blockgroup');
|
|
||||||
if ($this->args) {
|
|
||||||
foreach ($this->args as $k => $v) {
|
|
||||||
$this->out->hidden('returnto-' . $k, $v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action elements
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formActions()
|
|
||||||
{
|
|
||||||
$this->out->submit(
|
|
||||||
'submit',
|
|
||||||
// TRANS: Button text for the form that will block a user from a group.
|
|
||||||
_m('BUTTON','Block'),
|
|
||||||
'submit',
|
|
||||||
null,
|
|
||||||
// TRANS: Submit button title.
|
|
||||||
_m('TOOLTIP', 'Block this user'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form for making a user an admin for a group
|
|
||||||
*
|
|
||||||
* @category Form
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @author Sarven Capadisli <csarven@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
|
||||||
class MakeAdminForm extends Form
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Profile of user to block
|
|
||||||
*/
|
|
||||||
var $profile = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Group to block the user from
|
|
||||||
*/
|
|
||||||
var $group = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return-to args
|
|
||||||
*/
|
|
||||||
var $args = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param HTMLOutputter $out output channel
|
|
||||||
* @param Profile $profile profile of user to block
|
|
||||||
* @param User_group $group group to block user from
|
|
||||||
* @param array $args return-to args
|
|
||||||
*/
|
|
||||||
function __construct($out=null, $profile=null, $group=null, $args=null)
|
|
||||||
{
|
|
||||||
parent::__construct($out);
|
|
||||||
|
|
||||||
$this->profile = $profile;
|
|
||||||
$this->group = $group;
|
|
||||||
$this->args = $args;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID of the form
|
|
||||||
*
|
|
||||||
* @return int ID of the form
|
|
||||||
*/
|
|
||||||
function id()
|
|
||||||
{
|
|
||||||
// This should be unique for the page.
|
|
||||||
return 'makeadmin-' . $this->profile->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* class of the form
|
|
||||||
*
|
|
||||||
* @return string class of the form
|
|
||||||
*/
|
|
||||||
function formClass()
|
|
||||||
{
|
|
||||||
return 'form_make_admin';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action of the form
|
|
||||||
*
|
|
||||||
* @return string URL of the action
|
|
||||||
*/
|
|
||||||
function action()
|
|
||||||
{
|
|
||||||
return common_local_url('makeadmin', array('nickname' => $this->group->nickname));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legend of the Form
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formLegend()
|
|
||||||
{
|
|
||||||
// TRANS: Form legend for form to make a user a group admin.
|
|
||||||
$this->out->element('legend', null, _('Make user an admin of the group'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data elements of the form
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formData()
|
|
||||||
{
|
|
||||||
$this->out->hidden('profileid-' . $this->profile->id,
|
|
||||||
$this->profile->id,
|
|
||||||
'profileid');
|
|
||||||
$this->out->hidden('groupid-' . $this->group->id,
|
|
||||||
$this->group->id,
|
|
||||||
'groupid');
|
|
||||||
if ($this->args) {
|
|
||||||
foreach ($this->args as $k => $v) {
|
|
||||||
$this->out->hidden('returnto-' . $k, $v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action elements
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formActions()
|
|
||||||
{
|
|
||||||
$this->out->submit(
|
|
||||||
'submit',
|
|
||||||
// TRANS: Button text for the form that will make a user administrator.
|
|
||||||
_m('BUTTON','Make Admin'),
|
|
||||||
'submit',
|
|
||||||
null,
|
|
||||||
// TRANS: Submit button title.
|
|
||||||
_m('TOOLTIP','Make this user an admin'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
199
actions/groupqueue.php
Normal file
199
actions/groupqueue.php
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* List of group members
|
||||||
|
*
|
||||||
|
* 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 Group
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||||
|
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of group members
|
||||||
|
*
|
||||||
|
* @category Group
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
class GroupqueueAction extends GroupDesignAction
|
||||||
|
{
|
||||||
|
var $page = null;
|
||||||
|
|
||||||
|
function isReadOnly($args)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixme most of this belongs in a base class, sounds common to most group actions?
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||||
|
|
||||||
|
$nickname_arg = $this->arg('nickname');
|
||||||
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
|
if ($nickname_arg != $nickname) {
|
||||||
|
$args = array('nickname' => $nickname);
|
||||||
|
if ($this->page != 1) {
|
||||||
|
$args['page'] = $this->page;
|
||||||
|
}
|
||||||
|
common_redirect(common_local_url('groupqueue', $args), 301);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$nickname) {
|
||||||
|
// TRANS: Client error displayed when trying to view group members without providing a group nickname.
|
||||||
|
$this->clientError(_('No nickname.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$local = Local_group::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$local) {
|
||||||
|
// TRANS: Client error displayed when trying to view group members for a non-existing group.
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->group = User_group::staticGet('id', $local->group_id);
|
||||||
|
|
||||||
|
if (!$this->group) {
|
||||||
|
// TRANS: Client error displayed when trying to view group members for an object that is not a group.
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cur = common_current_user();
|
||||||
|
if (!$cur || !$cur->isAdmin($this->group)) {
|
||||||
|
$this->clientError(_('Only the group admin may approve users.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
if ($this->page == 1) {
|
||||||
|
// TRANS: Title of the page showing pending group members still awaiting approval to join the group.
|
||||||
|
// TRANS: %s is the name of the group.
|
||||||
|
return sprintf(_('%s group members awaiting approval'),
|
||||||
|
$this->group->nickname);
|
||||||
|
} else {
|
||||||
|
// TRANS: Title of the page showing pending group members still awaiting approval to join the group.
|
||||||
|
// TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
|
||||||
|
return sprintf(_('%1$s group members awaiting approval, page %2$d'),
|
||||||
|
$this->group->nickname,
|
||||||
|
$this->page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
$this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showPageNotice()
|
||||||
|
{
|
||||||
|
$this->element('p', 'instructions',
|
||||||
|
// TRANS: Page notice for group members page.
|
||||||
|
_('A list of users awaiting approval to join this group.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showObjectNav()
|
||||||
|
{
|
||||||
|
$nav = new GroupNav($this, $this->group);
|
||||||
|
$nav->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showContent()
|
||||||
|
{
|
||||||
|
$offset = ($this->page-1) * PROFILES_PER_PAGE;
|
||||||
|
$limit = PROFILES_PER_PAGE + 1;
|
||||||
|
|
||||||
|
$cnt = 0;
|
||||||
|
|
||||||
|
$members = $this->group->getRequests($offset, $limit);
|
||||||
|
|
||||||
|
if ($members) {
|
||||||
|
// @fixme change!
|
||||||
|
$member_list = new GroupQueueList($members, $this->group, $this);
|
||||||
|
$cnt = $member_list->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$members->free();
|
||||||
|
|
||||||
|
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||||
|
$this->page, 'groupmembers',
|
||||||
|
array('nickname' => $this->group->nickname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupQueueList extends GroupMemberList
|
||||||
|
{
|
||||||
|
function newListItem($profile)
|
||||||
|
{
|
||||||
|
return new GroupQueueListItem($profile, $this->group, $this->action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupQueueListItem extends GroupMemberListItem
|
||||||
|
{
|
||||||
|
function showActions()
|
||||||
|
{
|
||||||
|
$this->startActions();
|
||||||
|
if (Event::handle('StartProfileListItemActionElements', array($this))) {
|
||||||
|
$this->showApproveButton();
|
||||||
|
$this->showCancelButton();
|
||||||
|
Event::handle('EndProfileListItemActionElements', array($this));
|
||||||
|
}
|
||||||
|
$this->endActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showApproveButton()
|
||||||
|
{
|
||||||
|
$this->out->elementStart('li', 'entity_join');
|
||||||
|
$form = new ApproveGroupForm($this->out, $this->group, $this->profile);
|
||||||
|
$form->show();
|
||||||
|
$this->out->elementEnd('li');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCancelButton()
|
||||||
|
{
|
||||||
|
$this->out->elementStart('li', 'entity_leave');
|
||||||
|
$bf = new CancelGroupForm($this->out, $this->group, $this->profile);
|
||||||
|
$bf->show();
|
||||||
|
$this->out->elementEnd('li');
|
||||||
|
}
|
||||||
|
}
|
|
@ -129,10 +129,7 @@ class JoingroupAction extends Action
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartJoinGroup', array($this->group, $cur))) {
|
$result = $cur->joinGroup($this->group);
|
||||||
Group_member::join($this->group->id, $cur->id);
|
|
||||||
Event::handle('EndJoinGroup', array($this->group, $cur));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error displayed when joining a group failed in the database.
|
// TRANS: Server error displayed when joining a group failed in the database.
|
||||||
// TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
|
// TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
|
||||||
|
@ -150,8 +147,16 @@ class JoingroupAction extends Action
|
||||||
$this->group->nickname));
|
$this->group->nickname));
|
||||||
$this->elementEnd('head');
|
$this->elementEnd('head');
|
||||||
$this->elementStart('body');
|
$this->elementStart('body');
|
||||||
$lf = new LeaveForm($this, $this->group);
|
|
||||||
$lf->show();
|
if ($result instanceof Group_member) {
|
||||||
|
$form = new LeaveForm($this, $this->group);
|
||||||
|
} else if ($result instanceof Group_join_queue) {
|
||||||
|
$form = new CancelGroupForm($this, $this->group);
|
||||||
|
} else {
|
||||||
|
// wtf?
|
||||||
|
throw new Exception(_m("Unknown error joining group."));
|
||||||
|
}
|
||||||
|
$form->show();
|
||||||
$this->elementEnd('body');
|
$this->elementEnd('body');
|
||||||
$this->elementEnd('html');
|
$this->elementEnd('html');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -123,10 +123,7 @@ class LeavegroupAction extends Action
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartLeaveGroup', array($this->group, $cur))) {
|
$cur->leaveGroup($this->group);
|
||||||
Group_member::leave($this->group->id, $cur->id);
|
|
||||||
Event::handle('EndLeaveGroup', array($this->group, $cur));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error displayed when leaving a group failed in the database.
|
// TRANS: Server error displayed when leaving a group failed in the database.
|
||||||
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
||||||
|
|
|
@ -131,6 +131,7 @@ class NewgroupAction extends Action
|
||||||
$description = $this->trimmed('description');
|
$description = $this->trimmed('description');
|
||||||
$location = $this->trimmed('location');
|
$location = $this->trimmed('location');
|
||||||
$aliasstring = $this->trimmed('aliases');
|
$aliasstring = $this->trimmed('aliases');
|
||||||
|
$join_policy = intval($this->arg('join_policy'));
|
||||||
|
|
||||||
if ($this->nicknameExists($nickname)) {
|
if ($this->nicknameExists($nickname)) {
|
||||||
// TRANS: Group create form validation error.
|
// TRANS: Group create form validation error.
|
||||||
|
@ -215,6 +216,7 @@ class NewgroupAction extends Action
|
||||||
'location' => $location,
|
'location' => $location,
|
||||||
'aliases' => $aliases,
|
'aliases' => $aliases,
|
||||||
'userid' => $cur->id,
|
'userid' => $cur->id,
|
||||||
|
'join_policy' => $join_policy,
|
||||||
'local' => true));
|
'local' => true));
|
||||||
|
|
||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
|
|
58
classes/Group_join_queue.php
Normal file
58
classes/Group_join_queue.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Table Definition for request_queue
|
||||||
|
*/
|
||||||
|
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||||
|
|
||||||
|
class Group_join_queue extends Managed_DataObject
|
||||||
|
{
|
||||||
|
###START_AUTOCODE
|
||||||
|
/* the code below is auto generated do not remove the above tag */
|
||||||
|
|
||||||
|
public $__table = 'group_join_queue'; // table name
|
||||||
|
public $profile_id;
|
||||||
|
public $group_id;
|
||||||
|
public $created;
|
||||||
|
|
||||||
|
/* Static get */
|
||||||
|
function staticGet($k,$v=null)
|
||||||
|
{ return Memcached_DataObject::staticGet('Group_join_queue',$k,$v); }
|
||||||
|
|
||||||
|
/* Pkey get */
|
||||||
|
function pkeyGet($k)
|
||||||
|
{ return Memcached_DataObject::pkeyGet('Group_join_queue',$k); }
|
||||||
|
|
||||||
|
/* the code above is auto generated do not remove the tag below */
|
||||||
|
###END_AUTOCODE
|
||||||
|
|
||||||
|
public static function schemaDef()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'description' => 'Holder for group join requests awaiting moderation.',
|
||||||
|
'fields' => array(
|
||||||
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
|
||||||
|
'group_id' => array('type' => 'int', 'description' => 'remote or local group to join, if any'),
|
||||||
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||||
|
),
|
||||||
|
'primary key' => array('profile_id', 'group_id'),
|
||||||
|
'indexes' => array(
|
||||||
|
'group_join_queue_profile_id_created_idx' => array('profile_id', 'created'),
|
||||||
|
'group_join_queue_group_id_created_idx' => array('group_id', 'created'),
|
||||||
|
),
|
||||||
|
'foreign keys' => array(
|
||||||
|
'group_join_queue_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||||
|
'group_join_queue_group_id_fkey' => array('user_group', array('group_id' => 'id')),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function saveNew(Profile $profile, User_group $group)
|
||||||
|
{
|
||||||
|
$rq = new Group_join_queue();
|
||||||
|
$rq->profile_id = $profile->id;
|
||||||
|
$rq->group_id = $group->id;
|
||||||
|
$rq->created = common_sql_now();
|
||||||
|
$rq->insert();
|
||||||
|
return $rq;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ class Group_member extends Memcached_DataObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to add a user to a group.
|
* Method to add a user to a group.
|
||||||
|
* In most cases, you should call Profile->joinGroup() instead.
|
||||||
*
|
*
|
||||||
* @param integer $group_id Group to add to
|
* @param integer $group_id Group to add to
|
||||||
* @param integer $profile_id Profile being added
|
* @param integer $profile_id Profile being added
|
||||||
|
|
|
@ -93,6 +93,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||||
function keyTypes()
|
function keyTypes()
|
||||||
{
|
{
|
||||||
$table = call_user_func(array(get_class($this), 'schemaDef'));
|
$table = call_user_func(array(get_class($this), 'schemaDef'));
|
||||||
|
$keys = array();
|
||||||
|
|
||||||
if (!empty($table['unique keys'])) {
|
if (!empty($table['unique keys'])) {
|
||||||
foreach ($table['unique keys'] as $idx => $fields) {
|
foreach ($table['unique keys'] as $idx => $fields) {
|
||||||
|
|
|
@ -313,6 +313,13 @@ class Profile extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPendingMember($group)
|
||||||
|
{
|
||||||
|
$request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
|
||||||
|
'group_id' => $group->id));
|
||||||
|
return !empty($request);
|
||||||
|
}
|
||||||
|
|
||||||
function getGroups($offset=0, $limit=null)
|
function getGroups($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$qry =
|
$qry =
|
||||||
|
@ -516,6 +523,79 @@ class Profile extends Memcached_DataObject
|
||||||
return $lists;
|
return $lists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to join the given group.
|
||||||
|
* May throw exceptions on failure.
|
||||||
|
*
|
||||||
|
* @param User_group $group
|
||||||
|
* @return mixed: Group_member on success, Group_join_queue if pending approval, null on some cancels?
|
||||||
|
*/
|
||||||
|
function joinGroup(User_group $group)
|
||||||
|
{
|
||||||
|
$ok = null;
|
||||||
|
if ($group->join_policy == User_group::JOIN_POLICY_MODERATE) {
|
||||||
|
$ok = Group_join_queue::saveNew($this, $group);
|
||||||
|
} else {
|
||||||
|
if (Event::handle('StartJoinGroup', array($group, $this))) {
|
||||||
|
$ok = Group_member::join($group->id, $this->id);
|
||||||
|
Event::handle('EndJoinGroup', array($group, $this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel a pending group join...
|
||||||
|
*
|
||||||
|
* @param User_group $group
|
||||||
|
*/
|
||||||
|
function cancelJoinGroup(User_group $group)
|
||||||
|
{
|
||||||
|
$request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
|
||||||
|
'group_id' => $group->id));
|
||||||
|
if ($request) {
|
||||||
|
if (Event::handle('StartCancelJoinGroup', array($group, $this))) {
|
||||||
|
$request->delete();
|
||||||
|
Event::handle('EndCancelJoinGroup', array($group, $this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete a pending group join on our end...
|
||||||
|
*
|
||||||
|
* @param User_group $group
|
||||||
|
*/
|
||||||
|
function completeJoinGroup(User_group $group)
|
||||||
|
{
|
||||||
|
$ok = null;
|
||||||
|
$request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
|
||||||
|
'group_id' => $group->id));
|
||||||
|
if ($request) {
|
||||||
|
if (Event::handle('StartJoinGroup', array($group, $this))) {
|
||||||
|
$ok = Group_member::join($group->id, $this->id);
|
||||||
|
$request->delete();
|
||||||
|
Event::handle('EndJoinGroup', array($group, $this));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception(_m('Invalid group join approval: not pending.'));
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave a group that this profile is a member of.
|
||||||
|
*
|
||||||
|
* @param User_group $group
|
||||||
|
*/
|
||||||
|
function leaveGroup(User_group $group)
|
||||||
|
{
|
||||||
|
if (Event::handle('StartLeaveGroup', array($group, $this))) {
|
||||||
|
Group_member::leave($group->id, $this->id);
|
||||||
|
Event::handle('EndLeaveGroup', array($group, $this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function avatarUrl($size=AVATAR_PROFILE_SIZE)
|
function avatarUrl($size=AVATAR_PROFILE_SIZE)
|
||||||
{
|
{
|
||||||
$avatar = $this->getAvatar($size);
|
$avatar = $this->getAvatar($size);
|
||||||
|
|
|
@ -68,6 +68,9 @@ class User extends Memcached_DataObject
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Profile
|
||||||
|
*/
|
||||||
function getProfile()
|
function getProfile()
|
||||||
{
|
{
|
||||||
$profile = Profile::staticGet('id', $this->id);
|
$profile = Profile::staticGet('id', $this->id);
|
||||||
|
@ -596,6 +599,30 @@ class User extends Memcached_DataObject
|
||||||
return $profile->getGroups($offset, $limit);
|
return $profile->getGroups($offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to join the given group.
|
||||||
|
* May throw exceptions on failure.
|
||||||
|
*
|
||||||
|
* @param User_group $group
|
||||||
|
* @return Group_member
|
||||||
|
*/
|
||||||
|
function joinGroup(User_group $group)
|
||||||
|
{
|
||||||
|
$profile = $this->getProfile();
|
||||||
|
return $profile->joinGroup($group);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave a group that this user is a member of.
|
||||||
|
*
|
||||||
|
* @param User_group $group
|
||||||
|
*/
|
||||||
|
function leaveGroup(User_group $group)
|
||||||
|
{
|
||||||
|
$profile = $this->getProfile();
|
||||||
|
return $profile->leaveGroup($group);
|
||||||
|
}
|
||||||
|
|
||||||
function getSubscriptions($offset=0, $limit=null)
|
function getSubscriptions($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
class User_group extends Memcached_DataObject
|
class User_group extends Memcached_DataObject
|
||||||
{
|
{
|
||||||
|
const JOIN_POLICY_OPEN = 0;
|
||||||
|
const JOIN_POLICY_MODERATE = 1;
|
||||||
|
|
||||||
###START_AUTOCODE
|
###START_AUTOCODE
|
||||||
/* the code below is auto generated do not remove the above tag */
|
/* the code below is auto generated do not remove the above tag */
|
||||||
|
|
||||||
|
@ -24,6 +27,7 @@ class User_group extends Memcached_DataObject
|
||||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
||||||
public $uri; // varchar(255) unique_key
|
public $uri; // varchar(255) unique_key
|
||||||
public $mainpage; // varchar(255)
|
public $mainpage; // varchar(255)
|
||||||
|
public $join_policy; // tinyint
|
||||||
|
|
||||||
/* Static get */
|
/* Static get */
|
||||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); }
|
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); }
|
||||||
|
@ -149,6 +153,36 @@ class User_group extends Memcached_DataObject
|
||||||
return $members;
|
return $members;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get pending members, who have not yet been approved.
|
||||||
|
*
|
||||||
|
* @param int $offset
|
||||||
|
* @param int $limit
|
||||||
|
* @return Profile
|
||||||
|
*/
|
||||||
|
function getRequests($offset=0, $limit=null)
|
||||||
|
{
|
||||||
|
$qry =
|
||||||
|
'SELECT profile.* ' .
|
||||||
|
'FROM profile JOIN group_join_queue '.
|
||||||
|
'ON profile.id = group_join_queue.profile_id ' .
|
||||||
|
'WHERE group_join_queue.group_id = %d ' .
|
||||||
|
'ORDER BY group_join_queue.created DESC ';
|
||||||
|
|
||||||
|
if ($limit != null) {
|
||||||
|
if (common_config('db','type') == 'pgsql') {
|
||||||
|
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||||
|
} else {
|
||||||
|
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$members = new Profile();
|
||||||
|
|
||||||
|
$members->query(sprintf($qry, $this->id));
|
||||||
|
return $members;
|
||||||
|
}
|
||||||
|
|
||||||
function getMemberCount()
|
function getMemberCount()
|
||||||
{
|
{
|
||||||
// XXX: WORM cache this
|
// XXX: WORM cache this
|
||||||
|
@ -511,6 +545,11 @@ class User_group extends Memcached_DataObject
|
||||||
$group->uri = $uri;
|
$group->uri = $uri;
|
||||||
$group->mainpage = $mainpage;
|
$group->mainpage = $mainpage;
|
||||||
$group->created = common_sql_now();
|
$group->created = common_sql_now();
|
||||||
|
if (isset($fields['join_policy'])) {
|
||||||
|
$group->join_policy = intval($fields['join_policy']);
|
||||||
|
} else {
|
||||||
|
$group->join_policy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (Event::handle('StartGroupSave', array(&$group))) {
|
if (Event::handle('StartGroupSave', array(&$group))) {
|
||||||
|
|
||||||
|
|
|
@ -658,6 +658,7 @@ created = 142
|
||||||
modified = 384
|
modified = 384
|
||||||
uri = 2
|
uri = 2
|
||||||
mainpage = 2
|
mainpage = 2
|
||||||
|
join_policy = 1
|
||||||
|
|
||||||
[user_group__keys]
|
[user_group__keys]
|
||||||
id = N
|
id = N
|
||||||
|
|
|
@ -720,6 +720,7 @@ $schema['user_group'] = array(
|
||||||
|
|
||||||
'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'),
|
'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'),
|
||||||
'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'),
|
'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page for group info to link to'),
|
||||||
|
'join_policy' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'),
|
||||||
),
|
),
|
||||||
'primary key' => array('id'),
|
'primary key' => array('id'),
|
||||||
'unique keys' => array(
|
'unique keys' => array(
|
||||||
|
@ -1096,3 +1097,5 @@ $schema['schema_version'] = array(
|
||||||
),
|
),
|
||||||
'primary key' => array('table_name'),
|
'primary key' => array('table_name'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$schema['group_join_queue'] = Group_join_queue::schemaDef();
|
||||||
|
|
|
@ -163,10 +163,7 @@ class ActivityImporter extends QueueHandler
|
||||||
throw new ClientException(_("User is already a member of this group."));
|
throw new ClientException(_("User is already a member of this group."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
$user->joinGroup($group);
|
||||||
Group_member::join($group->id, $user->id);
|
|
||||||
Event::handle('EndJoinGroup', array($group, $user));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: largely cadged from Ostatus_profile::processNote()
|
// XXX: largely cadged from Ostatus_profile::processNote()
|
||||||
|
|
|
@ -116,7 +116,7 @@ class ActivityMover extends QueueHandler
|
||||||
$sink->postActivity($act);
|
$sink->postActivity($act);
|
||||||
$group = User_group::staticGet('uri', $act->objects[0]->id);
|
$group = User_group::staticGet('uri', $act->objects[0]->id);
|
||||||
if (!empty($group)) {
|
if (!empty($group)) {
|
||||||
Group_member::leave($group->id, $user->id);
|
$user->leaveGroup($group);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ActivityVerb::FOLLOW:
|
case ActivityVerb::FOLLOW:
|
||||||
|
|
122
lib/approvegroupform.php
Normal file
122
lib/approvegroupform.php
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Form for leaving a group
|
||||||
|
*
|
||||||
|
* 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 Form
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @copyright 2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/lib/form.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for leaving a group
|
||||||
|
*
|
||||||
|
* @category Form
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*
|
||||||
|
* @see UnsubscribeForm
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ApproveGroupForm extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* group for user to leave
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $group = null;
|
||||||
|
var $profile = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param HTMLOutputter $out output channel
|
||||||
|
* @param group $group group to leave
|
||||||
|
*/
|
||||||
|
|
||||||
|
function __construct($out=null, $group=null, $profile=null)
|
||||||
|
{
|
||||||
|
parent::__construct($out);
|
||||||
|
|
||||||
|
$this->group = $group;
|
||||||
|
$this->profile = $profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*
|
||||||
|
* @return string ID of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
function id()
|
||||||
|
{
|
||||||
|
return 'group-cancel-' . $this->group->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class of the form
|
||||||
|
*
|
||||||
|
* @return string of the form class
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_group_join ajax';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action of the form
|
||||||
|
*
|
||||||
|
* @return string URL of the action
|
||||||
|
*/
|
||||||
|
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
$params = array();
|
||||||
|
if ($this->profile) {
|
||||||
|
$params['profile_id'] = $this->profile->id;
|
||||||
|
}
|
||||||
|
return common_local_url('approvegroup',
|
||||||
|
array('id' => $this->group->id), $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit('submit', _('Approve'));
|
||||||
|
}
|
||||||
|
}
|
122
lib/cancelgroupform.php
Normal file
122
lib/cancelgroupform.php
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Form for leaving a group
|
||||||
|
*
|
||||||
|
* 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 Form
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @copyright 2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/lib/form.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for leaving a group
|
||||||
|
*
|
||||||
|
* @category Form
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*
|
||||||
|
* @see UnsubscribeForm
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CancelGroupForm extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* group for user to leave
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $group = null;
|
||||||
|
var $profile = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param HTMLOutputter $out output channel
|
||||||
|
* @param group $group group to leave
|
||||||
|
*/
|
||||||
|
|
||||||
|
function __construct($out=null, $group=null, $profile=null)
|
||||||
|
{
|
||||||
|
parent::__construct($out);
|
||||||
|
|
||||||
|
$this->group = $group;
|
||||||
|
$this->profile = $profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*
|
||||||
|
* @return string ID of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
function id()
|
||||||
|
{
|
||||||
|
return 'group-cancel-' . $this->group->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class of the form
|
||||||
|
*
|
||||||
|
* @return string of the form class
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_group_leave ajax';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action of the form
|
||||||
|
*
|
||||||
|
* @return string URL of the action
|
||||||
|
*/
|
||||||
|
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
$params = array();
|
||||||
|
if ($this->profile) {
|
||||||
|
$params['profile_id'] = $this->profile->id;
|
||||||
|
}
|
||||||
|
return common_local_url('cancelgroup',
|
||||||
|
array('id' => $this->group->id), $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit('submit', _('Cancel join request'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -352,10 +352,7 @@ class JoinCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartJoinGroup', array($group, $cur))) {
|
$cur->joinGroup($group);
|
||||||
Group_member::join($group->id, $cur->id);
|
|
||||||
Event::handle('EndJoinGroup', array($group, $cur));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Message given having failed to add a user to a group.
|
// TRANS: Message given having failed to add a user to a group.
|
||||||
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
|
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
|
||||||
|
@ -400,10 +397,7 @@ class DropCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartLeaveGroup', array($group, $cur))) {
|
$cur->leaveGroup($group);
|
||||||
Group_member::leave($group->id, $cur->id);
|
|
||||||
Event::handle('EndLeaveGroup', array($group, $cur));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Message given having failed to remove a user from a group.
|
// TRANS: Message given having failed to remove a user from a group.
|
||||||
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
|
// TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
|
||||||
|
|
130
lib/groupblockform.php
Normal file
130
lib/groupblockform.php
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for blocking a user from a group
|
||||||
|
*
|
||||||
|
* @category Form
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*
|
||||||
|
* @see BlockForm
|
||||||
|
*/
|
||||||
|
class GroupBlockForm extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Profile of user to block
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $profile = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group to block the user from
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $group = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return-to args
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $args = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param HTMLOutputter $out output channel
|
||||||
|
* @param Profile $profile profile of user to block
|
||||||
|
* @param User_group $group group to block user from
|
||||||
|
* @param array $args return-to args
|
||||||
|
*/
|
||||||
|
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||||
|
{
|
||||||
|
parent::__construct($out);
|
||||||
|
|
||||||
|
$this->profile = $profile;
|
||||||
|
$this->group = $group;
|
||||||
|
$this->args = $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*
|
||||||
|
* @return int ID of the form
|
||||||
|
*/
|
||||||
|
function id()
|
||||||
|
{
|
||||||
|
// This should be unique for the page.
|
||||||
|
return 'block-' . $this->profile->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class of the form
|
||||||
|
*
|
||||||
|
* @return string class of the form
|
||||||
|
*/
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_group_block';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action of the form
|
||||||
|
*
|
||||||
|
* @return string URL of the action
|
||||||
|
*/
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
return common_local_url('groupblock');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legend of the Form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formLegend()
|
||||||
|
{
|
||||||
|
// TRANS: Form legend for form to block user from a group.
|
||||||
|
$this->out->element('legend', null, _('Block user from group'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data elements of the form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formData()
|
||||||
|
{
|
||||||
|
$this->out->hidden('blockto-' . $this->profile->id,
|
||||||
|
$this->profile->id,
|
||||||
|
'blockto');
|
||||||
|
$this->out->hidden('blockgroup-' . $this->group->id,
|
||||||
|
$this->group->id,
|
||||||
|
'blockgroup');
|
||||||
|
if ($this->args) {
|
||||||
|
foreach ($this->args as $k => $v) {
|
||||||
|
$this->out->hidden('returnto-' . $k, $v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit(
|
||||||
|
'submit',
|
||||||
|
// TRANS: Button text for the form that will block a user from a group.
|
||||||
|
_m('BUTTON','Block'),
|
||||||
|
'submit',
|
||||||
|
null,
|
||||||
|
// TRANS: Submit button title.
|
||||||
|
_m('TOOLTIP', 'Block this user'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -186,6 +186,15 @@ class GroupEditForm extends Form
|
||||||
common_config('group', 'maxaliases')));;
|
common_config('group', 'maxaliases')));;
|
||||||
$this->out->elementEnd('li');
|
$this->out->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
$this->out->elementStart('li');
|
||||||
|
$this->out->dropdown('join_policy',
|
||||||
|
_('Membership policy'),
|
||||||
|
array(User_group::JOIN_POLICY_OPEN => _('Open to all'),
|
||||||
|
User_group::JOIN_POLICY_MODERATE => _('Admin must approve all members')),
|
||||||
|
_('Whether admin approval is required to join this group.'),
|
||||||
|
false,
|
||||||
|
(empty($this->group->join_policy)) ? User_group::JOIN_POLICY_OPEN : $this->group->join_policy);
|
||||||
|
$this->out->elementEnd('li');
|
||||||
Event::handle('EndGroupEditFormData', array($this));
|
Event::handle('EndGroupEditFormData', array($this));
|
||||||
}
|
}
|
||||||
$this->out->elementEnd('ul');
|
$this->out->elementEnd('ul');
|
||||||
|
|
18
lib/groupmemberlist.php
Normal file
18
lib/groupmemberlist.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class GroupMemberList extends ProfileList
|
||||||
|
{
|
||||||
|
var $group = null;
|
||||||
|
|
||||||
|
function __construct($profile, $group, $action)
|
||||||
|
{
|
||||||
|
parent::__construct($profile, $action);
|
||||||
|
|
||||||
|
$this->group = $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
function newListItem($profile)
|
||||||
|
{
|
||||||
|
return new GroupMemberListItem($profile, $this->group, $this->action);
|
||||||
|
}
|
||||||
|
}
|
105
lib/groupmemberlistitem.php
Normal file
105
lib/groupmemberlistitem.php
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class GroupMemberListItem extends ProfileListItem
|
||||||
|
{
|
||||||
|
var $group = null;
|
||||||
|
|
||||||
|
function __construct($profile, $group, $action)
|
||||||
|
{
|
||||||
|
parent::__construct($profile, $action);
|
||||||
|
|
||||||
|
$this->group = $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showFullName()
|
||||||
|
{
|
||||||
|
parent::showFullName();
|
||||||
|
if ($this->profile->isAdmin($this->group)) {
|
||||||
|
$this->out->text(' '); // for separating the classes.
|
||||||
|
// TRANS: Indicator in group members list that this user is a group administrator.
|
||||||
|
$this->out->element('span', 'role', _('Admin'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showActions()
|
||||||
|
{
|
||||||
|
$this->startActions();
|
||||||
|
if (Event::handle('StartProfileListItemActionElements', array($this))) {
|
||||||
|
$this->showSubscribeButton();
|
||||||
|
$this->showMakeAdminForm();
|
||||||
|
$this->showGroupBlockForm();
|
||||||
|
Event::handle('EndProfileListItemActionElements', array($this));
|
||||||
|
}
|
||||||
|
$this->endActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMakeAdminForm()
|
||||||
|
{
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
if (!empty($user) &&
|
||||||
|
$user->id != $this->profile->id &&
|
||||||
|
($user->isAdmin($this->group) || $user->hasRight(Right::MAKEGROUPADMIN)) &&
|
||||||
|
!$this->profile->isAdmin($this->group)) {
|
||||||
|
$this->out->elementStart('li', 'entity_make_admin');
|
||||||
|
$maf = new MakeAdminForm($this->out, $this->profile, $this->group,
|
||||||
|
$this->returnToArgs());
|
||||||
|
$maf->show();
|
||||||
|
$this->out->elementEnd('li');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function showGroupBlockForm()
|
||||||
|
{
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
|
||||||
|
$this->out->elementStart('li', 'entity_block');
|
||||||
|
$bf = new GroupBlockForm($this->out, $this->profile, $this->group,
|
||||||
|
$this->returnToArgs());
|
||||||
|
$bf->show();
|
||||||
|
$this->out->elementEnd('li');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function linkAttributes()
|
||||||
|
{
|
||||||
|
$aAttrs = parent::linkAttributes();
|
||||||
|
|
||||||
|
if (common_config('nofollow', 'members')) {
|
||||||
|
$aAttrs['rel'] .= ' nofollow';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $aAttrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function homepageAttributes()
|
||||||
|
{
|
||||||
|
$aAttrs = parent::linkAttributes();
|
||||||
|
|
||||||
|
if (common_config('nofollow', 'members')) {
|
||||||
|
$aAttrs['rel'] = 'nofollow';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $aAttrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch necessary return-to arguments for the profile forms
|
||||||
|
* to return to this list when they're done.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function returnToArgs()
|
||||||
|
{
|
||||||
|
$args = array('action' => 'groupmembers',
|
||||||
|
'nickname' => $this->group->nickname);
|
||||||
|
$page = $this->out->arg('page');
|
||||||
|
if ($page) {
|
||||||
|
$args['param-page'] = $page;
|
||||||
|
}
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -100,6 +100,18 @@ class GroupNav extends Menu
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
|
|
||||||
if ($cur && $cur->isAdmin($this->group)) {
|
if ($cur && $cur->isAdmin($this->group)) {
|
||||||
|
$pending = $this->countPendingMembers();
|
||||||
|
if ($pending || $this->group->join_policy == User_group::JOIN_POLICY_MODERATE) {
|
||||||
|
$this->out->menuItem(common_local_url('groupqueue', array('nickname' =>
|
||||||
|
$nickname)),
|
||||||
|
// TRANS: Menu item in the group navigation page. Only shown for group administrators.
|
||||||
|
sprintf(_m('MENU','Pending members (%d)'), $pending),
|
||||||
|
// TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
|
||||||
|
// TRANS: %s is the nickname of the group.
|
||||||
|
sprintf(_m('TOOLTIP','%s pending members'), $nickname),
|
||||||
|
$action_name == 'groupqueue',
|
||||||
|
'nav_group_pending');
|
||||||
|
}
|
||||||
$this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
|
$this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
|
||||||
$nickname)),
|
$nickname)),
|
||||||
// TRANS: Menu item in the group navigation page. Only shown for group administrators.
|
// TRANS: Menu item in the group navigation page. Only shown for group administrators.
|
||||||
|
@ -141,4 +153,11 @@ class GroupNav extends Menu
|
||||||
}
|
}
|
||||||
$this->out->elementEnd('ul');
|
$this->out->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function countPendingMembers()
|
||||||
|
{
|
||||||
|
$req = new Group_join_queue();
|
||||||
|
$req->group_id = $this->group->id;
|
||||||
|
return $req->count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,14 @@ class GroupProfileBlock extends ProfileBlock
|
||||||
$this->out->elementStart('li', 'entity_subscribe');
|
$this->out->elementStart('li', 'entity_subscribe');
|
||||||
if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
|
if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
|
||||||
if ($cur) {
|
if ($cur) {
|
||||||
if ($cur->isMember($this->group)) {
|
$profile = $cur->getProfile();
|
||||||
|
if ($profile->isMember($this->group)) {
|
||||||
$lf = new LeaveForm($this->out, $this->group);
|
$lf = new LeaveForm($this->out, $this->group);
|
||||||
$lf->show();
|
$lf->show();
|
||||||
} else if (!Group_block::isBlocked($this->group, $cur->getProfile())) {
|
} else if ($profile->isPendingMember($this->group)) {
|
||||||
|
$cf = new CancelGroupForm($this->out, $this->group);
|
||||||
|
$cf->show();
|
||||||
|
} else if (!Group_block::isBlocked($this->group, $profile)) {
|
||||||
$jf = new JoinForm($this->out, $this->group);
|
$jf = new JoinForm($this->out, $this->group);
|
||||||
$jf->show();
|
$jf->show();
|
||||||
}
|
}
|
||||||
|
|
125
lib/makeadminform.php
Normal file
125
lib/makeadminform.php
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for making a user an admin for a group
|
||||||
|
*
|
||||||
|
* @category Form
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
class MakeAdminForm extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Profile of user to block
|
||||||
|
*/
|
||||||
|
var $profile = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group to block the user from
|
||||||
|
*/
|
||||||
|
var $group = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return-to args
|
||||||
|
*/
|
||||||
|
var $args = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param HTMLOutputter $out output channel
|
||||||
|
* @param Profile $profile profile of user to block
|
||||||
|
* @param User_group $group group to block user from
|
||||||
|
* @param array $args return-to args
|
||||||
|
*/
|
||||||
|
function __construct($out=null, $profile=null, $group=null, $args=null)
|
||||||
|
{
|
||||||
|
parent::__construct($out);
|
||||||
|
|
||||||
|
$this->profile = $profile;
|
||||||
|
$this->group = $group;
|
||||||
|
$this->args = $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*
|
||||||
|
* @return int ID of the form
|
||||||
|
*/
|
||||||
|
function id()
|
||||||
|
{
|
||||||
|
// This should be unique for the page.
|
||||||
|
return 'makeadmin-' . $this->profile->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class of the form
|
||||||
|
*
|
||||||
|
* @return string class of the form
|
||||||
|
*/
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_make_admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action of the form
|
||||||
|
*
|
||||||
|
* @return string URL of the action
|
||||||
|
*/
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
return common_local_url('makeadmin', array('nickname' => $this->group->nickname));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legend of the Form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formLegend()
|
||||||
|
{
|
||||||
|
// TRANS: Form legend for form to make a user a group admin.
|
||||||
|
$this->out->element('legend', null, _('Make user an admin of the group'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data elements of the form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formData()
|
||||||
|
{
|
||||||
|
$this->out->hidden('profileid-' . $this->profile->id,
|
||||||
|
$this->profile->id,
|
||||||
|
'profileid');
|
||||||
|
$this->out->hidden('groupid-' . $this->group->id,
|
||||||
|
$this->group->id,
|
||||||
|
'groupid');
|
||||||
|
if ($this->args) {
|
||||||
|
foreach ($this->args as $k => $v) {
|
||||||
|
$this->out->hidden('returnto-' . $k, $v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit(
|
||||||
|
'submit',
|
||||||
|
// TRANS: Button text for the form that will make a user administrator.
|
||||||
|
_m('BUTTON','Make Admin'),
|
||||||
|
'submit',
|
||||||
|
null,
|
||||||
|
// TRANS: Submit button title.
|
||||||
|
_m('TOOLTIP','Make this user an admin'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -364,7 +364,7 @@ class Router
|
||||||
|
|
||||||
$m->connect('group/new', array('action' => 'newgroup'));
|
$m->connect('group/new', array('action' => 'newgroup'));
|
||||||
|
|
||||||
foreach (array('edit', 'join', 'leave', 'delete') as $v) {
|
foreach (array('edit', 'join', 'leave', 'delete', 'cancel', 'approve') as $v) {
|
||||||
$m->connect('group/:nickname/'.$v,
|
$m->connect('group/:nickname/'.$v,
|
||||||
array('action' => $v.'group'),
|
array('action' => $v.'group'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
@ -391,6 +391,10 @@ class Router
|
||||||
array('action' => 'makeadmin'),
|
array('action' => 'makeadmin'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
|
||||||
|
$m->connect('group/:nickname/members/pending',
|
||||||
|
array('action' => 'groupqueue'),
|
||||||
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
|
||||||
$m->connect('group/:id/id',
|
$m->connect('group/:id/id',
|
||||||
array('action' => 'groupbyid'),
|
array('action' => 'groupbyid'),
|
||||||
array('id' => '[0-9]+'));
|
array('id' => '[0-9]+'));
|
||||||
|
|
|
@ -68,10 +68,7 @@ class ForceGroupPlugin extends Plugin
|
||||||
$group = User_group::getForNickname($nickname);
|
$group = User_group::getForNickname($nickname);
|
||||||
if ($group && !$profile->isMember($group)) {
|
if ($group && !$profile->isMember($group)) {
|
||||||
try {
|
try {
|
||||||
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
$profile->joinGroup($group);
|
||||||
Group_member::join($group->id, $user->id);
|
|
||||||
Event::handle('EndJoinGroup', array($group, $user));
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server exception.
|
// TRANS: Server exception.
|
||||||
// TRANS: %1$s is a user nickname, %2$s is a group nickname.
|
// TRANS: %1$s is a user nickname, %2$s is a group nickname.
|
||||||
|
|
|
@ -129,9 +129,9 @@ class ModPlusPlugin extends Plugin
|
||||||
* Currently only adds output for remote profiles, nothing for local users.
|
* Currently only adds output for remote profiles, nothing for local users.
|
||||||
*
|
*
|
||||||
* @param HTMLOutputter $out
|
* @param HTMLOutputter $out
|
||||||
* @param Profile $profile
|
* @param Profile $profile (may also be an ArrayWrapper... sigh)
|
||||||
*/
|
*/
|
||||||
protected function showProfileOptions(HTMLOutputter $out, Profile $profile)
|
protected function showProfileOptions(HTMLOutputter $out, $profile)
|
||||||
{
|
{
|
||||||
$isRemote = !(User::staticGet('id', $profile->id));
|
$isRemote = !(User::staticGet('id', $profile->id));
|
||||||
if ($isRemote) {
|
if ($isRemote) {
|
||||||
|
|
|
@ -788,7 +788,7 @@ class OStatusPlugin extends Plugin
|
||||||
* it'll be left with a stray membership record.
|
* it'll be left with a stray membership record.
|
||||||
*
|
*
|
||||||
* @param User_group $group
|
* @param User_group $group
|
||||||
* @param User $user
|
* @param Profile $user
|
||||||
*
|
*
|
||||||
* @return mixed hook return value
|
* @return mixed hook return value
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -149,14 +149,7 @@ class GroupsalmonAction extends SalmonAction
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @fixme that event currently passes a user from main UI
|
$profile->joinGroup($this->group);
|
||||||
// Event should probably move into Group_member::join
|
|
||||||
// and take a Profile object.
|
|
||||||
//
|
|
||||||
//if (Event::handle('StartJoinGroup', array($this->group, $profile))) {
|
|
||||||
Group_member::join($this->group->id, $profile->id);
|
|
||||||
//Event::handle('EndJoinGroup', array($this->group, $profile));
|
|
||||||
//}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error. %1$s is a profile URI, %2$s is a group nickname.
|
// TRANS: Server error. %1$s is a profile URI, %2$s is a group nickname.
|
||||||
$this->serverError(sprintf(_m('Could not join remote user %1$s to group %2$s.'),
|
$this->serverError(sprintf(_m('Could not join remote user %1$s to group %2$s.'),
|
||||||
|
@ -181,11 +174,7 @@ class GroupsalmonAction extends SalmonAction
|
||||||
$profile = $oprofile->localProfile();
|
$profile = $oprofile->localProfile();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @fixme event needs to be refactored as above
|
$profile->leaveGroup($this->group);
|
||||||
//if (Event::handle('StartLeaveGroup', array($this->group, $profile))) {
|
|
||||||
Group_member::leave($this->group->id, $profile->id);
|
|
||||||
//Event::handle('EndLeaveGroup', array($this->group, $profile));
|
|
||||||
//}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error. %1$s is a profile URI, %2$s is a group nickname.
|
// TRANS: Server error. %1$s is a profile URI, %2$s is a group nickname.
|
||||||
$this->serverError(sprintf(_m('Could not remove remote user %1$s from group %2$s.'),
|
$this->serverError(sprintf(_m('Could not remove remote user %1$s from group %2$s.'),
|
||||||
|
|
|
@ -141,18 +141,12 @@ class OStatusGroupAction extends OStatusSubAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
try {
|
||||||
$ok = Group_member::join($this->oprofile->group_id, $user->id);
|
$user->joinGroup($group);
|
||||||
if ($ok) {
|
} catch (Exception $e) {
|
||||||
Event::handle('EndJoinGroup', array($group, $user));
|
|
||||||
$this->success();
|
|
||||||
} else {
|
|
||||||
// TRANS: OStatus remote group subscription dialog error.
|
|
||||||
$this->showForm(_m('Remote group join failed!'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TRANS: OStatus remote group subscription dialog error.
|
// TRANS: OStatus remote group subscription dialog error.
|
||||||
$this->showForm(_m('Remote group join aborted!'));
|
$this->showForm(_m('Remote group join failed!'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user