forked from GNUsocial/gnu-social
Add request_queue table and user_group.join_policy column, for upcoming join & subscription moderation.
UI for setting the join policy is in, but not yet used.
This commit is contained in:
parent
01ecca5e60
commit
0bec9cfdbc
@ -185,6 +185,7 @@ class EditgroupAction extends GroupDesignAction
|
||||
$description = $this->trimmed('description');
|
||||
$location = $this->trimmed('location');
|
||||
$aliasstring = $this->trimmed('aliases');
|
||||
$join_policy = intval($this->arg('join_policy'));
|
||||
|
||||
if ($this->nicknameExists($nickname)) {
|
||||
// TRANS: Group edit form validation error.
|
||||
@ -265,6 +266,7 @@ class EditgroupAction extends GroupDesignAction
|
||||
$this->group->description = $description;
|
||||
$this->group->location = $location;
|
||||
$this->group->mainpage = common_local_url('showgroup', array('nickname' => $nickname));
|
||||
$this->group->join_policy = $join_policy;
|
||||
|
||||
$result = $this->group->update($orig);
|
||||
|
||||
|
@ -131,6 +131,7 @@ class NewgroupAction extends Action
|
||||
$description = $this->trimmed('description');
|
||||
$location = $this->trimmed('location');
|
||||
$aliasstring = $this->trimmed('aliases');
|
||||
$join_policy = intval($this->arg('join_policy'));
|
||||
|
||||
if ($this->nicknameExists($nickname)) {
|
||||
// TRANS: Group create form validation error.
|
||||
@ -215,6 +216,7 @@ class NewgroupAction extends Action
|
||||
'location' => $location,
|
||||
'aliases' => $aliases,
|
||||
'userid' => $cur->id,
|
||||
'join_policy' => $join_policy,
|
||||
'local' => true));
|
||||
|
||||
$this->group = $group;
|
||||
|
50
classes/Request_queue.php
Normal file
50
classes/Request_queue.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Table Definition for request_queue
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Request_queue extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'request_queue'; // table name
|
||||
public $subscriber;
|
||||
public $subscribed;
|
||||
public $group_id;
|
||||
public $created;
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=null)
|
||||
{ return Memcached_DataObject::staticGet('Confirm_address',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array(
|
||||
'description' => 'Holder for subscription & group join requests awaiting moderation.',
|
||||
'fields' => array(
|
||||
'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
|
||||
'subscribed' => array('type' => 'int', 'description' => 'remote or local profile to subscribe to, if any'),
|
||||
'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'),
|
||||
),
|
||||
'unique key' => array(
|
||||
'request_queue_subscriber_subscribed_group_id' => array('subscriber', 'subscribed', 'group_id'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'request_queue_subscriber_created_idx' => array('subscriber', 'created'),
|
||||
'request_queue_subscribed_created_idx' => array('subscriber', 'created'),
|
||||
'request_queue_group_id_created_idx' => array('group_id', 'created'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'request_queue_subscriber_fkey' => array('profile', array('subscriber' => 'id')),
|
||||
'request_queue_subscribed_fkey' => array('profile', array('subscribed' => 'id')),
|
||||
'request_queue_group_id_fkey' => array('user_group', array('group_id' => 'id')),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ class User_group extends Memcached_DataObject
|
||||
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
|
||||
public $uri; // varchar(255) unique_key
|
||||
public $mainpage; // varchar(255)
|
||||
public $join_policy; // tinyint
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); }
|
||||
@ -511,6 +512,11 @@ 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 (Event::handle('StartGroupSave', array(&$group))) {
|
||||
|
||||
|
@ -621,6 +621,7 @@ created = 142
|
||||
modified = 384
|
||||
uri = 2
|
||||
mainpage = 2
|
||||
join_policy = 1
|
||||
|
||||
[user_group__keys]
|
||||
id = N
|
||||
|
@ -649,6 +649,7 @@ $schema['user_group'] = array(
|
||||
|
||||
'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'),
|
||||
'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'),
|
||||
'unique keys' => array(
|
||||
@ -1025,3 +1026,5 @@ $schema['schema_version'] = array(
|
||||
),
|
||||
'primary key' => array('table_name'),
|
||||
);
|
||||
|
||||
$schema['request_queue'] = Request_queue::schemaDef();
|
||||
|
@ -186,6 +186,15 @@ class GroupEditForm extends Form
|
||||
common_config('group', 'maxaliases')));;
|
||||
$this->out->elementEnd('li');
|
||||
}
|
||||
$this->out->elementStart('li');
|
||||
$this->out->dropdown('join_policy',
|
||||
_('Membership policy'),
|
||||
array(0 => _('Open to all'),
|
||||
1 => _('Admin must approve all members')),
|
||||
_('Whether admin approval is required to join this group.'),
|
||||
false,
|
||||
(empty($this->group->join_policy)) ? 0 : $this->group->join_policy);
|
||||
$this->out->elementEnd('li');
|
||||
Event::handle('EndGroupEditFormData', array($this));
|
||||
}
|
||||
$this->out->elementEnd('ul');
|
||||
|
Loading…
Reference in New Issue
Block a user