From: Alexander Ebert Date: Thu, 1 Nov 2012 15:39:18 +0000 (+0100) Subject: Marking first imported style as default style X-Git-Tag: 2.0.0_Beta_1~821^2~15 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=062d21596026ebb35a806d28ecbc0f9e5d54d605;p=GitHub%2FWoltLab%2FWCF.git Marking first imported style as default style Fixes #878 --- 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);