X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fnewapplication.php;h=0f819b3499881795e3ce597fd1559846875f7f15;hb=88ae7f53bb4470a899678d231cecb8cb963b2075;hp=3d42b657befc0601333900816d44de277e9aed7f;hpb=adfca0180847571b9474db76a0c4daa407acf22b;p=quix0rs-gnu-social.git diff --git a/actions/newapplication.php b/actions/newapplication.php index 3d42b657be..0f819b3499 100644 --- a/actions/newapplication.php +++ b/actions/newapplication.php @@ -114,8 +114,7 @@ class NewApplicationAction extends OwnerDesignAction $cur = common_current_user(); if ($this->arg('cancel')) { - common_redirect(common_local_url('apps', - array('nickname' => $cur->nickname)), 303); + common_redirect(common_local_url('oauthappssettings'), 303); } elseif ($this->arg('save')) { $this->trySave(); } else { @@ -147,7 +146,7 @@ class NewApplicationAction extends OwnerDesignAction function trySave() { - $name = $this->trimmed('name'); + $name = $this->trimmed('name'); $description = $this->trimmed('description'); $source_url = $this->trimmed('source_url'); $organization = $this->trimmed('organization'); @@ -159,6 +158,9 @@ class NewApplicationAction extends OwnerDesignAction if (empty($name)) { $this->showForm(_('Name is required.')); return; + } else if ($this->nameExists($name)) { + $this->showForm(_('Name already in use. Try another one.')); + return; } elseif (mb_strlen($name) > 255) { $this->showForm(_('Name is too long (max 255 chars).')); return; @@ -266,13 +268,29 @@ class NewApplicationAction extends OwnerDesignAction $app->query('ROLLBACK'); } - $this->app->uploadLogo(); + $app->uploadLogo(); $app->query('COMMIT'); - common_redirect(common_local_url('apps', - array('nickname' => $cur->nickname)), 303); + 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) + { + $app = Oauth_application::staticGet('name', $name); + return !empty($app); } }