]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/scopingnoticestream.php
Merge remote-tracking branch 'upstream/nightly' into nightly
[quix0rs-gnu-social.git] / lib / scopingnoticestream.php
index a7ecbcd56ba8c34f44251317e28a93309edce8a6..854903d33dee0414e5bab488052705afa08caa27 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    // This check helps protect against security problems;
-    // your code file can't be executed directly from the web.
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Class comment
@@ -49,17 +45,12 @@ class ScopingNoticeStream extends FilteringNoticeStream
 {
     protected $profile;
 
-    function __construct($upstream, $profile = null)
+    function __construct(NoticeStream $upstream, Profile $scoped=null)
     {
         parent::__construct($upstream);
 
-        if (empty($profile)) {
-            $user = common_current_user();
-            if (!empty($user)) {
-                $profile = $user->getProfile();
-            }
-        }
-        $this->profile = $profile;
+        $this->profile = $scoped;   // legacy
+        $this->scoped = $scoped;
     }
 
     /**
@@ -70,9 +61,29 @@ class ScopingNoticeStream extends FilteringNoticeStream
      * @return boolean whether to include the notice
      */
 
-    function filter($notice)
+    protected function filter(Notice $notice)
+    {
+        return $notice->inScope($this->scoped);
+    }
+
+    function prefill($notices)
     {
-        return $notice->inScope($this->profile);
+        // XXX: this should probably only be in the scoping one.
+            
+        Notice::fillGroups($notices);
+        Notice::fillReplies($notices);
+
+        if (common_config('notice', 'hidespam')) {
+
+            $profiles = Notice::getProfiles($notices);
+
+            foreach ($profiles as $profile) {
+                $pids[] = $profile->id;
+            }
+            
+            Profile_role::pivotGet('profile_id',
+                                   $pids,
+                                   array('role' => Profile_role::SILENCED));
+        }
     }
-    
 }