Fix unique project name validation when editing project
authorMatthias Schmidt <gravatronics@live.com>
Sun, 23 Jul 2017 08:22:41 +0000 (10:22 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 23 Jul 2017 08:22:41 +0000 (10:22 +0200)
wcfsetup/install/files/lib/acp/form/DevtoolsProjectAddForm.class.php
wcfsetup/install/files/lib/acp/form/DevtoolsProjectEditForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index ae3f8f1f77dd1624bd2295c7022d64fc6851e166..b42e41ba6b6978e46fc613a19846392097d57f89 100644 (file)
@@ -66,15 +66,7 @@ class DevtoolsProjectAddForm extends AbstractForm {
                        throw new UserInputException('name');
                }
                else {
-                       $sql = "SELECT  COUNT(*)
-                               FROM    wcf".WCF_N."_devtools_project
-                               WHERE   name = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute([$this->name]);
-                       
-                       if ($statement->fetchColumn()) {
-                               throw new UserInputException('name', 'notUnique');
-                       }
+                       $this->validateUniqueName();
                }
                
                // validate path
@@ -94,6 +86,21 @@ class DevtoolsProjectAddForm extends AbstractForm {
                }
        }
        
+       /**
+        * Checks that the project name is not used by another project.
+        */
+       protected function validateUniqueName() {
+               $sql = "SELECT  COUNT(*)
+                       FROM    wcf".WCF_N."_devtools_project
+                       WHERE   name = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute([$this->name]);
+               
+               if ($statement->fetchColumn()) {
+                       throw new UserInputException('name', 'notUnique');
+               }
+       }
+       
        /**
         * Checks that the project path is not used by another project.
         */
index 187015f2e6031225dcad1039d3af12204d012473..8d6a685df381335be6120628cc2378e37cda8b9e 100644 (file)
@@ -47,6 +47,23 @@ class DevtoolsProjectEditForm extends DevtoolsProjectAddForm {
                }
        }
        
+       /** @noinspection PhpMissingParentCallCommonInspection */
+       /**
+        * @inheritDoc
+        */
+       protected function validateUniqueName() {
+               $sql = "SELECT  COUNT(*)
+                       FROM    wcf".WCF_N."_devtools_project
+                       WHERE   name = ?
+                               AND projectID <> ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute([$this->name, $this->objectID]);
+               
+               if ($statement->fetchColumn()) {
+                       throw new UserInputException('name', 'notUnique');
+               }
+       }
+       
        /** @noinspection PhpMissingParentCallCommonInspection */
        /**
         * @inheritDoc
index 8090c77695a7ecafe2e07e7781b5a4e09f0089c7..1c4afae0fa692567c456231adf16c9f2ad575771 100644 (file)
                <item name="wcf.acp.devtools.project.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} das Projekt <span class="confirmationObject">{$object->name}</span> wirklich löschen?]]></item>
                <item name="wcf.acp.devtools.project.list"><![CDATA[Projekte]]></item>
                <item name="wcf.acp.devtools.project.name"><![CDATA[Name]]></item>
+               <item name="wcf.acp.devtools.project.name.error.notUnique"><![CDATA[Der Name wird bereits von einem anderen Projekt verwendet.]]></item>
                <item name="wcf.acp.devtools.project.path"><![CDATA[Pfad]]></item>
                <item name="wcf.acp.devtools.project.path.error.excludedVersion"><![CDATA[Die aktuelle Core-Version wird in der <kbd>package.xml</kbd> explizit ausgeschlossen.]]></item>
                <item name="wcf.acp.devtools.project.path.error.missingExclude"><![CDATA[In der <kbd>package.xml</kbd> fehlt die <kbd>&gt;excludedpackage&lt;</kbd>-Anweisung für <kbd>com.woltlab.wcf</kbd>.]]></item>
index 0d728b5aef4e37b305f88ea48690ecb62fed9d18..1cc943a6f9fdac5829bbc966f63257400ba15f97 100644 (file)
                <item name="wcf.acp.devtools.project.delete.confirmMessage"><![CDATA[Do you really want to delete the project <span class="confirmationObject">{$object->name}</span>?]]></item>
                <item name="wcf.acp.devtools.project.list"><![CDATA[Projects]]></item>
                <item name="wcf.acp.devtools.project.name"><![CDATA[Name]]></item>
+               <item name="wcf.acp.devtools.project.name.error.notUnique"><![CDATA[The name is already used by another project.]]></item>
                <item name="wcf.acp.devtools.project.path"><![CDATA[Path]]></item>
                <item name="wcf.acp.devtools.project.path.error.excludedVersion"><![CDATA[The current Core version is explicitly listed as excluded in the <kbd>package.xml</kbd>.]]></item>
                <item name="wcf.acp.devtools.project.path.error.missingExclude"><![CDATA[The <kbd>package.xml</kbd> is missing the <kbd>&gt;excludedpackage&lt;</kbd> instruction for <kbd>com.woltlab.wcf</kbd>.]]></item>