]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
fix constructor error in FileNoticeStream
[quix0rs-gnu-social.git] / classes / User_group.php
index 4d6dcfab689d536834e7b79e7f3bc6ddb16f6e0f..f72cc57533db1f8eb3f526b2016b6be0788bfcc9 100644 (file)
@@ -28,6 +28,7 @@ class User_group extends Memcached_DataObject
     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); }
@@ -87,41 +88,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)
     {
@@ -544,12 +515,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();
@@ -673,4 +651,10 @@ class User_group extends Memcached_DataObject
         }
         parent::delete();
     }
+
+    function isPrivate()
+    {
+        return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
+                $this->force_scope == 1);
+    }
 }