From: Alexander Ebert Date: Mon, 12 Mar 2012 16:35:48 +0000 (+0100) Subject: Added switch to handle user options during registration X-Git-Tag: 2.0.0_Beta_1~1243^2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bb13301b4a681ccf98d99ca56c534880a2cc107a;p=GitHub%2FWoltLab%2FWCF.git Added switch to handle user options during registration --- diff --git a/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php index 46330a6987..a985beef90 100644 --- a/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php @@ -157,7 +157,7 @@ class UserAddForm extends UserOptionListForm { // validate user language $language = LanguageFactory::getInstance()->getLanguage($this->languageID); - if (!$language->languageID) { + if ($language === null || !$language->languageID) { // use default language $this->languageID = LanguageFactory::getInstance()->getDefaultLanguageID(); } diff --git a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php index 7036dc88ea..a6fda43f96 100644 --- a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php @@ -18,6 +18,12 @@ use wcf\system\option\OptionHandler; * @category Community Framework */ class UserOptionHandler extends OptionHandler { + /** + * true, if within registration process + * @var boolean + */ + public $inRegistration = false; + /** * true, if empty options should be removed * @var boolean @@ -44,6 +50,15 @@ class UserOptionHandler extends OptionHandler { $this->removeEmptyOptions = false; } + /** + * Sets registration mode. + * + * @param boolean $inRegistration + */ + public function setInRegistration($inRegistration) { + $this->inRegistration = $inRegistration; + } + /** * Sets option values for a certain user. * @@ -114,6 +129,28 @@ class UserOptionHandler extends OptionHandler { $option->setUser($this->user); } + if ($this->inRegistration && !$option->askDuringRegistration) { + return false; + } + return $option->isVisible(); } + + /** + * @see wcf\system\option\OptionHandler::save() + */ + public function save($categoryName = null, $optionPrefix = null) { + $options = parent::save($categoryName, $optionPrefix); + + // remove options which are not asked during registration + if ($this->inRegistration && !empty($options)) { + foreach ($this->options as $option) { + if (!$option->askDuringRegistration && array_key_exists($option->optionID, $options)) { + unset($options[$option->optionID]); + } + } + } + + return $options; + } }