]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/scopingnoticestream.php
Merge branch 'nightly' into 'nightly'
[quix0rs-gnu-social.git] / lib / scopingnoticestream.php
index 30a7b708d202eb1a62539fc04b36ed4552e553b4..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,16 +45,12 @@ class ScopingNoticeStream extends FilteringNoticeStream
 {
     protected $profile;
 
-    function __construct($upstream, $profile = -1)
+    function __construct(NoticeStream $upstream, Profile $scoped=null)
     {
         parent::__construct($upstream);
 
-        // Invalid but not null
-        if (is_int($profile) && $profile == -1) {
-            $profile = Profile::current();
-        }
-
-        $this->profile = $profile;
+        $this->profile = $scoped;   // legacy
+        $this->scoped = $scoped;
     }
 
     /**
@@ -69,9 +61,9 @@ class ScopingNoticeStream extends FilteringNoticeStream
      * @return boolean whether to include the notice
      */
 
-    function filter($notice)
+    protected function filter(Notice $notice)
     {
-        return $notice->inScope($this->profile);
+        return $notice->inScope($this->scoped);
     }
 
     function prefill($notices)
@@ -80,5 +72,18 @@ class ScopingNoticeStream extends FilteringNoticeStream
             
         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));
+        }
     }
 }