]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/groupnoticestream.php
No more needed (for this fix) but maybe later. So I always only comment them out.
[quix0rs-gnu-social.git] / lib / groupnoticestream.php
index 26784458e0ea1c7a7590cd068593098bcc13dab5..723f064cb3523dab13b8de075fbd66b0e140ff1a 100644 (file)
@@ -46,15 +46,49 @@ if (!defined('STATUSNET')) {
  */
 class GroupNoticeStream extends ScopingNoticeStream
 {
+    var $group;
+    var $userProfile;
+
     function __construct($group, $profile = -1)
     {
         if (is_int($profile) && $profile == -1) {
             $profile = Profile::current();
         }
+        $this->group = $group;
+        $this->userProfile = $profile;
+
         parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group),
                                                     'user_group:notice_ids:' . $group->id),
                             $profile);
     }
+
+    function getNoticeIds($offset, $limit, $since_id, $max_id)
+    {
+        if ($this->impossibleStream()) {
+            return array();
+        } else {
+            return parent::getNoticeIds($offset, $limit, $since_id, $max_id);
+        }
+    }
+
+    function getNotices($offset, $limit, $sinceId = null, $maxId = null)
+    {
+        if ($this->impossibleStream()) {
+            return new ArrayWrapper(array());
+        } else {
+            return parent::getNotices($offset, $limit, $sinceId, $maxId);
+        }
+    }
+
+    function impossibleStream() 
+    {
+        if ($this->group->force_scope &&
+            (empty($this->userProfile) || !$this->userProfile->isMember($this->group))) {
+            return true;
+        }
+
+        return false;
+    }
 }
 
 /**