Declaring some more static functions properly

As a bonus I added type declaration on Profile_block::exists and
Subscription::exists respectively.
This commit is contained in:
Mikael Nordfeldth 2013-09-09 23:08:43 +02:00
parent a9c4bcd71f
commit 99312c8cc2
5 changed files with 15 additions and 18 deletions

View File

@ -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()

View File

@ -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));
}
}

View File

@ -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));

View File

@ -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;

View File

@ -104,7 +104,11 @@ class ApiAuthAction extends ApiAction
}
// NOTE: Make sure we're scoped properly based on the auths!
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