<optiontype>captchaSelect</optiontype>
<defaultvalue>com.woltlab.wcf.recaptcha</defaultvalue>
<allowemptyvalue>1</allowemptyvalue>
+ <enableoptions>:!register_use_captcha,!lost_password_use_captcha,!profile_mail_use_captcha,!search_use_captcha</enableoptions>
</option>
<option name="register_use_captcha">
<categoryname>security.antispam.captcha</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
- <options>captcha_type</options>
</option>
<option name="lost_password_use_captcha">
<categoryname>security.antispam.captcha</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
- <options>captcha_type</options>
</option>
<option name="profile_mail_use_captcha">
<categoryname>security.antispam.captcha</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
- <options>captcha_type</options>
</option>
<option name="search_use_captcha">
<categoryname>security.antispam.captcha</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>0</defaultvalue>
- <options>captcha_type</options>
</option>
<!-- /security.antispam.captcha -->
);
}
+ $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
*/