From 3ed8cffad2de407df2f54712929d8a12956bc5e2 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 30 Nov 2018 04:02:13 +0100 Subject: [ticket/15889] Add core.memberlist_modify_memberrow_sql PHPBB3-15889 --- phpBB/memberlist.php | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 977857da59..536006036c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1469,19 +1469,25 @@ switch ($mode) // Do the SQL thang if ($mode == 'group') { - $sql = "SELECT u.* - $sql_select - FROM " . USERS_TABLE . " u - $sql_from - WHERE " . $db->sql_in_set('u.user_id', $user_list) . " - $sql_where_data"; + $sql_array = array( + 'SELECT' => 'u.*' . $sql_select, + 'FROM' => array( + USERS_TABLE => 'u' . $sql_from + ), + 'WHERE' => $db->sql_in_set('u.user_id', $user_list) . $sql_where_data . '', + ); } else { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_list); + $sql_array = array( + 'SELECT' => '*', + 'FROM' => array( + USERS_TABLE => 'u' + ), + 'WHERE' => $db->sql_in_set('u.user_id', $user_list), + ); } + $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $id_cache = array(); @@ -1492,9 +1498,31 @@ switch ($mode) $id_cache[$row['user_id']] = $row; } + + /** + * Modify user data SQL before member row is created + * + * @event core.memberlist_modify_memberrow_sql + * @var string mode group + * @var string sql_select Additional select statement + * @var string sql_from Additional from statement + * @var array sql_array Array containing the main query + * @var array user_list Array containing list of users + * @var array id_cache Array of temp user ID data + * @since 3.2.6-RC1 + */ + $vars = array( + 'mode', + 'sql_select', + 'sql_from', + 'sql_array', + 'user_list', + 'id_cache' + ); + extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); + $db->sql_freeresult($result); - // Load custom profile fields if ($config['load_cpf_memberlist']) { // Grab all profile fields from users in id cache for later use - similar to the poster cache -- cgit v1.2.1 From 89b6fb1168e2a04111123a672c37cc0d94ad5608 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 30 Nov 2018 04:24:57 +0100 Subject: [ticket/15889] Add core.memberlist_modify_memberrow_sql PHPBB3-15889 --- phpBB/memberlist.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 536006036c..0203b2af4b 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1507,8 +1507,7 @@ switch ($mode) * @var string sql_select Additional select statement * @var string sql_from Additional from statement * @var array sql_array Array containing the main query - * @var array user_list Array containing list of users - * @var array id_cache Array of temp user ID data + * @var array row Array containing the user_ID data * @since 3.2.6-RC1 */ $vars = array( @@ -1516,8 +1515,7 @@ switch ($mode) 'sql_select', 'sql_from', 'sql_array', - 'user_list', - 'id_cache' + 'row' ); extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); -- cgit v1.2.1 From c5082250ea225d6b426ebf5e5818954dba6976dd Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 30 Nov 2018 04:44:49 +0100 Subject: [ticket/15889] Add core.memberlist_modify_memberrow_sql PHPBB3-15889 --- phpBB/memberlist.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 0203b2af4b..e27900f660 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1507,7 +1507,7 @@ switch ($mode) * @var string sql_select Additional select statement * @var string sql_from Additional from statement * @var array sql_array Array containing the main query - * @var array row Array containing the user_ID data + * @var array id_cache Array of temp user ID data * @since 3.2.6-RC1 */ $vars = array( @@ -1515,7 +1515,7 @@ switch ($mode) 'sql_select', 'sql_from', 'sql_array', - 'row' + 'id_cache', ); extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); -- cgit v1.2.1 From ec140a558b0721244da999930ee2a5ac264b05ea Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 30 Nov 2018 06:42:20 +0100 Subject: [ticket/15889] Add core.memberlist_modify_memberrow_sql PHPBB3-15889 --- phpBB/memberlist.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index e27900f660..7340737b2c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1507,7 +1507,8 @@ switch ($mode) * @var string sql_select Additional select statement * @var string sql_from Additional from statement * @var array sql_array Array containing the main query - * @var array id_cache Array of temp user ID data + * @var array user_list Array containing the user IDs + * @var array id_cache Temp. Array of users data * @since 3.2.6-RC1 */ $vars = array( @@ -1515,6 +1516,7 @@ switch ($mode) 'sql_select', 'sql_from', 'sql_array', + 'user_list', 'id_cache', ); extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); -- cgit v1.2.1 From 73b709d0caf6ef3bd83c23192e0aa12c54952a66 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 30 Nov 2018 08:40:17 +0100 Subject: [ticket/15889] Add core.memberlist_modify_memberrow_sql That's it. PHPBB3-15889 --- phpBB/memberlist.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 7340737b2c..ddebf5124c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1487,17 +1487,6 @@ switch ($mode) 'WHERE' => $db->sql_in_set('u.user_id', $user_list), ); } - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - $id_cache = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0; - $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; - - $id_cache[$row['user_id']] = $row; - } /** * Modify user data SQL before member row is created @@ -1507,8 +1496,7 @@ switch ($mode) * @var string sql_select Additional select statement * @var string sql_from Additional from statement * @var array sql_array Array containing the main query - * @var array user_list Array containing the user IDs - * @var array id_cache Temp. Array of users data + * @var array user_list Array containing list of users * @since 3.2.6-RC1 */ $vars = array( @@ -1517,10 +1505,21 @@ switch ($mode) 'sql_from', 'sql_array', 'user_list', - 'id_cache', ); extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query($sql); + + $id_cache = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0; + $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; + + $id_cache[$row['user_id']] = $row; + } + $db->sql_freeresult($result); if ($config['load_cpf_memberlist']) -- cgit v1.2.1 From afcc713d39a05b8aec54f046b1f56170d56f4ac3 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 30 Nov 2018 09:11:35 +0100 Subject: [ticket/15889] Add core.memberlist_modify_memberrow_sql fix select all on users table PHPBB3-15889 --- phpBB/memberlist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index ddebf5124c..97d709163a 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1480,7 +1480,7 @@ switch ($mode) else { $sql_array = array( - 'SELECT' => '*', + 'SELECT' => 'u.*', 'FROM' => array( USERS_TABLE => 'u' ), -- cgit v1.2.1 From 31b8fdf964585d7021ea86230c7129dedefc3c7d Mon Sep 17 00:00:00 2001 From: 3D-I Date: Sat, 1 Dec 2018 00:05:15 +0100 Subject: [ticket/15889] Restore comment line PHPBB3-15889 --- phpBB/memberlist.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 97d709163a..30aa0c1140 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1522,6 +1522,7 @@ switch ($mode) $db->sql_freeresult($result); + // Load custom profile fields if required if ($config['load_cpf_memberlist']) { // Grab all profile fields from users in id cache for later use - similar to the poster cache -- cgit v1.2.1 From eead94c8a6829f43df6e0e97ecfa7ef566d92bc3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 29 Dec 2018 11:43:23 +0100 Subject: [ticket/15889] Use array version of sql_from tables in sql array PHPBB3-15889 --- phpBB/memberlist.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 30aa0c1140..bcd72762ae 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1469,11 +1469,23 @@ switch ($mode) // Do the SQL thang if ($mode == 'group') { + $sql_from_ary = explode(',', $sql_from); + $extra_tables = []; + foreach ($sql_from_ary as $entry) + { + $table_data = explode(' ', trim($entry)); + + if (empty($table_data[0]) || empty($table_data[1])) + { + continue; + } + + $extra_tables[$table_data[0]] = $table_data[1]; + } + $sql_array = array( 'SELECT' => 'u.*' . $sql_select, - 'FROM' => array( - USERS_TABLE => 'u' . $sql_from - ), + 'FROM' => array_merge([USERS_TABLE => 'u'], $extra_tables), 'WHERE' => $db->sql_in_set('u.user_id', $user_list) . $sql_where_data . '', ); } -- cgit v1.2.1 From a14a666e86dfa0941785a05a8e8df935104a908f Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 29 Mar 2019 23:53:56 +0100 Subject: [ticket/15889] Change mode description in doc-block PHPBB3-15889 [ticket/15889] Change mode description in doc-block PHPBB3-15889 [ticket/15889] Amend doc-block PHPBB3-15889 [ticket/15889] Amend doc-block PHPBB3-15889 [ticket/15889] Change mode description in doc-block PHPBB3-15889 --- phpBB/memberlist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/memberlist.php') diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 5efb451f55..3e71a2a495 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1504,7 +1504,7 @@ switch ($mode) * Modify user data SQL before member row is created * * @event core.memberlist_modify_memberrow_sql - * @var string mode group + * @var string mode Memberlist mode * @var string sql_select Additional select statement * @var string sql_from Additional from statement * @var array sql_array Array containing the main query -- cgit v1.2.1