forked from GNUsocial/gnu-social
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
* '1.0.x' of gitorious.org:statusnet/mainline: single flag for private groups add force_scope flag to User_group
This commit is contained in:
commit
e7124528a3
@ -185,7 +185,15 @@ class EditgroupAction extends GroupDesignAction
|
||||
$description = $this->trimmed('description');
|
||||
$location = $this->trimmed('location');
|
||||
$aliasstring = $this->trimmed('aliases');
|
||||
$join_policy = intval($this->arg('join_policy'));
|
||||
$private = $this->boolean('private');
|
||||
|
||||
if ($private) {
|
||||
$force_scope = 1;
|
||||
$join_policy = User_group::JOIN_POLICY_MODERATE;
|
||||
} else {
|
||||
$force_scope = 0;
|
||||
$join_policy = User_group::JOIN_POLICY_OPEN;
|
||||
}
|
||||
|
||||
if ($this->nicknameExists($nickname)) {
|
||||
// TRANS: Group edit form validation error.
|
||||
@ -267,6 +275,7 @@ class EditgroupAction extends GroupDesignAction
|
||||
$this->group->location = $location;
|
||||
$this->group->mainpage = common_local_url('showgroup', array('nickname' => $nickname));
|
||||
$this->group->join_policy = $join_policy;
|
||||
$this->group->force_scope = $force_scope;
|
||||
|
||||
$result = $this->group->update($orig);
|
||||
|
||||
|
@ -130,8 +130,8 @@ class NewgroupAction extends Action
|
||||
$homepage = $this->trimmed('homepage');
|
||||
$description = $this->trimmed('description');
|
||||
$location = $this->trimmed('location');
|
||||
$private = $this->boolean('private');
|
||||
$aliasstring = $this->trimmed('aliases');
|
||||
$join_policy = intval($this->arg('join_policy'));
|
||||
|
||||
if ($this->nicknameExists($nickname)) {
|
||||
// TRANS: Group create form validation error.
|
||||
@ -203,6 +203,14 @@ class NewgroupAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
if ($private) {
|
||||
$force_scope = 1;
|
||||
$join_policy = User_group::JOIN_POLICY_MODERATE;
|
||||
} else {
|
||||
$force_scope = 0;
|
||||
$join_policy = User_group::JOIN_POLICY_OPEN;
|
||||
}
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
// Checked in prepare() above
|
||||
@ -217,6 +225,7 @@ class NewgroupAction extends Action
|
||||
'aliases' => $aliases,
|
||||
'userid' => $cur->id,
|
||||
'join_policy' => $join_policy,
|
||||
'force_scope' => $force_scope,
|
||||
'local' => true));
|
||||
|
||||
$this->group = $group;
|
||||
|
@ -28,6 +28,7 @@ class User_group extends Memcached_DataObject
|
||||
public $uri; // varchar(255) unique_key
|
||||
public $mainpage; // varchar(255)
|
||||
public $join_policy; // tinyint
|
||||
public $force_scope; // tinyint
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); }
|
||||
@ -514,12 +515,19 @@ class User_group extends Memcached_DataObject
|
||||
$group->uri = $uri;
|
||||
$group->mainpage = $mainpage;
|
||||
$group->created = common_sql_now();
|
||||
|
||||
if (isset($fields['join_policy'])) {
|
||||
$group->join_policy = intval($fields['join_policy']);
|
||||
} else {
|
||||
$group->join_policy = 0;
|
||||
}
|
||||
|
||||
if (isset($fields['force_scope'])) {
|
||||
$group->force_scope = intval($fields['force_scope']);
|
||||
} else {
|
||||
$group->force_scope = 0;
|
||||
}
|
||||
|
||||
if (Event::handle('StartGroupSave', array(&$group))) {
|
||||
|
||||
$result = $group->insert();
|
||||
@ -643,4 +651,10 @@ class User_group extends Memcached_DataObject
|
||||
}
|
||||
parent::delete();
|
||||
}
|
||||
|
||||
function isPrivate()
|
||||
{
|
||||
return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
|
||||
$this->force_scope == 1);
|
||||
}
|
||||
}
|
||||
|
@ -625,6 +625,7 @@ modified = 384
|
||||
uri = 2
|
||||
mainpage = 2
|
||||
join_policy = 1
|
||||
force_scope = 1
|
||||
|
||||
[user_group__keys]
|
||||
id = N
|
||||
|
@ -202,17 +202,10 @@ class GroupEditForm extends Form
|
||||
$this->out->elementEnd('li');
|
||||
}
|
||||
$this->out->elementStart('li');
|
||||
$this->out->dropdown('join_policy',
|
||||
// TRANS: Dropdown fieldd label on group edit form.
|
||||
_('Membership policy'),
|
||||
// TRANS: Group membership policy option.
|
||||
array(User_group::JOIN_POLICY_OPEN => _('Open to all'),
|
||||
// TRANS: Group membership policy option.
|
||||
User_group::JOIN_POLICY_MODERATE => _('Admin must approve all members')),
|
||||
// TRANS: Dropdown field title on group edit form.
|
||||
_('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->checkbox('private', _('Private'),
|
||||
($this->out->arg('private')) ? $this->out->arg('private') :
|
||||
((!empty($this->group)) ? $this->group->isPrivate() : false),
|
||||
_('New members must be approved by admin and all posts are forced to be private'));
|
||||
$this->out->elementEnd('li');
|
||||
Event::handle('EndGroupEditFormData', array($this));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user