X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Feditapplication.php;h=64cf0a5745d134fcceeb7b214844b45dc86111ec;hb=83c2e0b379a8a6a81c211ed5c4d837e047f919f7;hp=3b120259a8d2245a4e49f45561e950ad89d35df2;hpb=01dc77c2fd783f8b7ff796ca06013804971c8f5e;p=quix0rs-gnu-social.git diff --git a/actions/editapplication.php b/actions/editapplication.php index 3b120259a8..64cf0a5745 100644 --- a/actions/editapplication.php +++ b/actions/editapplication.php @@ -51,7 +51,7 @@ class EditApplicationAction extends OwnerDesignAction function title() { - return _('Edit application'); + return _('Edit Application'); } /** @@ -179,6 +179,9 @@ class EditApplicationAction extends OwnerDesignAction } elseif (mb_strlen($name) > 255) { $this->showForm(_('Name is too long (max 255 chars).')); return; + } else if ($this->nameExists($name)) { + $this->showForm(_('Name already in use. Try another one.')); + return; } elseif (empty($description)) { $this->showForm(_('Description is required.')); return; @@ -260,5 +263,26 @@ class EditApplicationAction extends OwnerDesignAction common_redirect(common_local_url('oauthappssettings'), 303); } + /** + * Does the app name already exist? + * + * Checks the DB to see someone has already registered an app + * with the same name. + * + * @param string $name app name to check + * + * @return boolean true if the name already exists + */ + + function nameExists($name) + { + $newapp = Oauth_application::staticGet('name', $name); + if (empty($newapp)) { + return false; + } else { + return $newapp->id != $this->app->id; + } + } + }