From f6e9e043d810e0ced59cb81f9e2221df5b8dc896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dark=E2=9D=B6?= Date: Thu, 27 Feb 2020 21:38:48 +0530 Subject: [PATCH 1/3] [ticket/16383] Add core events to modify friends list PHPBB3-16383 --- phpBB/ucp.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 96a3efea97..3b7a6b2377 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -356,6 +356,19 @@ if ($module->is_active('zebra', 'friends')) 'ORDER_BY' => 'u.username_clean ASC', ); + /** + * Event to modify the SQL query before listing of friends + * + * @event core.ucp_modify_friends_sql + * @var array sql_ary SQL query array for listing of friends + * + * @since 3.2.10-RC1 + */ + $vars = array( + 'sql_ary', + ); + extract($phpbb_dispatcher->trigger_event('core.ucp_modify_friends_sql', compact($vars))); + $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary); $result = $db->sql_query($sql); @@ -363,14 +376,32 @@ if ($module->is_active('zebra', 'friends')) { $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline'; - $template->assign_block_vars("friends_{$which}", array( + $tpl_ary = array( 'USER_ID' => $row['user_id'], - 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])) + 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) ); + + /** + * Event to modify the template before listing of friends + * + * @event core.ucp_modify_friends_template_vars + * @var array row friend user row + * @var array tpl_ary friend template array + * @var string which friend is 'online' or 'offline' + * + * @since 3.2.10-RC1 + */ + $vars = array( + 'row', + 'tpl_ary', + 'which', + ); + extract($phpbb_dispatcher->trigger_event('core.ucp_modify_friends_template_vars', compact($vars))); + + $template->assign_block_vars("friends_{$which}", $tpl_ary); } $db->sql_freeresult($result); } From 2ee9d4f101efa17363ba1ae6a57c300b28ad0240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dark=E2=9D=B6?= Date: Fri, 28 Feb 2020 00:21:08 +0530 Subject: [PATCH 2/3] [ticket/16383] Add core events to modify friends list PHPBB3-16383 --- phpBB/ucp.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 3b7a6b2377..0cb5c0f608 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -364,9 +364,9 @@ if ($module->is_active('zebra', 'friends')) * * @since 3.2.10-RC1 */ - $vars = array( + $vars = [ 'sql_ary', - ); + ]; extract($phpbb_dispatcher->trigger_event('core.ucp_modify_friends_sql', compact($vars))); $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary); @@ -394,11 +394,11 @@ if ($module->is_active('zebra', 'friends')) * * @since 3.2.10-RC1 */ - $vars = array( + $vars = [ 'row', 'tpl_ary', 'which', - ); + ]; extract($phpbb_dispatcher->trigger_event('core.ucp_modify_friends_template_vars', compact($vars))); $template->assign_block_vars("friends_{$which}", $tpl_ary); From 300f887c02349723299b202ae3e5e19aaba74a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dark=E2=9D=B6?= Date: Fri, 28 Feb 2020 00:30:34 +0530 Subject: [PATCH 3/3] [ticket/16383] Add core events to modify friends list PHPBB3-16383 --- phpBB/ucp.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 0cb5c0f608..0d3feb9aa9 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -376,13 +376,13 @@ if ($module->is_active('zebra', 'friends')) { $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline'; - $tpl_ary = array( + $tpl_ary = [ 'USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) - ); + ]; /** * Event to modify the template before listing of friends