X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapifriendshipsexists.php;h=725178fd427bf52d0265909871cdfda465b900eb;hb=3dd734b2c3ea49c55467cfbfd4b3a5fb38456e87;hp=3d6e7448deec8f23a7a4998e06893818dda8b3ea;hpb=4ed8055f86d3e3c517a9e367607f60d595b77f37;p=quix0rs-gnu-social.git diff --git a/actions/apifriendshipsexists.php b/actions/apifriendshipsexists.php index 3d6e7448de..725178fd42 100644 --- a/actions/apifriendshipsexists.php +++ b/actions/apifriendshipsexists.php @@ -21,8 +21,10 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley - * @copyright 2009 StatusNet, Inc. + * @copyright 2009-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,25 +33,25 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/twitterapi.php'; +require_once INSTALLDIR . '/lib/apiprivateauth.php'; /** - * Tests for the existence of friendship between two users. Will return true if + * Tests for the existence of friendship between two users. Will return true if * user_a follows user_b, otherwise will return false. * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ -class ApiFriendshipsExistsAction extends TwitterApiAction +class ApiFriendshipsExistsAction extends ApiPrivateAuthAction { - - var $format = null; - var $user_a = null; - var $user_b = null; + var $profile_a = null; + var $profile_b = null; /** * Take arguments for running @@ -64,22 +66,8 @@ class ApiFriendshipsExistsAction extends TwitterApiAction { parent::prepare($args); - $this->format = $this->arg('format'); - - $user_a_id = $this->trimmed('user_a'); - $user_b_id = $this->trimmed('user_b'); - - common_debug("user_a = " . $user_a_id); - common_debug("user_b = " . $user_b_id); - - - $this->user_a = $this->getTargetUser($user_a_id); - - if (empty($this->user_a)) { - common_debug('gargargra'); - } - - $this->user_b = $this->getTargetUser($user_b_id); + $this->profile_a = $this->getTargetProfile($this->trimmed('user_a')); + $this->profile_b = $this->getTargetProfile($this->trimmed('user_b')); return true; } @@ -98,31 +86,46 @@ class ApiFriendshipsExistsAction extends TwitterApiAction { parent::handle($args); - if (empty($this->user_a) || empty($this->user_b)) { + if (empty($this->profile_a) || empty($this->profile_b)) { $this->clientError( - _('Two user ids or screen_names must be supplied.'), + _('Two valid IDs or screen_names must be supplied.'), 400, $this->format ); return; } - $result = $this->user_a->isSubscribed($this->user_b); + $result = Subscription::exists($this->profile_a, $this->profile_b); switch ($this->format) { case 'xml': - $this->init_document('xml'); + $this->initDocument('xml'); $this->element('friends', null, $result); - $this->end_document('xml'); + $this->endDocument('xml'); break; case 'json': - $this->init_document('json'); + $this->initDocument('json'); print json_encode($result); - $this->end_document('json'); + $this->endDocument('json'); break; default: break; } } + /** + * Return true if read only. + * + * MAY override + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ + + function isReadOnly($args) + { + return true; + } + }