From 062d21596026ebb35a806d28ecbc0f9e5d54d605 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 1 Nov 2012 16:39:18 +0100 Subject: [PATCH] Marking first imported style as default style Fixes #878 --- .../files/lib/data/style/StyleEditor.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index 1365c890c4..2cb6178c4e 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -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); -- 2.20.1