Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions com.woltlab.wcf/templates/userCard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
{/if}
{/if}

{foreach from=$user->getUserCardOptions() item=userCardOption}
<dt>{$userCardOption->getTitle()}</dt>
<dd>{unsafe:$userCardOption->optionValue}</dd>
{/foreach}

{event name='afterDetails'}
{/content}
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@
->defaultValue(0)
->drop(),
JsonDatabaseTableColumn::create('cachedReactions'),
])
]),
PartialDatabaseTable::create('wcf1_user_option')
->columns([
DefaultFalseBooleanDatabaseTableColumn::create('showOnUserCard'),
]),
];
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ public function createForm()
BooleanFormField::create('searchable')
->label('wcf.acp.user.option.searchable')
->value(false),
BooleanFormField::create('showOnUserCard')
->label('wcf.acp.user.option.showOnUserCard')
->value(false),
])
]);
}
Expand Down
41 changes: 40 additions & 1 deletion wcfsetup/install/files/lib/data/user/UserProfile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use wcf\data\user\ignore\UserIgnore;
use wcf\data\user\online\UserOnline;
use wcf\data\user\option\ViewableUserOption;
use wcf\system\cache\builder\UserOptionCacheBuilder;
use wcf\data\user\rank\UserRank;
use wcf\system\cache\builder\UserGroupPermissionCacheBuilder;
use wcf\system\cache\builder\UserRankCacheBuilder;
Expand Down Expand Up @@ -47,7 +48,7 @@
* @property-read string $birthday
* @extends DatabaseObjectDecorator<User>
*/
class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject
class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject, \Stringable
{
/**
* @inheritDoc
Expand Down Expand Up @@ -1102,6 +1103,44 @@ public function isVisibleOption(string $name)
return $option->isVisible();
}

/**
* Returns the list of user options that should be displayed on the user card.
*
* @return ViewableUserOption[]
* @since 6.3
*/
public function getUserCardOptions(): array
{
$options = UserOptionCacheBuilder::getInstance()->getData([], 'options');

$result = [];
foreach ($options as $option) {
if (!$option->showOnUserCard) {
continue;
}

$rawValue = $this->getUserOption($option->optionName);
if ($rawValue === null || $rawValue === '') {
continue;
}

$viewableOption = ViewableUserOption::getUserOption($option->optionName);
$viewableOption->setUser($this->getDecoratedObject());
if (!$viewableOption->isVisible()) {
continue;
}

$viewableOption->setOptionValue($this->getDecoratedObject());
if ($viewableOption->optionValue === '' || $viewableOption->optionValue === null) {
continue;
}

$result[] = $viewableOption;
}

return $result;
}

/**
* Returns the formatted username.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* @property-read 0|1 $isDisabled is `1` if the user option is disabled and thus neither shown nor editable, otherwise `0`
* @property-read 0|1 $originIsSystem is `1` if the user option was created by the system and not manually by an administrator, otherwise `0`
* @property-read string $labeledUrl the url, if the option type is `labeledUrl`
* @property-read 0|1 $showOnUserCard is `1` if the user option should be displayed on the user card, otherwise `0`
*/
class UserOption extends Option implements ITitledObject
{
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/lang/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3148,6 +3148,7 @@ Abschnitte dürfen nicht leer sein und nur folgende Zeichen enthalten: <kbd>[a-z
<item name="wcf.acp.user.option.askDuringRegistration"><![CDATA[Das Feld wird im Registrierungs-Formular angezeigt.]]></item>
<item name="wcf.acp.user.option.required"><![CDATA[Das Feld muss zwingend durch den Eigentümer ausgefüllt werden.]]></item>
<item name="wcf.acp.user.option.searchable"><![CDATA[Das Feld kann über die Mitgliedersuche durchsucht werden.]]></item>
<item name="wcf.acp.user.option.showOnUserCard"><![CDATA[Feld in der Mitgliederliste anzeigen]]></item>
<item name="wcf.acp.user.option.selectOptions"><![CDATA[Auswahloptionen]]></item>
<item name="wcf.acp.user.option.selectOptions.description"><![CDATA[Hier {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} pro Zeile Auswahloptionen eintragen, beispielsweise bei einer Select-Box. {if LANGUAGE_USE_INFORMAL_VARIANT}Beachte{else}Beachten Sie{/if}, dass bei der Verwendung des Doppelpunktes der linke Teil der Zeile als interner Bezeichner verwendet wird. Dieser erlaubt es den Text zu ändern, ohne dass die Auswahl von Benutzern verloren geht.]]></item>
<item name="wcf.acp.user.option.setDefaults"><![CDATA[Benutzerprofil-Einstellungen verwalten]]></item>
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,7 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
<item name="wcf.acp.user.option.askDuringRegistration"><![CDATA[Field will be visible during registration]]></item>
<item name="wcf.acp.user.option.required"><![CDATA[Owner must provide a valid value]]></item>
<item name="wcf.acp.user.option.searchable"><![CDATA[Field values are searchable in the member search]]></item>
<item name="wcf.acp.user.option.showOnUserCard"><![CDATA[Display field in the members list]]></item>
<item name="wcf.acp.user.option.selectOptions"><![CDATA[Select Options]]></item>
<item name="wcf.acp.user.option.selectOptions.description"><![CDATA[Enter one select option per line, e.g. for use with a select-box. Note: The left-hand side of a colon is used as an internal identifier. It allows you to change the text of the option without invalidating former selections.]]></item>
<item name="wcf.acp.user.option.setDefaults"><![CDATA[Manage User Field Settings]]></item>
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/setup/db/install_com.woltlab.wcf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4616,6 +4616,7 @@
TextDatabaseTableColumn::create('options'),
MediumtextDatabaseTableColumn::create('additionalData'),
DefaultFalseBooleanDatabaseTableColumn::create('originIsSystem'),
DefaultFalseBooleanDatabaseTableColumn::create('showOnUserCard'),
])
->indices([
DatabaseTablePrimaryIndex::create()
Expand Down
Loading