]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
Correct args for join event
[quix0rs-gnu-social.git] / classes / User_group.php
index 38cc5603db3c6f77648c8332e68dc69de6e0a611..0f1cc40b28f38e42a50b4e93323144962a40a021 100644 (file)
@@ -3,7 +3,7 @@
  * Table Definition for user_group
  */
 
-class User_group extends Memcached_DataObject
+class User_group extends Managed_DataObject
 {
     const JOIN_POLICY_OPEN = 0;
     const JOIN_POLICY_MODERATE = 1;
@@ -42,6 +42,41 @@ class User_group extends Memcached_DataObject
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
+    public static function schemaDef()
+    {
+        return array(
+            'fields' => array(
+                'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
+
+                'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'),
+                'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'),
+                'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'),
+                'description' => array('type' => 'text', 'description' => 'group description'),
+                'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'related physical location, if any'),
+
+                'original_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'original size logo'),
+                'homepage_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'homepage (profile) size logo'),
+                'stream_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'stream-sized logo'),
+                'mini_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'mini logo'),
+
+                'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
+                'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
+
+                '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'),      
+                'force_scope' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'),
+            ),
+            'primary key' => array('id'),
+            'unique keys' => array(
+                'user_group_uri_key' => array('uri'),
+            ),
+            'indexes' => array(
+                'user_group_nickname_idx' => array('nickname'),
+            ),
+        );
+    }
+
     function defaultLogo($size)
     {
         static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
@@ -174,6 +209,26 @@ class User_group extends Memcached_DataObject
         return $member_count;
     }
 
+    function getBlockedCount()
+    {
+        // XXX: WORM cache this
+
+        $block = new Group_block();
+        $block->group_id = $this->id;
+
+        return $block->count();
+    }
+
+    function getQueueCount()
+    {
+        // XXX: WORM cache this
+
+        $queue = new Group_join_queue();
+        $queue->group_id = $this->id;
+
+        return $queue->count();
+    }
+
     function getAdmins($offset=0, $limit=null)
     {
         $qry =
@@ -494,6 +549,18 @@ class User_group extends Memcached_DataObject
         // MAGICALLY put fields into current scope
         // @fixme kill extract(); it makes debugging absurdly hard
 
+               $defaults = array('nickname' => null,
+                                                 'fullname' => null,
+                                                 'homepage' => null,
+                                                 'description' => null,
+                                                 'location' => null,
+                                                 'uri' => null,
+                                                 'mainpage' => null,
+                                                 'aliases' => array(),
+                                                 'userid' => null);
+               
+               $fields = array_merge($defaults, $fields);
+               
         extract($fields);
 
         $group = new User_group();