<section class="section">
<h2 class="sectionTitle">{lang}wcf.user.option.category.{@$categoryLevel2[object]->categoryName}{/lang}</h2>
- {if $categoryLevel2[object]->categoryName == 'settings.general' && $availableLanguages|count > 1}
- <dl>
- <dt><label for="languageID">{lang}wcf.user.language{/lang}</label></dt>
- <dd>
- {htmlOptions options=$availableLanguages selected=$languageID name=languageID id=languageID disableEncoding=true}
- </dd>
- </dl>
+ {if $categoryLevel2[object]->categoryName == 'settings.general'}
+ {if $availableLanguages|count > 1}
+ <dl>
+ <dt><label for="languageID">{lang}wcf.user.language{/lang}</label></dt>
+ <dd>
+ {htmlOptions options=$availableLanguages selected=$languageID name=languageID id=languageID disableEncoding=true}
+ </dd>
+ </dl>
+
+ {if $availableContentLanguages|count > 1}
+ <dl>
+ <dt>
+ <label>{lang}wcf.user.visibleLanguages{/lang}</label>
+ </dt>
+ <dd>
+ {foreach from=$availableContentLanguages key=availableLanguageID item=availableLanguage}
+ <label><input type="checkbox" name="visibleLanguages[]" value="{@$availableLanguageID}"{if $availableLanguageID|in_array:$visibleLanguages} checked{/if}> {@$availableLanguage}</label>
+ {/foreach}
+ </dd>
+ </dl>
+ {/if}
+ {/if}
- {if $availableContentLanguages|count > 1}
+ {if $action === 'edit' && $availableStyles|count > 1}
<dl>
- <dt>
- <label>{lang}wcf.user.visibleLanguages{/lang}</label>
- </dt>
+ <dt><label for="styleID">{lang}wcf.user.style{/lang}</label></dt>
<dd>
- {foreach from=$availableContentLanguages key=availableLanguageID item=availableLanguage}
- <label><input type="checkbox" name="visibleLanguages[]" value="{@$availableLanguageID}"{if $availableLanguageID|in_array:$visibleLanguages} checked{/if}> {@$availableLanguage}</label>
- {/foreach}
+ <select id="styleID" name="styleID">
+ <option value="0">{lang}wcf.global.defaultValue{/lang}</option>
+ {foreach from=$availableStyles item=style}
+ <option value="{@$style->styleID}"{if $style->styleID == $styleID} selected{/if}>{$style->styleName}</option>
+ {/foreach}
+ </select>
+ {if $errorField === 'styleID'}
+ <small class="innerError">
+ {if $errorType === 'empty' || $errorType === 'noValidSelection'}
+ {lang}wcf.global.form.error.{@$errorType}{/lang}
+ {else}
+ {lang}wcf.user.style.error.{@$errorType.password}{/lang}
+ {/if}
+ </small>
+ {/if}
+ <small>{lang}wcf.user.style.description{/lang}</small>
</dd>
</dl>
{/if}
<?php
namespace wcf\acp\form;
+use wcf\data\style\Style;
use wcf\data\user\avatar\Gravatar;
use wcf\data\user\avatar\UserAvatar;
use wcf\data\user\avatar\UserAvatarAction;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\moderation\queue\ModerationQueueManager;
+use wcf\system\style\StyleHandler;
use wcf\system\WCF;
use wcf\util\StringUtil;
* Shows the user edit form.
*
* @author Marcel Werk
- * @copyright 2001-2019 WoltLab GmbH
+ * @copyright 2001-2020 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\Acp\Form
*/
*/
public $disconnect3rdParty = 0;
+ /**
+ * list of available styles for the edited user
+ * @var Style[]
+ * @since 5.3
+ */
+ public $availableStyles = [];
+
+ /**
+ * id of the used style
+ * @var int
+ * @since 5.3
+ */
+ public $styleID;
+
/**
* @inheritDoc
*/
}
if (isset($_POST['avatarType'])) $this->avatarType = $_POST['avatarType'];
+ if (isset($_POST['styleID'])) $this->styleID = intval($_POST['styleID']);
if (WCF::getSession()->getPermission('admin.user.canDisableAvatar')) {
if (!empty($_POST['disableAvatar'])) $this->disableAvatar = 1;
$this->readDefaultValues();
}
+ $userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
+ foreach (StyleHandler::getInstance()->getStyles() as $style) {
+ if (!$style->isDisabled || $userProfile->getPermission('admin.style.canUseDisabledStyle')) {
+ $this->availableStyles[$style->styleID] = $style;
+ }
+ }
+
parent::readData();
// get the avatar object
// get the user cover photo object
if ($this->user->coverPhotoHash) {
- $userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
-
// If the editing user lacks the permissions to view the cover photo, the system
// will try to load the default cover photo. However, the default cover photo depends
// on the style, eventually triggering a change to the template group which will
$this->banReason = $this->user->banReason;
$this->banExpires = $this->user->banExpires;
$this->userTitle = $this->user->userTitle;
+ $this->styleID = $this->user->styleID;
$this->signature = $this->user->signature;
$this->disableSignature = $this->user->disableSignature;
'disableCoverPhotoExpires' => $this->disableCoverPhotoExpires,
'deleteCoverPhoto' => $this->deleteCoverPhoto,
'ownerGroupID' => UserGroup::getOwnerGroupID(),
+ 'availableStyles' => $this->availableStyles,
+ 'styleID' => $this->styleID,
]);
}
// save user
$saveOptions = $this->optionHandler->save();
-
+
$data = [
'data' => array_merge($this->additionalFields, [
'username' => $this->username,
'password' => $this->password,
'languageID' => $this->languageID,
'userTitle' => $this->userTitle,
- 'signature' => $this->htmlInputProcessor->getHtml()
+ 'signature' => $this->htmlInputProcessor->getHtml(),
+ 'styleID' => $this->styleID,
]),
'groups' => $this->groupIDs,
'languageIDs' => $this->visibleLanguages,
- 'options' => $saveOptions
+ 'options' => $saveOptions,
];
// handle changed username
if (mb_strtolower($this->username) != mb_strtolower($this->user->username)) {
$this->validateAvatar();
parent::validate();
+
+ if (!isset($this->availableStyles[$this->styleID])) {
+ throw new UserInputException('styleID', 'noValidSelection');
+ }
}
}