From: Alexander Ebert Date: Tue, 21 Aug 2012 18:00:57 +0000 (+0200) Subject: Fixed a few bugs if editing a single group option X-Git-Tag: 2.0.0_Beta_1~880^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=139fee8b599c574a6c16a806e19a14844e6b4246;p=GitHub%2FWoltLab%2FWCF.git Fixed a few bugs if editing a single group option --- diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 3256d72c53..ddf4d01011 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -703,14 +703,22 @@ WCF.ACP.Options.Group = Class.extend({ // collect default value if (this._canEditEveryone) { var $container = $('#defaultValueContainer > dl'); - $values[$container.data('groupID')] = $container.find('textarea, input').val(); + + var $value = this._getValue($container); + if ($value !== null) { + $values[$container.data('groupID')] = $value; + } } // collect values from other groups + var self = this; $('#otherValueContainer > dl').each(function(index, container) { var $container = $(container); - $values[$container.data('groupID')] = $container.find('textarea, input').val(); + var $value = self._getValue($container); + if ($value !== null) { + $values[$container.data('groupID')] = $value; + } }); var $form = $('#defaultValueContainer').parent('form'); @@ -723,6 +731,35 @@ WCF.ACP.Options.Group = Class.extend({ $('#submitButton').attr('disable', 'disable'); $form.submit(); + }, + + /** + * Returns the value of an input or textarea. + * + * @param jQuery container + * @return string + */ + _getValue: function(container) { + var $textarea = container.find('textarea'); + if ($textarea.length) { + return $textarea.val(); + } + else { + var $input = container.find('input'); + if (!$input.length) { + return null; + } + + if ($input.attr('type') == 'checkbox') { + if ($input.is(':checked')) { + return $input.val(); + } + + return null; + } + + return $input.val(); + } } }); diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php index 86afe0035a..890cd96d65 100644 --- a/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php @@ -171,19 +171,26 @@ class UserGroupOptionForm extends ACPForm { $this->groupEveryone->groupID )); $row = $statement->fetchArray(); - $defaultValue = $row['optionValue']; + $this->defaultValue = $row['optionValue']; } else { if (!isset($this->values[$this->groupEveryone->groupID])) { throw new IllegalLinkException(); } - $defaultValue = $this->values[$this->groupEveryone->groupID]; + $this->defaultValue = $this->values[$this->groupEveryone->groupID]; } foreach ($this->values as $groupID => $optionValue) { - if (!isset($this->groups[$groupID]) || (!$this->canEditEveryone && $groupID == $this->groupEveryone->groupID)) { - throw new PermissionDeniedException(); + if (!isset($this->groups[$groupID])) { + if ($groupID == $this->groupEveryone->groupID) { + if (!$this->canEditEveryone) { + throw new PermissionDeniedException(); + } + } + else { + throw new PermissionDeniedException(); + } } try { @@ -195,7 +202,7 @@ class UserGroupOptionForm extends ACPForm { // check if not editing default value if ($groupID != $this->groupEveryone->groupID) { - $newValue = $this->optionType->merge($defaultValue, $optionValue); + $newValue = $this->optionType->merge($this->defaultValue, $optionValue); if ($newValue === null) { unset($this->values[$groupID]); } diff --git a/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionAction.class.php b/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionAction.class.php index 00f729de0c..2a91145d72 100644 --- a/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionAction.class.php +++ b/wcfsetup/install/files/lib/data/user/group/option/UserGroupOptionAction.class.php @@ -1,6 +1,7 @@ objects); // remove old values @@ -49,5 +50,8 @@ class UserGroupOptionAction extends AbstractDatabaseObjectAction { } WCF::getDB()->commitTransaction(); } + + // clear cache + CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.groups-*.php'); } }