]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/moderatednoticestream.php
Merge branch 'master' into mmn_fixes
[quix0rs-gnu-social.git] / lib / moderatednoticestream.php
1 <?php
2
3 if (!defined('GNUSOCIAL')) { exit(1); }
4
5 /**
6  * Moderated notice stream, will take into account the scoping of
7  * notices as well as whether the profile is moderated somehow,
8  * such as by sandboxing or silencing.
9  *
10  * Inherits $this->scoped from ScopingNoticeStream as the Profile
11  * this stream is meant for. Can be null in case we're not logged in.
12  *
13  * @category  Stream
14  * @package   GNUsocial
15  * @author    Mikael Nordfeldth <mmn@hethane.se>
16  * @copyright 2016 Free Software Foundation, Inc.
17  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
18  * @link      https://gnu.io/social
19  */
20
21 class ModeratedNoticeStream extends ScopingNoticeStream
22 {
23     protected function filter(Notice $notice)
24     {
25         if (!parent::filter($notice)) {
26             return false;
27         }
28
29         // If the notice author is sandboxed
30         if ($notice->getProfile()->isSandboxed()) {
31             if (!$this->scoped instanceof Profile) {
32                 // Non-logged in users don't get to see posts by sandboxed users
33                 return false;
34             } elseif (!$notice->getProfile()->sameAs($this->scoped) && !$this->scoped->hasRight(Right::REVIEWSPAM)) {
35                 // And if we are logged in, deny if scoped user is neither the author nor has the right to review spam
36                 return false;
37             }
38         }
39
40         return true;
41     }
42 }