From: Marcel Werk Date: Mon, 5 Nov 2012 20:37:23 +0000 (+0100) Subject: Added application prefix to constant name X-Git-Tag: 2.0.0_Beta_1~809^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=85ccfeb4117efb8ff0ea697f6cedd29ec0be1bb6;p=GitHub%2FWoltLab%2FWCF.git Added application prefix to constant name --- diff --git a/wcfsetup/install/files/lib/data/option/Option.class.php b/wcfsetup/install/files/lib/data/option/Option.class.php index 367b46a1b8..6b0eae1ac6 100644 --- a/wcfsetup/install/files/lib/data/option/Option.class.php +++ b/wcfsetup/install/files/lib/data/option/Option.class.php @@ -1,6 +1,7 @@ */ public static function getOptions($packageID = PACKAGE_ID) { - $sql = "SELECT optionName, optionID - FROM wcf".WCF_N."_option option_table - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = option_table.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; + $sql = "SELECT option_table.*, + package.package, package.isApplication, + parent_package.package AS parentPackage, + parent_package.isApplication AS parentPackageIsApplication + FROM wcf".WCF_N."_package_dependency package_dependency, + wcf".WCF_N."_option option_table + LEFT JOIN wcf".WCF_N."_package package + ON (package.packageID = option_table.packageID) + LEFT JOIN wcf".WCF_N."_package parent_package + ON (parent_package.packageID = package.parentPackageID) + WHERE package_dependency.dependency = option_table.packageID + AND package_dependency.packageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($packageID)); - - $optionIDs = array(); while ($row = $statement->fetchArray()) { - $optionIDs[$row['optionName']] = $row['optionID']; - } - - $options = array(); - if (!empty($optionIDs)) { - // get needed options - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("optionID IN (?)", array($optionIDs)); - - $sql = "SELECT * - FROM wcf".WCF_N."_option - ".$conditions." - ORDER BY optionName"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - $options[StringUtil::toUpperCase($row['optionName'])] = new Option(null, $row); - } + $option = new Option(null, $row); + $options[$option->getConstantName()] = $option; } return $options; @@ -184,4 +173,25 @@ class Option extends DatabaseObject { public static function getDatabaseTableAlias() { return 'option_table'; } + + /** + * Returns the constant name. + * + * @return string + */ + public function getConstantName() { + $prefix = ''; + if ($this->parentPackage) { + if ($this->parentPackageIsApplication && $this->parentPackage != 'com.woltlab.wcf') { + $prefix = Package::getAbbreviation($this->parentPackage) . '_'; + } + } + else if ($this->package) { + if ($this->isApplication && $this->package != 'com.woltlab.wcf') { + $prefix = Package::getAbbreviation($this->package) . '_'; + } + } + + return strtoupper($prefix.$this->optionName); + } }