]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiaccountupdateprofile.php
Added missing isPrivateScope().
[quix0rs-gnu-social.git] / actions / apiaccountupdateprofile.php
index d0b9abe9b79fffcf3b8d5dbb6e56574e094d4d69..a9842ec5d8f33d80dba29e353e4597be3150623c 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * API analog to the profile settings page
  * Only the parameters specified will be updated.
@@ -45,6 +43,8 @@ require_once INSTALLDIR . '/lib/apiauth.php';
  */
 class ApiAccountUpdateProfileAction extends ApiAuthAction
 {
+    protected $needPost = true;
+
     /**
      * Take arguments for running
      *
@@ -52,7 +52,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
      *
      * @return boolean success flag
      */
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -71,45 +71,27 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
      *
      * See which request params have been set, and update the profile
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
-
-        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-            $this->clientError(
-                // TRANS: Client error. POST is a HTTP command. It should not be translated.
-                _('This method requires a POST.'),
-                400, $this->format
-            );
-            return;
-        }
+        parent::handle();
 
         if (!in_array($this->format, array('xml', 'json'))) {
-            $this->clientError(
-                // TRANS: Client error displayed when trying to handle an unknown API method.
-                _('API method not found.'),
-                404,
-                $this->format
-            );
-            return;
+            // TRANS: Client error displayed when coming across a non-supported API method.
+            $this->clientError(_('API method not found.'), 404);
         }
 
         if (empty($this->user)) {
             // TRANS: Client error displayed if a user could not be found.
-            $this->clientError(_('No such user.'), 404, $this->format);
-            return;
+            $this->clientError(_('No such user.'), 404);
         }
 
         $profile = $this->user->getProfile();
 
         if (empty($profile)) {
-            // TRANS: Client error displayed if a user profile could not be found.
+            // TRANS: Error message displayed when referring to a user without a profile.
             $this->clientError(_('User has no profile.'));
-            return;
         }
 
         $original = clone($profile);
@@ -129,7 +111,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
         if (!empty($this->location)) {
             $profile->location = $this->location;
 
-            $loc = Location::fromName($location);
+            $loc = Location::fromName($this->location);
 
             if (!empty($loc)) {
                 $profile->lat         = $loc->lat;
@@ -145,11 +127,8 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
             common_log_db_error($profile, 'UPDATE', __FILE__);
             // TRANS: Server error displayed if a user profile could not be saved.
             $this->serverError(_('Could not save profile.'));
-            return;
         }
 
-        common_broadcast_profile($profile);
-
         $twitter_user = $this->twitterUserArray($profile, true);
 
         if ($this->format == 'xml') {