]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apifriendshipsexists.php
Added missing isPrivateScope().
[quix0rs-gnu-social.git] / actions / apifriendshipsexists.php
index ca62b5f51420b81009d766bdebb30e6fd17d359d..21d82f96fd13f20fc41cf77bf247ccc12709d355 100644 (file)
  * @author    Dan Moore <dan@moore.cx>
  * @author    Evan Prodromou <evan@status.net>
  * @author    Zach Copley <zach@status.net>
- * @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/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-require_once INSTALLDIR . '/lib/apiprivateauth.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Tests for the existence of friendship between two users. Will return true if
@@ -47,11 +43,10 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php';
  * @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 ApiPrivateAuthAction
 {
-    var $user_a = null;
-    var $user_b = null;
+    var $profile_a = null;
+    var $profile_b = null;
 
     /**
      * Take arguments for running
@@ -59,18 +54,13 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
      * @param array $args $_REQUEST args
      *
      * @return boolean success flag
-     *
      */
-
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
-        $user_a_id = $this->trimmed('user_a');
-        $user_b_id = $this->trimmed('user_b');
-
-        $this->user_a = $this->getTargetUser($user_a_id);
-        $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;
     }
@@ -80,25 +70,21 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
      *
      * Check the format and show the user info
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
+        parent::handle();
 
-        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.'),
-                400,
-                $this->format
+                // TRANS: Client error displayed when supplying invalid parameters to an API call checking if a friendship exists.
+                _('Two valid IDs or nick names must be supplied.'),
+                400
             );
-            return;
         }
 
-        $result = $this->user_a->isSubscribed($this->user_b);
+        $result = Subscription::exists($this->profile_a, $this->profile_b);
 
         switch ($this->format) {
         case 'xml':
@@ -125,10 +111,8 @@ class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
      *
      * @return boolean is read only action?
      */
-
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         return true;
     }
-
 }