<select id="{$option->optionName}" name="values[{$option->optionName}]">
-{foreach from=$selectOptions key=key item=selectOption}
- <option value="{$key}"{if $value == $key} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
-{/foreach}
+ <option value=""></option>
+ {foreach from=$selectOptions key=key item=selectOption}
+ <option value="{$key}"{if $value == $key} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
+ {/foreach}
</select>
\ No newline at end of file
<select id="{$option->optionName}" name="values[{$option->optionName}]">
+ <option value=""></option>
{foreach from=$selectOptions key=key item=selectOption}
<option value="{$key}"{if $value == $key} selected="selected"{/if}>{lang}{@$selectOption}{/lang}</option>
{/foreach}
// reset values
$this->optionName = $this->optionDescription = $this->categoryName = $this->optionType = $this->defaultValue = $this->validationPattern = $this->optionType = $this->selectOptions = $this->outputClass = '';
- $this->required = $this->editable = $this->visible = $this->searchable = $this->showOrder = $this->askDuringRegistration = 0;
+ $this->required = $this->searchable = $this->showOrder = $this->askDuringRegistration = 0;
+ $this->editable = 3;
+ $this->visible = 15;
// show success
WCF::getTPL()->assign('success', true);
// apply changes
if ($this->applyChangesToExistingUsers) {
$optionIDs = array_keys($saveOptions);
- $sql = "UPDATE wcf".WCF_N."_user_option_value
- SET userOption".implode(' = ?, userOption', $optionIDs)." = ?";
+
+ // get changed options
+ $sql = "SELECT optionID, defaultValue
+ FROM wcf".WCF_N."_user_option
+ WHERE optionID IN (?".str_repeat(', ?', count($optionIDs) - 1).")";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge($saveOptions));
+ $statement->execute($optionIDs);
+ $optionIDs = $optionValues = array();
+ while ($row = $statement->fetchArray()) {
+ if ($row['defaultValue'] != $saveOptions[$row['optionID']]) {
+ $optionIDs[] = $row['optionID'];
+ $optionValues[] = $saveOptions[$row['optionID']];
+ }
+ }
+
+ if (!empty($optionIDs)) {
+ $sql = "UPDATE wcf".WCF_N."_user_option_value
+ SET userOption".implode(' = ?, userOption', $optionIDs)." = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array_merge($optionValues));
+ }
}
// reset cache
UserOptionCacheBuilder::getInstance()->reset();
-
$this->saved();
WCF::getTPL()->assign('success', true);
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($this->optionID));
- $sql = WCF::getDB()->getEditor()->dropColumn('wcf'.WCF_N.'_user_option_value', 'userOption'.$this->optionID);
+ WCF::getDB()->getEditor()->dropColumn('wcf'.WCF_N.'_user_option_value', 'userOption'.$this->optionID);
+ }
+
+ /**
+ * @see wcf\data\IEditableObject::deleteAll()
+ */
+ public static function deleteAll(array $objectIDs = array()) {
+ $returnValue = parent::deleteAll($objectIDs);
+
+ foreach ($objectIDs as $objectID) {
+ WCF::getDB()->getEditor()->dropColumn('wcf'.WCF_N.'_user_option_value', 'userOption'.$objectID);
+ }
+
+ return $returnValue;
}
/**
WCF::getTPL()->assign(array(
'option' => $option,
'selectOptions' => $option->parseSelectOptions(),
- 'value' => explode("\n", $value)
+ 'value' => (!is_array($value) ? explode("\n", $value) : $value)
));
return WCF::getTPL()->fetch('multiSelectOptionType');
}
$value = ArrayUtil::trim($value);
if (empty($value)) return false;
- $conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value)));
+ $conditions->add("option_value.userOption".$option->optionID." REGEXP '".'(^|\n)'.implode('\n([^\n]*\n)*', array_map('escapeString', $value)).'($|\n)'."'");
return true;
}
}