]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiaccountupdateprofile.php
Merge branch 'nginx-sample' into 'nightly'
[quix0rs-gnu-social.git] / actions / apiaccountupdateprofile.php
index fea6064f30b7cbecf508a048424797049c0d879c..8767dabf8528a6ef23c597bb7b4a8de47903ba8a 100644 (file)
@@ -52,7 +52,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
      *
      * @return boolean success flag
      */
-    protected function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -92,27 +92,17 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
         if (empty($profile)) {
             // TRANS: Error message displayed when referring to a user without a profile.
             $this->clientError(_('User has no profile.'));
-            return;
         }
 
         $original = clone($profile);
 
-        if (!empty($this->name)) {
-            $profile->fullname = $this->name;
-        }
-
-        if (!empty($this->url)) {
-            $profile->homepage = $this->url;
-        }
-
-        if (!empty($this->description)) {
-            $profile->bio = $this->description;
-        }
+        $profile->fullname = $this->name;
+        $profile->homepage = $this->url;
+        $profile->bio = $this->description;
+        $profile->location = $this->location;
 
         if (!empty($this->location)) {
-            $profile->location = $this->location;
-
-            $loc = Location::fromName($location);
+            $loc = Location::fromName($this->location);
 
             if (!empty($loc)) {
                 $profile->lat         = $loc->lat;
@@ -120,6 +110,12 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
                 $profile->location_id = $loc->location_id;
                 $profile->location_ns = $loc->location_ns;
             }
+        } else {
+            // location is empty so reset the extrapolated information too
+            $profile->lat = '';
+            $profile->lon = '';
+            $profile->location_id = '';
+            $profile->location_ns = '';
         }
 
         $result = $profile->update($original);
@@ -128,11 +124,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') {