From: Evan Prodromou Date: Thu, 17 Mar 2011 02:55:14 +0000 (-0400) Subject: function for checking scope rules for Profile X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9af92f94bded2ee788785519f957756738e00738;p=quix0rs-gnu-social.git function for checking scope rules for Profile --- diff --git a/classes/Profile.php b/classes/Profile.php index 88edf5cbb3..ba7d6296f8 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1076,4 +1076,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; + } }