From 549376a43d9c64e68bad808467e03d9be953f2bf Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 7 May 2013 08:37:10 +0200 Subject: [PATCH] Adds missing check if application abbreviations are unique Closes #1225 --- .../form/PackageStartInstallForm.class.php | 3 +++ .../system/package/PackageArchive.class.php | 27 +++++++++++++++++-- wcfsetup/install/lang/de.xml | 3 ++- wcfsetup/install/lang/en.xml | 3 ++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index d1f5aa6f85..19b3a7e6b3 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -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'); + } } } diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 4355b2b625..c1ea46d3d5 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -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. * diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 3fdb0fe5d5..8a13f13dcb 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -413,7 +413,7 @@ - + @@ -428,6 +428,7 @@ + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 159e8871b8..c085a80435 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -413,7 +413,7 @@ - + @@ -428,6 +428,7 @@ + -- 2.20.1