Searching certain user options can be enabled/disabled making it possible to search for "empty" user options.
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchRadioButtonOption{/lang}</label>
+<select id="{$option->optionName}" name="values[{$option->optionName}][]" multiple="multiple" size="{if $selectOptions|count > 10}10{else}{@$selectOptions|count}{/if}"{if !$searchOption} disabled="disabled"{/if}>
+ {foreach from=$selectOptions key=key item=selectOption}
+ <option value="{$key}"{if $key|in_array:$value} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
+ {/foreach}
+</select>
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('#{$option->optionName}').enable();
+ }
+ else {
+ $('#{$option->optionName}').disable();
+ }
+ });
+});
+//]]>
+</script>
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchRadioButtonOption{/lang}</label>
+{foreach from=$selectOptions key=key item=selectOption}
+ <label><input type="radio" name="values[{$option->optionName}]" value="{$key}" {if $value == $key} checked="checked"{/if} {if $disableOptions[$key]|isset || $enableOptions[$key]|isset}class="jsEnablesOptions" data-disable-options="[ {@$disableOptions[$key]}]" data-enable-options="[ {@$enableOptions[$key]}]"{/if} /> {lang}{@$selectOption}{/lang}</label>
+{/foreach}
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('input[name="values[{$option->optionName}]"]').enable();
+ }
+ else {
+ $('input[name="values[{$option->optionName}]"]').disable();
+ }
+ });
+});
+//]]>
+</script>
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchRadioButtonOption{/lang}</label>
+<select id="{$option->optionName}" name="values[{$option->optionName}]"{if !$searchOption} disabled="disabled"{/if}>
+ {if !$allowEmptyValue|empty}<option value="">{lang}wcf.global.noSelection{/lang}</option>{/if}
+ {foreach from=$selectOptions key=key item=selectOption}
+ <option value="{$key}"{if $value == $key} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
+ {/foreach}
+</select>
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('#{$option->optionName}').enable();
+ }
+ else {
+ $('#{$option->optionName}').disable();
+ }
+ });
+});
+//]]>
+</script>
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchTextOption{/lang}</label>
+<input type="{@$inputType}" id="{$option->optionName}" name="values[{$option->optionName}]" value="{$value}"{if $inputClass} class="{@$inputClass}"{/if}{if !$searchOption} disabled="disabled"{/if} />
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('#{$option->optionName}').enable();
+ }
+ else {
+ $('#{$option->optionName}').disable();
+ }
+ });
+});
+//]]>
+</script>
<option name="gender">
<categoryname>profile.personal</categoryname>
- <optiontype>radioButton</optiontype>
+ <optiontype>select</optiontype>
<outputclass>wcf\system\option\user\SelectOptionsUserOptionOutput</outputclass>
<selectoptions>
<![CDATA[0:wcf.global.noDeclaration
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchRadioButtonOption{/lang}</label>
+<select id="{$option->optionName}" name="values[{$option->optionName}][]" multiple="multiple" size="{if $selectOptions|count > 10}10{else}{@$selectOptions|count}{/if}"{if !$searchOption} disabled="disabled"{/if}>
+ {foreach from=$selectOptions key=key item=selectOption}
+ <option value="{$key}"{if $key|in_array:$value} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
+ {/foreach}
+</select>
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('#{$option->optionName}').enable();
+ }
+ else {
+ $('#{$option->optionName}').disable();
+ }
+ });
+});
+//]]>
+</script>
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchRadioButtonOption{/lang}</label>
+{foreach from=$selectOptions key=key item=selectOption}
+ <label><input type="radio" name="values[{$option->optionName}]" value="{$key}" {if $value == $key} checked="checked"{/if} {if $disableOptions[$key]|isset || $enableOptions[$key]|isset}class="jsEnablesOptions" data-disable-options="[ {@$disableOptions[$key]}]" data-enable-options="[ {@$enableOptions[$key]}]"{/if} /> {lang}{@$selectOption}{/lang}</label>
+{/foreach}
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('input[name="values[{$option->optionName}]"]').enable();
+ }
+ else {
+ $('input[name="values[{$option->optionName}]"]').disable();
+ }
+ });
+});
+//]]>
+</script>
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchRadioButtonOption{/lang}</label>
+<select id="{$option->optionName}" name="values[{$option->optionName}]"{if !$searchOption} disabled="disabled"{/if}>
+ {if !$allowEmptyValue|empty}<option value="">{lang}wcf.global.noSelection{/lang}</option>{/if}
+ {foreach from=$selectOptions key=key item=selectOption}
+ <option value="{$key}"{if $value == $key} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
+ {/foreach}
+</select>
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('#{$option->optionName}').enable();
+ }
+ else {
+ $('#{$option->optionName}').disable();
+ }
+ });
+});
+//]]>
+</script>
--- /dev/null
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchTextOption{/lang}</label>
+<input type="{@$inputType}" id="{$option->optionName}" name="values[{$option->optionName}]" value="{$value}"{if $inputClass} class="{@$inputClass}"{/if}{if !$searchOption} disabled="disabled"{/if} />
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+ $('#search_{$option->optionName}').change(function(event) {
+ if ($(event.currentTarget).prop('checked')) {
+ $('#{$option->optionName}').enable();
+ }
+ else {
+ $('#{$option->optionName}').disable();
+ }
+ });
+});
+//]]>
+</script>
// dynamic fields
$this->buildDynamicConditions();
+ // if no conditions exists, no need to send query
+ if (!count($this->conditions->getParameters())) {
+ return;
+ }
+
// do search
$statement = WCF::getDB()->prepareStatement($sql.$this->conditions, $this->maxResults);
$statement->execute($this->conditions->getParameters());
*/
class BirthdayOptionType extends DateOptionType {
/**
- * input css class
- * @var string
+ * @see \wcf\system\option\TextOptionType::$inputClass
*/
protected $inputClass = 'birthday';
* @see \wcf\system\option\ISearchableUserOption::getCondition()
*/
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
- if (empty($value['ageFrom']) || empty($value['ageTo'])) return false;
+ if (empty($value['ageFrom']) && empty($value['ageTo'])) return false;
$ageFrom = intval($value['ageFrom']);
$ageTo = intval($value['ageTo']);
if ($ageFrom < 0 || $ageFrom > 120) return false;
if ($ageTo < 0 || $ageTo > 120) return false;
- if (!$ageFrom || !$ageTo) return false;
$dateFrom = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P'.($ageTo + 1).'Y'))->add(new \DateInterval('P1D'));
$dateTo = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P'.$ageFrom.'Y'));
- $conditions->add("option_value.userOption".User::getUserOptionID('birthdayShowYear')." = ? AND option_value.userOption".$option->optionID." BETWEEN DATE(?) AND DATE(?)", array(1, $dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d')));
+ $conditions->add('option_value.userOption'.User::getUserOptionID('birthdayShowYear').' = ?', array(1));
+
+ if ($ageFrom && $ageTo) {
+ $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d')));
+ }
+ else if ($ageFrom) {
+ $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array('1893-01-01', $dateTo->format('Y-m-d')));
+ }
+ else {
+ $conditions->add('option_value.userOption'.$option->optionID.' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), DateUtil::getDateTimeByTimestamp(TIME_NOW)->add(new \DateInterval('P1D'))->format('Y-m-d')));
+ }
+
return true;
}
}
return WCF::getTPL()->fetch('multiSelectOptionType');
}
+ /**
+ * @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
+ */
+ public function getSearchFormElement(Option $option, $value) {
+ WCF::getTPL()->assign(array(
+ 'option' => $option,
+ 'searchOption' => isset($_POST['searchOptions'][$option->optionName]),
+ 'selectOptions' => $option->parseSelectOptions(),
+ 'value' => (!is_array($value) ? explode("\n", $value) : $value)
+ ));
+ return WCF::getTPL()->fetch('multiSelectSearchableOptionType');
+ }
+
/**
* @see \wcf\system\option\IOptionType::validate()
*/
* @see \wcf\system\option\ISearchableUserOption::getCondition()
*/
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+ if (!isset($_POST['searchOptions'][$option->optionName])) return false;
+
if (!is_array($value) || empty($value)) return false;
$value = ArrayUtil::trim($value);
- if (empty($value)) return false;
$conditions->add("option_value.userOption".$option->optionID." REGEXP '".'(^|\n)'.implode('\n([^\n]*\n)*', array_map('escapeString', $value)).'($|\n)'."'");
return true;
* @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
*/
public function getSearchFormElement(Option $option, $value) {
+ $this->templateName = 'radioButtonSearchableOptionType';
+ WCF::getTPL()->assign('searchOption', empty($_POST) || isset($_POST['searchOptions'][$option->optionName]));
+
return $this->getFormElement($option, $value);
}
* @see \wcf\system\option\ISearchableUserOption::getCondition()
*/
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
- $value = StringUtil::trim($value);
- if (!$value) return false;
+ if (!isset($_POST['searchOptions'][$option->optionName])) return false;
- $conditions->add("option_value.userOption".$option->optionID." = ?", array($value));
+ $conditions->add("option_value.userOption".$option->optionID." = ?", array(StringUtil::trim($value)));
return true;
}
}
* @see \wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- // get options
$options = $this->parseEnableOptions($option);
WCF::getTPL()->assign(array(
* @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
*/
public function getSearchFormElement(Option $option, $value) {
- $this->allowEmptyValue = true;
- return $this->getFormElement($option, $value);
+ $options = $this->parseEnableOptions($option);
+
+ WCF::getTPL()->assign(array(
+ 'disableOptions' => $options['disableOptions'],
+ 'enableOptions' => $options['enableOptions'],
+ 'option' => $option,
+ 'searchOption' => isset($_POST['searchOptions'][$option->optionName]),
+ 'selectOptions' => $option->parseSelectOptions(),
+ 'value' => $value
+ ));
+ return WCF::getTPL()->fetch('selectSearchableOptionType');
}
/**
* @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
*/
public function getSearchFormElement(Option $option, $value) {
- return $this->getFormElement($option, $value);
+ WCF::getTPL()->assign(array(
+ 'option' => $option,
+ 'inputType' => $this->inputType,
+ 'inputClass' => $this->inputClass,
+ 'searchOption' => isset($_POST['searchOptions'][$option->optionName]),
+ 'value' => $value
+ ));
+ return WCF::getTPL()->fetch('textSearchableOptionType');
}
/**
* @see \wcf\system\option\ISearchableUserOption::getCondition()
*/
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+ if (!isset($_POST['searchOptions'][$option->optionName])) return false;
+
$value = StringUtil::trim($value);
- if (empty($value)) return false;
+ if ($value == '') {
+ $conditions->add("option_value.userOption".$option->optionID." = ?", array(''));
+ }
+ else {
+ $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%'));
+ }
- $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%'));
return true;
}
*
* @param \wcf\data\option\Option $option
* @param string $newValue
- * @return string
+ * @return string
*/
protected function getContent(Option $option, $newValue) {
if ($option->contentpattern) {
<item name="wcf.user.option.googlePlus"><![CDATA[Google+]]></item>
<item name="wcf.user.option.googlePlus.description"><![CDATA[21-stellige Google-Plus-ID]]></item>
<item name="wcf.user.option.canWriteProfileComments"><![CDATA[Kann Pinnwand-Kommentare schreiben]]></item>
+
+ <item name="wcf.user.option.searchRadioButtonOption"><![CDATA[Auswahl des Benutzers bei „{lang}wcf.user.option.{$option->optionName}{/lang}“:]]></item>
+ <item name="wcf.user.option.searchTextOption"><![CDATA[„{lang}wcf.user.option.{$option->optionName}{/lang}“ enthält:]]></item>
</category>
<category name="wcf.user.mail">
<item name="wcf.user.option.googlePlus"><![CDATA[Google+]]></item>
<item name="wcf.user.option.googlePlus.description"><![CDATA[21 digits Google Plus user ID]]></item>
<item name="wcf.user.option.canWriteProfileComments"><![CDATA[Can Write Comments on My Wall]]></item>
+
+ <item name="wcf.user.option.searchRadioButtonOption"><![CDATA[User's selection for “{lang}wcf.user.option.{$option->optionName}{/lang}”:]]></item>
+ <item name="wcf.user.option.searchTextOption"><![CDATA[“{lang}wcf.user.option.{$option->optionName}{/lang}” contains:]]></item>
</category>
<category name="wcf.user.mail">