Skip to content

Commit 7a461dd

Browse files
committed
Allow emoji in short name to be saved to DB
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent d0a0cb7 commit 7a461dd

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

event/listener.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public static function getSubscribedEvents()
8585
'core.ucp_display_module_before' => 'load_language',
8686
'core.acp_main_notice' => 'compatibility_notice',
8787
'core.acp_board_config_edit_add' => 'acp_pwa_options',
88+
'core.acp_board_config_emoji_enabled'=> 'acp_pwa_allow_emoji',
8889
'core.validate_config_variable' => 'validate_pwa_options',
8990
'core.help_manager_add_block_after' => 'wpn_faq',
9091
];
@@ -170,6 +171,24 @@ public function acp_pwa_options($event)
170171
}
171172
}
172173

174+
/**
175+
* Allow PWA short name ACP field to accept emoji characters
176+
*
177+
* @param \phpbb\event\data $event
178+
* @return void
179+
*/
180+
public function acp_pwa_allow_emoji($event)
181+
{
182+
if (in_array('pwa_short_name', $event['config_name_ary'], true))
183+
{
184+
return;
185+
}
186+
187+
$config_name_ary = $event['config_name_ary'];
188+
$config_name_ary[] = 'pwa_short_name';
189+
$event['config_name_ary'] = $config_name_ary;
190+
}
191+
173192
/**
174193
* Return HTML for PWA icon name settings
175194
*
@@ -223,7 +242,7 @@ public function validate_pwa_options($event)
223242
return;
224243
}
225244

226-
$short_name = $event['cfg_array']['pwa_short_name'];
245+
$short_name = html_entity_decode($event['cfg_array']['pwa_short_name'], ENT_QUOTES, 'UTF-8');
227246

228247
// Do not allow strings longer than 12 characters
229248
if (mb_strlen($short_name, 'UTF-8') > 12)
@@ -339,7 +358,7 @@ protected function can_use_notifications()
339358
}
340359

341360
/**
342-
* Get short name from a string (strip out multibyte characters and trim to 12 characters)
361+
* Get short name from a string (decode any entities and trim to 12 characters)
343362
*
344363
* @param string $name
345364
* @return string 12 max characters string

0 commit comments

Comments
 (0)