]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigroupprofileupdate.php
Don't accept non-objects before testing with "instanceof".
[quix0rs-gnu-social.git] / actions / apigroupprofileupdate.php
index 2f4d07b7a4f4287e8abe278646cfebed92c91d28..1a489eeefb25e749cbfce5dedd94367797c2808d 100644 (file)
@@ -51,11 +51,11 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
      * @return boolean success flag
      *
      */
-    protected function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
-        $this->nickname    = common_canonical_nickname($this->trimmed('nickname'));
+        $this->nickname    = Nickname::normalize($this->trimmed('nickname'));
 
         $this->fullname    = $this->trimmed('fullname');
         $this->homepage    = $this->trimmed('homepage');
@@ -106,14 +106,9 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
 
         try {
 
-            if (!empty($this->nickname)) {
+            if (common_config('profile', 'changenick') == true && $this->group->nickname !== $this->nickname) {
                 try {
                     $this->group->nickname = Nickname::normalize($this->nickname, true);
-                } catch (NicknameTakenException $e) {
-                    // Abort only if the nickname is occupied by _another_ local group
-                    if ($e->profile->id != $this->group->id) {
-                        throw new ApiValidationException($e->getMessage());
-                    }
                 } catch (NicknameException $e) {
                     throw new ApiValidationException($e->getMessage());
                 }
@@ -170,12 +165,6 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
             $this->serverError(_('Could not create aliases.'));
         }
 
-        if (!empty($this->nickname) && ($this->nickname != $orig->nickname)) {
-            common_log(LOG_INFO, "Saving local group info.");
-            $local = Local_group::getKV('group_id', $this->group->id);
-            $local->setNickname($this->nickname);
-        }
-
         $this->group->query('COMMIT');
 
         switch($this->format) {