]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
Rip out user, group and site design customization code
[quix0rs-gnu-social.git] / classes / User_group.php
index 4d6dcfab689d536834e7b79e7f3bc6ddb16f6e0f..6168f219b998d51a022a9bb93d6efd51ae2c8724 100644 (file)
@@ -22,15 +22,17 @@ class User_group extends Memcached_DataObject
     public $homepage_logo;                   // varchar(255)
     public $stream_logo;                     // varchar(255)
     public $mini_logo;                       // varchar(255)
-    public $design_id;                       // int(4)
     public $created;                         // datetime   not_null default_0000-00-00%2000%3A00%3A00
     public $modified;                        // timestamp   not_null default_CURRENT_TIMESTAMP
     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); }
+    function staticGet($k,$v=NULL) {
+        return Memcached_DataObject::staticGet('User_group',$k,$v);
+    }
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
@@ -87,41 +89,11 @@ class User_group extends Memcached_DataObject
 
     function getNotices($offset, $limit, $since_id=null, $max_id=null)
     {
-        $stream = new NoticeStream(array($this, '_streamDirect'),
-                                   array(),
-                                   'user_group:notice_ids:' . $this->id);
+        $stream = new GroupNoticeStream($this);
 
         return $stream->getNotices($offset, $limit, $since_id, $max_id);
     }
 
-    function _streamDirect($offset, $limit, $since_id, $max_id)
-    {
-        $inbox = new Group_inbox();
-
-        $inbox->group_id = $this->id;
-
-        $inbox->selectAdd();
-        $inbox->selectAdd('notice_id');
-
-        Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
-        Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
-
-        $inbox->orderBy('created DESC, notice_id DESC');
-
-        if (!is_null($offset)) {
-            $inbox->limit($offset, $limit);
-        }
-
-        $ids = array();
-
-        if ($inbox->find()) {
-            while ($inbox->fetch()) {
-                $ids[] = $inbox->notice_id;
-            }
-        }
-
-        return $ids;
-    }
 
     function allowedNickname($nickname)
     {
@@ -366,11 +338,6 @@ class User_group extends Memcached_DataObject
         return null;
     }
 
-    function getDesign()
-    {
-        return Design::staticGet('id', $this->design_id);
-    }
-
     function getUserMembers()
     {
         // XXX: cache this
@@ -544,12 +511,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();
@@ -593,6 +567,8 @@ class User_group extends Memcached_DataObject
                 throw new ServerException(_('Could not set group membership.'));
             }
 
+            self::blow('profile:groups:%d', $userid);
+            
             if ($local) {
                 $local_group = new Local_group();
 
@@ -673,4 +649,10 @@ class User_group extends Memcached_DataObject
         }
         parent::delete();
     }
+
+    function isPrivate()
+    {
+        return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
+                $this->force_scope == 1);
+    }
 }