From 7fc5679e7e09972fa88f711f0f88eeeab8131dad Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 16 Mar 2011 22:55:14 -0400 Subject: [PATCH] function for checking scope rules for Profile --- classes/Profile.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/classes/Profile.php b/classes/Profile.php index 9566226951..fe097753d9 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1156,4 +1156,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; + } } -- 2.39.5