[ticket/16413] Handle displaying icon on PM screen

Also, save empty color if custom icon name is empty.

PHPBB3-16413
This commit is contained in:
rxu 2025-05-19 23:22:16 +07:00
parent 80af2dc25e
commit b84bc9adfc
No known key found for this signature in database
GPG key ID: 8117904FEDEFDD17
3 changed files with 11 additions and 3 deletions

View file

@ -429,9 +429,11 @@ class acp_profile
$options = $profile_field->prepare_options_form($exclude, $visibility_ary);
$field_icon_data = json_decode($field_row['field_icon'], true);
$field_icon_name = $request->variable('field_icon', $field_icon_data['name'] ?: '');
$field_icon_color = $field_icon_name ? $request->variable('field_icon_color', $field_icon_data['color'] ?: '') : '';
$cp->vars['field_icon'] = json_encode([
'name' => $request->variable('field_icon', $field_icon_data['name'] ?: ''),
'color' => $request->variable('field_icon_color', $field_icon_data['color'] ?: ''),
'name' => $field_icon_name,
'color' => $field_icon_color,
]);
$cp->vars['field_ident'] = ($action == 'create' && $step == 1) ? utf8_clean_string($request->variable('field_ident', $field_row['field_ident'], true)) : $request->variable('field_ident', $field_row['field_ident']);
$cp->vars['lang_name'] = $request->variable('lang_name', $field_row['lang_name'], true);

View file

@ -373,8 +373,11 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
if ($cp_block_row['S_PROFILE_CONTACT'])
{
$icon_data = json_decode($cp_block_row['PROFILE_FIELD_ICON'], true);
$template->assign_block_vars('contact', array(
'ID' => $cp_block_row['PROFILE_FIELD_IDENT'],
'ICON' => $icon_data['name'],
'ICON_COLOR'=> $icon_data['color'],
'NAME' => $cp_block_row['PROFILE_FIELD_NAME'],
'U_CONTACT' => $cp_block_row['PROFILE_FIELD_CONTACT'],
));

View file

@ -71,7 +71,10 @@
<div>
<!-- ENDIF -->
<a href="<!-- IF contact.U_CONTACT -->{contact.U_CONTACT}<!-- ELSE -->{contact.U_PROFILE_AUTHOR}<!-- ENDIF -->" title="{contact.NAME}"<!-- IF $S_LAST_CELL --> class="last-cell"<!-- ENDIF -->>
{% if contact.ID == 'pm' %}
{% if contact.ICON %}
{% set color = contact.ICON_COLOR ? ({style: 'color: #' ~ contact.ICON_COLOR}) : [] %}
{{ Icon('font', contact.ICON, '', true, '', color) }}
{% elseif contact.ID == 'pm' %}
{{ Icon('font', 'message', '', true, 'far contact-icon') }}
{% elseif contact.ID == 'email' %}
{{ Icon('font', 'at', '', true, 'fas contact-icon') }}