X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile.php;h=a58a1f07c6136646e44afd680bb44612fb0cbe9d;hb=eb1faa78658669bff57288ff48a4af4aa1a89c1b;hp=c5dd2dfda9da20e44ad3ee47d4f134b973263d00;hpb=2b901894c2c14f3e7e1c3eae8960f8a3c09310a0;p=quix0rs-gnu-social.git diff --git a/classes/Profile.php b/classes/Profile.php index c5dd2dfda9..a58a1f07c6 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1161,4 +1161,44 @@ class Profile extends Memcached_DataObject return $profile; } + + function canRead(Notice $notice) + { + if ($notice->scope & Notice::SITE_SCOPE) { + $user = $this->getUser(); + if (empty($user)) { + return false; + } + } + + if ($notice->scope & Notice::ADDRESSEE_SCOPE) { + $replies = $notice->getReplies(); + + if (!in_array($this->id, $replies)) { + $groups = $notice->getGroups(); + + $foundOne = false; + + foreach ($groups as $group) { + if ($this->isMember($group)) { + $foundOne = true; + break; + } + } + + if (!$foundOne) { + return false; + } + } + } + + if ($notice->scope & Notice::FOLLOWER_SCOPE) { + $author = $notice->getProfile(); + if (!Subscription::exists($this, $author)) { + return false; + } + } + + return true; + } }