Adds missing check if application abbreviations are unique
authorMatthias Schmidt <gravatronics@live.com>
Tue, 7 May 2013 06:37:10 +0000 (08:37 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 7 May 2013 06:37:10 +0000 (08:37 +0200)
Closes #1225

wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php
wcfsetup/install/files/lib/system/package/PackageArchive.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index d1f5aa6f85616095f76353fd06abd25d6d90a228..19b3a7e6b30e6b13922b27a7e7b5cbbbd014887c 100755 (executable)
@@ -195,6 +195,9 @@ class PackageStartInstallForm extends AbstractForm {
                        else if ($this->archive->isAlreadyInstalled()) {
                                throw new UserInputException($type, 'uniqueAlreadyInstalled');
                        }
+                       else if ($this->archive->getPackageInfo('isApplication') && $this->archive->hasUniqueAbbreviation()) {
+                               throw new UserInputException($type, 'noUniqueAbbrevation');
+                       }
                }
        }
        
index 4355b2b625c3947e41fb6e66b1f7008d1ce36c3e..c1ea46d3d5b67d6afd7d505cc20f53d66560384b 100644 (file)
@@ -235,7 +235,7 @@ class PackageArchive {
                        foreach ($attributes as $attribute) {
                                $data[$attribute->name] = $attribute->value;
                        }
-                                       
+                       
                        $this->requirements[$element->nodeValue] = $data;
                }
                
@@ -252,7 +252,7 @@ class PackageArchive {
                        foreach ($attributes as $attribute) {
                                $data[$attribute->name] = $attribute->value;
                        }
-                                       
+                       
                        $this->optionals[] = $data;
                }
                
@@ -437,6 +437,29 @@ class PackageArchive {
                return ($row['count'] > 0) ? true : false;
        }
        
+       /**
+        * Returns true if the package is an application and has an unique abbrevation.
+        * 
+        * @return      boolean
+        */
+       public function hasUniqueAbbreviation() {
+               if (!$this->packageInfo['isApplication']) {
+                       return true;
+               }
+               
+               $sql = "SELECT  COUNT(*)
+                       FROM    wcf".WCF_N."_package
+                       WHERE   isApplication = ?
+                               AND package LIKE ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(
+                       1,
+                       '%'.Package::getAbbreviation($this->packageInfo['name'])
+               ));
+               
+               return $statement->fetchColumn();
+       }
+       
        /**
         * Returns information about the author of this package archive.
         * 
index 3fdb0fe5d5700965cbeecc134ced5f4649f33267..8a13f13dcb439db53e106c5392deb373f00f0e6e 100644 (file)
                <item name="wcf.acp.option.external_link_target_blank"><![CDATA[Externe Links in neuem Fenster öffnen]]></item>
                <item name="wcf.acp.option.external_link_target_blank.description"><![CDATA[Setzt das Attribut „target="_blank"“ auf externe Links und weist den Browser dadurch an, einen aufgerufenen Link in einem neuen Browser-Fenster zu öffnen.]]></item>
        </category>
-
+       
        <category name="wcf.acp.package">
                <item name="wcf.acp.package.application.installed"><![CDATA[Installierte Anwendungen]]></item>
                <item name="wcf.acp.package.application.title"><![CDATA[Anwendungen]]></item>
                <item name="wcf.acp.package.dependencies.required.description"><![CDATA[Pakete, die zwingend für den Betrieb dieses Paketes benötigt werden]]></item>
                <item name="wcf.acp.package.dependencies.title"><![CDATA[Abhängigkeiten]]></item>
                <item name="wcf.acp.package.description"><![CDATA[Beschreibung]]></item>
+               <item name="wcf.acp.package.error.noUniqueAbbrevation"><![CDATA[Es ist bereits eine Anwendung installiert, die die gleiche Abkürzung besitzt.]]></item>
                <item name="wcf.acp.package.error.noValidPackage"><![CDATA[Das angegebene Archiv ist kein gültiges Paket.]]></item>
                <item name="wcf.acp.package.error.sql.createTable"><![CDATA[Existierende Tabellen überschreiben]]></item>
                <item name="wcf.acp.package.error.sql.createTable.description"><![CDATA[Die oben genannten Tabellen existieren bereits und werden beim Fortfahren der Installation überschrieben. Alle Daten dieser Tabellen gehen unwiderruflich verloren.]]></item>
index 159e8871b8f486cd5cf35eb07e1292f2ac490ebf..c085a80435812f07d9b2a92e9ca7bda524dfabd3 100644 (file)
                <item name="wcf.acp.option.external_link_target_blank"><![CDATA[Open external links in a new window]]></item>
                <item name="wcf.acp.option.external_link_target_blank.description"><![CDATA[Appends the attribute “target="_blank"” to external links, causing the user’s browser to open the link in a new window.]]></item>
        </category>
-
+       
        <category name="wcf.acp.package">
                <item name="wcf.acp.package.application.installed"><![CDATA[Installed Applications]]></item>
                <item name="wcf.acp.package.application.title"><![CDATA[Applications]]></item>
                <item name="wcf.acp.package.dependencies.required.description"><![CDATA[Packages required by this package]]></item>
                <item name="wcf.acp.package.dependencies.title"><![CDATA[Dependencies]]></item>
                <item name="wcf.acp.package.description"><![CDATA[Description]]></item>
+               <item name="wcf.acp.package.error.noUniqueAbbrevation"><![CDATA[There is already an application installed which has the same abbrevation.]]></item>
                <item name="wcf.acp.package.error.noValidPackage"><![CDATA[The uploaded archive is invalid.]]></item>
                <item name="wcf.acp.package.error.sql.createTable"><![CDATA[Overwrite Existing Tables]]></item>
                <item name="wcf.acp.package.error.sql.createTable.description"><![CDATA[The tables above already exist and will be replaced during the installation. Any contained data will be lost.]]></item>