]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add request_queue table and user_group.join_policy column, for upcoming join & subscr...
authorBrion Vibber <brion@pobox.com>
Mon, 21 Mar 2011 20:30:40 +0000 (13:30 -0700)
committerBrion Vibber <brion@pobox.com>
Mon, 21 Mar 2011 20:51:13 +0000 (13:51 -0700)
UI for setting the join policy is in, but not yet used.

actions/editgroup.php
actions/newgroup.php
classes/Request_queue.php [new file with mode: 0644]
classes/User_group.php
classes/statusnet.ini
db/core.php
lib/groupeditform.php

index 08a75da12c690658d2413ecd271c65b36ad1405e..f5bada04fc074e7162a7cb8ad1eebc997b83de8b 100644 (file)
@@ -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);
 
index 9682b875cb0c666a058c0b241b4310d939cd2225..540a42b9ba1554a84fa903519ba5cdc47fd985ba 100644 (file)
@@ -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 (file)
index 0000000..3d094b1
--- /dev/null
@@ -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')),
+            )
+        );
+    }
+}
index 5a9991fe9e3fd936221b64ef69b5d7f1362e2994..6ed51b506ba8a28b9a6715ac5f65153ded824a4e 100644 (file)
@@ -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))) {
 
index 338e5c5aeaace0486b78f87b1047e049df583e8e..f648fb3fbf183a30951ea091efd18155bc9d76dc 100644 (file)
@@ -621,6 +621,7 @@ created = 142
 modified = 384
 uri = 2
 mainpage = 2
+join_policy = 1
 
 [user_group__keys]
 id = N
index 16a59462d491bd2f884f3c454858486185e86331..4aa1911d467ddf31805724cbfb59f9602a5b4d53 100644 (file)
@@ -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();
index 3a2cf6bf4ab244eb28962a30566916a625768524..75f1344c11d59c2eca2205df1760bacc0e8b0f79 100644 (file)
@@ -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');