summaryrefslogtreecommitdiff
path: root/actions/editapplication.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-03 12:32:48 -0500
committerEvan Prodromou <evan@status.net>2010-02-03 12:32:48 -0500
commit900cb8dd91b954d4e720b0c8afb2884419f43cd7 (patch)
treec2308c56f097d735273e965374240dfc20ded284 /actions/editapplication.php
parentaa4848d62d9bcc8166f18f4a18e5a3d2a6a51537 (diff)
parentefa930ab000e1e022f0754d9f421e8859024142c (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'actions/editapplication.php')
-rw-r--r--actions/editapplication.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/actions/editapplication.php b/actions/editapplication.php
index 9cc3e3cea..ca5dba1e4 100644
--- a/actions/editapplication.php
+++ b/actions/editapplication.php
@@ -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 (!$newapp) {
+ return false;
+ } else {
+ return $newapp->id != $this->app->id;
+ }
+ }
+
}