Removed obsolete code
authorMarcel Werk <burntime@woltlab.com>
Fri, 12 Apr 2013 17:23:50 +0000 (19:23 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 12 Apr 2013 17:23:50 +0000 (19:23 +0200)
wcfsetup/install/files/lib/data/user/option/category/UserOptionCategory.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php
wcfsetup/setup/db/install.sql

index c11e8ac3eb344405215763a020bfcf063bbcf83b..a43151f0009d96ce5aed5237bb0705fe1b534308 100644 (file)
@@ -51,21 +51,19 @@ class UserOptionCategory extends DatabaseObject {
        }
        
        /**
-        * Returns an instance of UserOptionCategory by name and package id.
+        * Returns an instance of UserOptionCategory by name.
         * 
         * @param       string          $categoryName
-        * @param       integer         $packageID
         * @return      wcf\data\user\option\category\UserOptionCategory
         */
-       public static function getCategoryByName($categoryName, $packageID) {
+       public static function getCategoryByName($categoryName) {
                $sql = "SELECT  *
                        FROM    wcf".WCF_N."_user_option_category
-                       WHERE   categoryName = ?
-                               AND packageID = ?";
+                       WHERE   categoryName = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($categoryName, $packageID));
+               $statement->execute(array($categoryName));
                $row = $statement->fetchArray();
-               if (!$row) $row = array();
+               if ($row === falsch) return null;
                
                return new UserOptionCategory(null, $row);
        }
index 6839a702680b7946526e8a9242e8136724506c41..e9e42535348404f390230b70d4a5a81edad5be7a 100644 (file)
@@ -201,17 +201,19 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag
         */
        protected function saveCategory($category) {
                // search existing category
-               $sql = "SELECT  categoryID
+               $sql = "SELECT  categoryID, packageID
                        FROM    wcf".WCF_N."_".$this->tableName."_category
-                       WHERE   categoryName = ?
-                               AND packageID = ?";
+                       WHERE   categoryName = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array(
-                       $category['categoryName'],
-                       $this->installation->getPackageID()
+                       $category['categoryName']
                ));
                $row = $statement->fetchArray();
                if (empty($row['categoryID'])) {
+                       if ($row['categoryID'] != $this->installation->getPackageID()) {
+                               throw new SystemException("Cannot override existing category '".$category['categoryName']."'");
+                       }
+                       
                        // insert new category
                        $sql = "INSERT INTO     wcf".WCF_N."_".$this->tableName."_category
                                                (packageID, categoryName, parentCategoryName, permissions,
index fc92fb15e0194dafb07fc066da696f5f481f9cef..75deba0ef4658560214171616534db4a501cd81f 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\user\option\category\UserOptionCategory;
 use wcf\data\user\option\category\UserOptionCategoryEditor;
 use wcf\data\user\option\UserOption;
 use wcf\data\user\option\UserOptionEditor;
+use wcf\system\exception\SystemException;
 use wcf\system\WCF;
 
 /**
@@ -41,8 +42,12 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
                // append show order if explicitly stated
                if ($category['showOrder'] !== null) $data['showOrder'] = $category['showOrder'];
                
-               $userOptionCategory = UserOptionCategory::getCategoryByName($category['categoryName'], $this->installation->getPackageID());
-               if ($userOptionCategory->categoryID) {
+               $userOptionCategory = UserOptionCategory::getCategoryByName($category['categoryName']);
+               if ($userOptionCategory !== null) {
+                       if ($userOptionCategory->packageID != $this->installation->getPackageID()) {
+                               throw new SystemException("Cannot override existing category '".$category['categoryName']."'");
+                       } 
+                       
                        $categoryEditor = new UserOptionCategoryEditor($userOptionCategory);
                        $categoryEditor->update($data);
                }
index 1badc9cd8bf2ec1b44eece932b3bbe2b8a47e0ca..4017fafa7cf7063cfe5258eb5934a4805dda0cc4 100644 (file)
@@ -313,7 +313,7 @@ CREATE TABLE wcf1_option_category (
        showOrder INT(10) NOT NULL DEFAULT 0,
        permissions TEXT,
        options TEXT,
-       UNIQUE KEY categoryName (categoryName, packageID)
+       UNIQUE KEY categoryName (categoryName)
 );
 
 DROP TABLE IF EXISTS wcf1_package;
@@ -670,7 +670,7 @@ CREATE TABLE wcf1_user_group_option_category (
        showOrder INT(10) NOT NULL DEFAULT 0,
        permissions TEXT,
        options TEXT,
-       UNIQUE KEY categoryName (categoryName, packageID)
+       UNIQUE KEY categoryName (categoryName)
 );
 
 DROP TABLE IF EXISTS wcf1_user_group_option_value;
@@ -716,7 +716,7 @@ CREATE TABLE wcf1_user_option_category (
        showOrder INT(10) NOT NULL DEFAULT 0,
        permissions TEXT,
        options TEXT,
-       UNIQUE KEY categoryName (categoryName, packageID)
+       UNIQUE KEY categoryName (categoryName)
 );
 
 DROP TABLE IF EXISTS wcf1_user_option_value;