Marking first imported style as default style
authorAlexander Ebert <ebert@woltlab.com>
Thu, 1 Nov 2012 15:39:18 +0000 (16:39 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 1 Nov 2012 15:39:18 +0000 (16:39 +0100)
Fixes #878

wcfsetup/install/files/lib/data/style/StyleEditor.class.php

index 1365c890c4c581044494fdfef4a6c438f712edfd..2cb6178c4e46df83c0a21b3ee7c3765b07ebe7f7 100644 (file)
@@ -801,6 +801,19 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                if (!isset($parameters['packageID'])) $parameters['packageID'] = PACKAGE_ID;
                if (!isset($parameters['styleDate'])) $parameters['styleDate'] = gmdate('Y-m-d', TIME_NOW);
                
+               // check if no default style is defined
+               $sql = "SELECT  styleID
+                       FROM    wcf".WCF_N."_style
+                       WHERE   isDefault = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(1));
+               $row = $statement->fetchArray();
+               
+               // no default style exists
+               if ($row === false) {
+                       $parameters['isDefault'] = 1;
+               }
+               
                // save style
                $style = parent::create($parameters);           
                $styleEditor = new StyleEditor($style);