]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newapplication.php
OStatus/FeedSub: tweaked PuSH feed garbage collection so other plugins can declare...
[quix0rs-gnu-social.git] / actions / newapplication.php
index c499fe7c76ed995bcb9896448dc410f3738cccfb..0f819b3499881795e3ce597fd1559846875f7f15 100644 (file)
@@ -158,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;
@@ -273,5 +276,22 @@ class NewApplicationAction extends OwnerDesignAction
 
     }
 
+    /**
+     * 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);
+    }
+
 }