From: Matthias Schmidt Date: Fri, 26 Aug 2016 07:53:35 +0000 (+0200) Subject: Use enableoptions for captcha selection X-Git-Tag: 3.0.0_Beta_1~494 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1170aad7c8f60b91902ba23ccf9b9562636da763;p=GitHub%2FWoltLab%2FWCF.git Use enableoptions for captcha selection --- diff --git a/com.woltlab.wcf/option.xml b/com.woltlab.wcf/option.xml index 3536ae5ebf..e9491cce1b 100644 --- a/com.woltlab.wcf/option.xml +++ b/com.woltlab.wcf/option.xml @@ -672,30 +672,27 @@ private:wcf.acp.option.exception_privacy.private captchaSelect com.woltlab.wcf.recaptcha 1 + :!register_use_captcha,!lost_password_use_captcha,!profile_mail_use_captcha,!search_use_captcha diff --git a/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php b/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php index 6b9b1973f3..059765bf98 100644 --- a/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php @@ -27,13 +27,52 @@ class CaptchaSelectOptionType extends AbstractOptionType { ); } + $options = $this->parseEnableOptions($option); + return WCF::getTPL()->fetch('selectOptionType', 'wcf', [ + 'disableOptions' => $options['disableOptions'], + 'enableOptions' => $options['enableOptions'], 'selectOptions' => $selectOptions, 'option' => $option, 'value' => $value ]); } + /** + * Prepares JSON-encoded values for disabling or enabling dependent options. + * + * @param Option $option + * @return array + * @see SelectOptionType::parseEnableOptions() + */ + protected function parseEnableOptions(Option $option) { + $disableOptions = $enableOptions = ''; + + if (!empty($option->enableOptions)) { + $options = $option->parseMultipleEnableOptions(); + + foreach ($options as $key => $optionData) { + $tmp = explode(',', $optionData); + + foreach ($tmp as $item) { + if ($item{0} == '!') { + if (!empty($disableOptions)) $disableOptions .= ','; + $disableOptions .= "{ value: '".$key."', option: '".mb_substr($item, 1)."' }"; + } + else { + if (!empty($enableOptions)) $enableOptions .= ','; + $enableOptions .= "{ value: '".$key."', option: '".$item."' }"; + } + } + } + } + + return [ + 'disableOptions' => $disableOptions, + 'enableOptions' => $enableOptions + ]; + } + /** * @inheritDoc */