diff --git a/classes/Profile.php b/classes/Profile.php index fe8e116419..bc0f6922e8 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1366,15 +1366,8 @@ class Profile extends Managed_DataObject function hasBlocked($other) { - $block = Profile_block::get($this->id, $other->id); - - if (empty($block)) { - $result = false; - } else { - $result = true; - } - - return $result; + $block = Profile_block::exists($this, $other); + return !empty($block); } function getAtomFeed() diff --git a/classes/Profile_block.php b/classes/Profile_block.php index d9b5cbba87..b30e3b244e 100644 --- a/classes/Profile_block.php +++ b/classes/Profile_block.php @@ -54,9 +54,9 @@ class Profile_block extends Managed_DataObject ); } - function get($blocker, $blocked) + static function exists(Profile $blocker, Profile $blocked) { - return Profile_block::pkeyGet(array('blocker' => $blocker, - 'blocked' => $blocked)); - } + return Profile_block::pkeyGet(array('blocker' => $blocker->id, + 'blocked' => $blocked->id)); + } } diff --git a/classes/Subscription.php b/classes/Subscription.php index 0c0c6489de..3f1819a841 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -185,7 +185,7 @@ class Subscription extends Managed_DataObject * Cancel a subscription * */ - function cancel(Profile $subscriber, Profile $other) + static function cancel(Profile $subscriber, Profile $other) { if (!self::exists($subscriber, $other)) { // TRANS: Exception thrown when trying to unsibscribe without a subscription. @@ -230,7 +230,7 @@ class Subscription extends Managed_DataObject return; } - function exists($subscriber, $other) + static function exists(Profile $subscriber, Profile $other) { $sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id, 'subscribed' => $other->id)); diff --git a/classes/User.php b/classes/User.php index e8e06a2d40..7a56e0f12e 100644 --- a/classes/User.php +++ b/classes/User.php @@ -632,11 +632,11 @@ class User extends Managed_DataObject return true; } - function unblock($other) + function unblock(Profile $other) { // Get the block record - $block = Profile_block::get($this->id, $other->id); + $block = Profile_block::exists($this->getProfile(), $other); if (!$block) { return false; diff --git a/lib/apiauthaction.php b/lib/apiauthaction.php index 3edcda4cb7..499c502480 100644 --- a/lib/apiauthaction.php +++ b/lib/apiauthaction.php @@ -104,7 +104,11 @@ class ApiAuthAction extends ApiAction } // NOTE: Make sure we're scoped properly based on the auths! - $this->scoped = $this->auth_user->getProfile(); + if (isset($this->auth_user) && !empty($this->auth_user)) { + $this->scoped = $this->auth_user->getProfile(); + } else { + $this->scoped = null; + } // Reject API calls with the wrong access level