[ticket/16383] Add core events to modify friends list

PHPBB3-16383
This commit is contained in:
Dark❶ 2020-02-27 21:38:48 +05:30
parent 5ce1e1e7df
commit f6e9e043d8
No known key found for this signature in database
GPG key ID: FAE32A15F9132DE8

View file

@ -356,6 +356,19 @@ if ($module->is_active('zebra', 'friends'))
'ORDER_BY' => 'u.username_clean ASC', '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); $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary);
$result = $db->sql_query($sql); $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'; $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'], 'USER_ID' => $row['user_id'],
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), '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']), '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' => 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); $db->sql_freeresult($result);
} }