From 38983e0f5a43f0ce11f66bb7df38d84a9c045221 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 13 Aug 2011 08:51:22 +0200 Subject: [PATCH] Additional adjustments --- .../lib/acp/form/UserGroupAddForm.class.php | 6 +- .../UserGroupPermissionCacheBuilder.class.php | 9 +- ...OptionsPackageInstallationPlugin.class.php | 164 ------------------ ...OptionsPackageInstallationPlugin.class.php | 2 +- 4 files changed, 9 insertions(+), 172 deletions(-) delete mode 100644 wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php index d2f7d51083..6b152416ff 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php @@ -187,14 +187,14 @@ class UserGroupAddForm extends AbstractOptionListForm { */ protected function getTypeObject($type) { if (!isset($this->typeObjects[$type])) { - $className = 'wcf\system\option\group\\'.StringUtil::toUpperCase($type).'GroupOptionType'; + $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($type).'UserGroupOptionType'; // create instance if (!class_exists($className)) { throw new SystemException("unable to find class '".$className."'"); } - if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\group\IGroupOptionType')) { - throw new SystemException("'".$className."' should implement wcf\system\option\group\IGroupOptionType"); + if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\userGroup\IUserGroupOptionType')) { + throw new SystemException("'".$className."' should implement wcf\system\option\userGroup\IUserGroupOptionType"); } $this->typeObjects[$type] = new $className(); } diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php index 4d84984c94..805be58e87 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php @@ -4,6 +4,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\WCF; use wcf\util\ClassUtil; +use wcf\util\StringUtil; /** * Caches the merged group options of a group combination. @@ -99,18 +100,18 @@ class UserGroupPermissionCacheBuilder implements ICacheBuilder { * Returns an object of the requested group option type. * * @param string $type - * @return wcf\system\option\group\IGroupOptionType + * @return wcf\system\option\userGroup\IUserGroupOptionType */ protected function getTypeObject($type) { if (!isset($this->typeObjects[$type])) { - $className = 'wcf\system\option\group\\'.StringUtil::toUpperCase($type).'GroupOptionType'; + $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($type).'UserGroupOptionType'; // validate class if (!class_exists($className)) { throw new SystemException("unable to find class '".$className."'"); } - if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\group\IGroupOptionType')) { - throw new SystemException("'".$className."' should implement wcf\system\option\group\IGroupOptionType"); + if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\userGroup\IUserGroupOptionType')) { + throw new SystemException("'".$className."' should implement wcf\system\option\userGroup\IUserGroupOptionType"); } // create instance diff --git a/wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php deleted file mode 100644 index 174195da13..0000000000 --- a/wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.package.plugin - * @category Community Framework - */ -class GroupOptionsPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin { - /** - * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName - */ - public $tableName = 'user_group_option'; - - public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'admindefaultvalue', 'validationpattern', 'showorder', 'categoryname', 'selectoptions', 'enableoptions', 'permissions', 'options', 'attrs', 'cdata'); - - /** - * Deletes group-option-categories and/or group-options which where installed by the package. - */ - public function uninstall() { - // Delete value-entries using categories or options - // which will be deleted. - $sql = "DELETE FROM wcf".WCF_N."_user_group_option_value - WHERE optionID IN ( - SELECT optionID - FROM wcf".WCF_N."_user_group_option - WHERE packageID = ? - )"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->installation->getPackageID())); - - parent::uninstall(); - } - - /** - * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption() - */ - protected function saveOption($option, $categoryName, $existingOptionID = 0) { - // default values - $optionName = $optionType = $defaultValue = $adminDefaultValue = $validationPattern = $enableOptions = $permissions = $options = ''; - $showOrder = null; - - // get values - if (isset($option['name'])) $optionName = $option['name']; - if (isset($option['optiontype'])) $optionType = $option['optiontype']; - if (isset($option['defaultvalue'])) $defaultValue = $option['defaultvalue']; - if (isset($option['admindefaultvalue'])) $adminDefaultValue = $option['admindefaultvalue']; - if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern']; - if (!empty($option['showorder'])) $showOrder = intval($option['showorder']); - $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName'); - if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions']; - if (isset($option['permissions'])) $permissions = $option['permissions']; - if (isset($option['options'])) $options = $option['options']; - - // check if optionType exists - $className = 'wcf\system\option\group\\'.StringUtil::toUpperCase($type).'GroupOptionType'; - if (!class_exists($className)) { - throw new SystemException("unable to find class '".$className."'"); - } - - // collect additional tags and their values - $additionalData = array(); - foreach ($option as $tag => $value) { - if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value; - } - - // check if the otion exist already and was installed by this package - $sql = "SELECT optionID - FROM wcf".WCF_N."_user_group_option - WHERE optionName = ? - AND packageID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - $optionName, - $this->installation->getPackageID() - )); - $row = $statement->fetchArray(); - - $data = array( - 'categoryName' => $categoryName, - 'optionType' => $optionType, - 'defaultValue' => $defaultValue, - 'adminDefaultValue' => $adminDefaultValue, - 'validationPattern' => $validationPattern, - 'showOrder' => $showOrder, - 'enableOptions' => $enableOptions, - 'permissions' => $permissions, - 'options' => $options, - 'additionalData' => serialize($additionalData) - ); - - if (!empty($row['optionID'])) { - // update existing option - $optionID = $row['optionID']; - - $groupOption = new UserGroupOption(null, $row); - $groupOptionEditor = new UserGroupOptionEditor($groupOption); - $groupOptionEditor->update($data); - } - else { - // add new option - $data['packageID'] = $this->installation->getPackageID(); - $data['optionName'] = $optionName; - - $groupOptionEditor = UserGroupOptionEditor::create($data); - $optionID = $groupOptionEditor->optionID; - - // get default group ("everyone") - $sql = "SELECT groupID - FROM wcf".WCF_N."_user_group - WHERE groupType = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array(UserGroup::EVERYONE)); - $row = $statement->fetchArray(); - - // save default value - $sql = "INSERT INTO wcf".WCF_N."_user_group_option_value - (groupID, optionID, optionValue) - VALUES (?, ?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($row['groupID'], $optionID, $defaultValue)); - - if ($adminDefaultValue && $defaultValue != $adminDefaultValue) { - $sql = "SELECT groupID - FROM wcf".WCF_N."_user_group_option_value - WHERE optionID = ( - SELECT optionID - FROM wcf".WCF_N."_user_group_option - WHERE optionName = ? - ) - AND optionValue = '1'"; - $statement2 = WCF::getDB()->prepareStatement($sql); - $statement2->execute(array('admin.general.canUseAcp')); - - $acpGroups = array(); - while ($row = $statement2->fetchArray()) { - $acpGroups[] = $row['groupID']; - } - - $statement2->execute(array('admin.user.canEditGroup')); - while ($row = $statement2->fetchArray()) { - if (!in_array($row['groupID'], $acpGroups)) { - continue; - } - - $statement->execute(array( - $row['groupID'], - $optionID, - $adminDefaultValue - )); - } - } - } - } -} diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php index 16d2147334..c906ff73a2 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php @@ -62,7 +62,7 @@ class UserGroupOptionsPackageInstallationPlugin extends AbstractOptionPackageIns if (isset($option['options'])) $options = $option['options']; // check if optionType exists - $className = 'wcf\system\option\userGroup\\'.StringUtil::toUpperCase($optionType).'UserGroupOptionType'; + $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($optionType).'UserGroupOptionType'; if (!class_exists($className)) { throw new SystemException("unable to find class '".$className."'"); } -- 2.20.1