X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile.php;h=f4452391c25819dadb930e08d7d2c9eb1d93db64;hb=b374e5f08b0a5b0321ddd0ac77baf4675274aba2;hp=a45511fe54b60a1a02d87258cb61656e2f9d1010;hpb=95d415257a43d5d4338ce22089463c1820b6bf8b;p=quix0rs-gnu-social.git diff --git a/classes/Profile.php b/classes/Profile.php index a45511fe54..f4452391c2 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -761,6 +761,36 @@ class Profile extends Managed_DataObject return Subscription::exists($this, $other); } + function readableBy(Profile $other=null) + { + // If it's not a private stream, it's readable by anyone + if (!$this->isPrivateStream()) { + return true; + } + + // If it's a private stream, $other must be a subscriber to $this + return is_null($other) ? false : $other->isSubscribed($this); + } + + function requiresSubscriptionApproval(Profile $other=null) + { + if (!$this->isLocal()) { + // We don't know for remote users, and we'll always be able to send + // the request. Whether it'll work immediately or require moderation + // can be determined in another function. + return false; + } + + // Assume that profiles _we_ subscribe to are permitted. Could be made configurable. + if (!is_null($other) && $this->isSubscribed($other)) { + return false; + } + + // If the local user either has a private stream (implies the following) + // or user has a moderation policy for new subscriptions, return true. + return $this->getUser()->private_stream || $this->getUser()->subscribe_policy === User::SUBSCRIBE_POLICY_MODERATE; + } + /** * Check if a pending subscription request is outstanding for this... *