示例#1
0
 protected function _inScope($profile)
 {
     $scope = is_null($this->scope) ? self::defaultScope() : $this->getScope();
     if ($scope === 0 && !$this->getProfile()->isPrivateStream()) {
         // Not scoping, so it is public.
         return !$this->isHiddenSpam($profile);
     }
     // If there's scope, anon cannot be in scope
     if (empty($profile)) {
         return false;
     }
     // Author is always in scope
     if ($this->profile_id == $profile->id) {
         return true;
     }
     // Only for users on this site
     if ($scope & Notice::SITE_SCOPE && !$profile->isLocal()) {
         return false;
     }
     // Only for users mentioned in the notice
     if ($scope & Notice::ADDRESSEE_SCOPE) {
         $reply = Reply::pkeyGet(array('notice_id' => $this->id, 'profile_id' => $profile->id));
         if (!$reply instanceof Reply) {
             return false;
         }
     }
     // Only for members of the given group
     if ($scope & Notice::GROUP_SCOPE) {
         // XXX: just query for the single membership
         $groups = $this->getGroups();
         $foundOne = false;
         foreach ($groups as $group) {
             if ($profile->isMember($group)) {
                 $foundOne = true;
                 break;
             }
         }
         if (!$foundOne) {
             return false;
         }
     }
     if ($scope & Notice::FOLLOWER_SCOPE || $this->getProfile()->isPrivateStream()) {
         if (!Subscription::exists($profile, $this->getProfile())) {
             return false;
         }
     }
     return !$this->isHiddenSpam($profile);
 }
示例#2
0
 protected function _inScope($profile)
 {
     if (!is_null($this->scope)) {
         $scope = $this->scope;
     } else {
         $scope = self::defaultScope();
     }
     // If there's no scope, anyone (even anon) is in scope.
     if ($scope == 0) {
         // Not private
         return !$this->isHiddenSpam($profile);
     } else {
         // Private, somehow
         // If there's scope, anon cannot be in scope
         if (empty($profile)) {
             return false;
         }
         // Author is always in scope
         if ($this->profile_id == $profile->id) {
             return true;
         }
         // Only for users on this site
         if ($scope & Notice::SITE_SCOPE) {
             $user = $profile->getUser();
             if (empty($user)) {
                 return false;
             }
         }
         // Only for users mentioned in the notice
         if ($scope & Notice::ADDRESSEE_SCOPE) {
             $repl = Reply::pkeyGet(array('notice_id' => $this->id, 'profile_id' => $profile->id));
             if (empty($repl)) {
                 return false;
             }
         }
         // Only for members of the given group
         if ($scope & Notice::GROUP_SCOPE) {
             // XXX: just query for the single membership
             $groups = $this->getGroups();
             $foundOne = false;
             foreach ($groups as $group) {
                 if ($profile->isMember($group)) {
                     $foundOne = true;
                     break;
                 }
             }
             if (!$foundOne) {
                 return false;
             }
         }
         // Only for followers of the author
         $author = null;
         if ($scope & Notice::FOLLOWER_SCOPE) {
             try {
                 $author = $this->getProfile();
             } catch (Exception $e) {
                 return false;
             }
             if (!Subscription::exists($profile, $author)) {
                 return false;
             }
         }
         return !$this->isHiddenSpam($profile);
     }
 }