]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
use notifyDeferred for tag/untag so that it gets queued offline
[quix0rs-gnu-social.git] / classes / User_group.php
index c044594f1fc1ea19557fdaa63fb66d87f27d92c5..e993961118e355afc08f9580437b98db26ea99f2 100644 (file)
@@ -28,9 +28,12 @@ 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); }
+    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,42 +90,11 @@ class User_group extends Memcached_DataObject
 
     function getNotices($offset, $limit, $since_id=null, $max_id=null)
     {
-        $ids = Notice::stream(array($this, '_streamDirect'),
-                              array(),
-                              'user_group:notice_ids:' . $this->id,
-                              $offset, $limit, $since_id, $max_id);
+        $stream = new GroupNoticeStream($this);
 
-        return Notice::getStreamByIds($ids);
+        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)
     {
@@ -306,11 +278,11 @@ class User_group extends Memcached_DataObject
 
         $oldaliases = $this->getAliases();
 
-        # Delete stuff that's old that not in new
+        // Delete stuff that's old that not in new
 
         $to_delete = array_diff($oldaliases, $newaliases);
 
-        # Insert stuff that's in new and not in old
+        // Insert stuff that's in new and not in old
 
         $to_insert = array_diff($newaliases, $oldaliases);
 
@@ -545,12 +517,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();
@@ -674,4 +653,10 @@ class User_group extends Memcached_DataObject
         }
         parent::delete();
     }
+
+    function isPrivate()
+    {
+        return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
+                $this->force_scope == 1);
+    }
 }