From: Brion Vibber Date: Mon, 21 Mar 2011 20:30:40 +0000 (-0700) Subject: Add request_queue table and user_group.join_policy column, for upcoming join & subscr... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0bec9cfdbc8edb05677ad9997058265dd32921b4;p=quix0rs-gnu-social.git 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. --- diff --git a/actions/editgroup.php b/actions/editgroup.php index 08a75da12c..f5bada04fc 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -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); diff --git a/actions/newgroup.php b/actions/newgroup.php index 9682b875cb..540a42b9ba 100644 --- a/actions/newgroup.php +++ b/actions/newgroup.php @@ -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; diff --git a/classes/Request_queue.php b/classes/Request_queue.php new file mode 100644 index 0000000000..3d094b1dfc --- /dev/null +++ b/classes/Request_queue.php @@ -0,0 +1,50 @@ + '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')), + ) + ); + } +} diff --git a/classes/User_group.php b/classes/User_group.php index 5a9991fe9e..6ed51b506b 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -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))) { diff --git a/classes/statusnet.ini b/classes/statusnet.ini index 338e5c5aea..f648fb3fbf 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -621,6 +621,7 @@ created = 142 modified = 384 uri = 2 mainpage = 2 +join_policy = 1 [user_group__keys] id = N diff --git a/db/core.php b/db/core.php index 16a59462d4..4aa1911d46 100644 --- a/db/core.php +++ b/db/core.php @@ -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(); diff --git a/lib/groupeditform.php b/lib/groupeditform.php index 3a2cf6bf4a..75f1344c11 100644 --- a/lib/groupeditform.php +++ b/lib/groupeditform.php @@ -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');