From 4b2d7735b30270ed933ed8ba3d6519183ec87dd6 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 16 Mar 2014 00:11:12 +0100 Subject: [PATCH 1/6] [ticket/7707] Add get_username_string() where possible PHPBB3-7707 --- phpBB/includes/acp/acp_main.php | 6 +----- phpBB/includes/acp/acp_prune.php | 2 +- phpBB/includes/acp/auth.php | 4 ++-- phpBB/includes/mcp/mcp_post.php | 8 ++++---- phpBB/includes/mcp/mcp_warn.php | 18 +++++++++--------- phpBB/memberlist.php | 2 +- phpBB/viewtopic.php | 2 +- 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index fd45027b49..4512905539 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -40,11 +40,7 @@ class acp_main $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $perm_from = '' : '>'); - $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '' : ''; - $perm_from .= $user_row['username']; - $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '' : ''; - $perm_from .= ''; + $perm_from = get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']); $template->assign_vars(array( 'S_RESTORE_PERMISSIONS' => true, diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 0f9ca9bab3..d0e5dfb5f4 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -294,7 +294,7 @@ class acp_prune $template->assign_block_vars('users', array( 'USERNAME' => $usernames[$user_id], 'USER_ID' => $user_id, - 'U_PROFILE' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx, 'mode=viewprofile&u=' . $user_id), + 'U_PROFILE' => get_username_string('profile', $user_id, $usernames[$user_id]), 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', )); } diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index a023bced0a..06f83b2775 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -649,8 +649,8 @@ class auth_admin extends \phpbb\auth\auth { $template->assign_block_vars('role_mask.users', array( 'USER_ID' => $row['user_id'], - 'USERNAME' => $row['username'], - 'U_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u={$row['user_id']}")) + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username']), + 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'])) ); } $db->sql_freeresult($result); diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 06f27655ae..e2d6cd15c9 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -294,8 +294,8 @@ function mcp_post_details($id, $mode, $action) 'REPORT_ID' => $row['report_id'], 'REASON_TITLE' => $row['reason_title'], 'REASON_DESC' => $row['reason_description'], - 'REPORTER' => ($row['user_id'] != ANONYMOUS) ? $row['username'] : $user->lang['GUEST'], - 'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']) : '', + 'REPORTER' => get_username_string('username', $row['user_id'], $row['username']), + 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username']), 'USER_NOTIFY' => ($row['user_notify']) ? true : false, 'REPORT_TIME' => $user->format_date($row['report_time']), 'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])), @@ -354,11 +354,11 @@ function mcp_post_details($id, $mode, $action) foreach ($users_ary as $user_id => $user_row) { $template->assign_block_vars('userrow', array( - 'USERNAME' => ($user_id == ANONYMOUS) ? $user->lang['GUEST'] : $user_row['username'], + 'USERNAME' => get_username_string('username', $user_id, $user_row['username']), 'NUM_POSTS' => $user_row['postings'], 'L_POST_S' => ($user_row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'], - 'U_PROFILE' => ($user_id == ANONYMOUS) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id), + 'U_PROFILE' => get_username_string('profile', $user_id, $user_row['username']), 'U_SEARCHPOSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user_id . '&sr=topics')) ); } diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index d396d004dc..86738717ba 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -96,9 +96,9 @@ class mcp_warn 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '', - 'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USERNAME_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + 'U_USER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'WARNING_TIME' => $user->format_date($row['user_last_warning']), 'WARNINGS' => $row['user_warnings'], @@ -118,9 +118,9 @@ class mcp_warn 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '', - 'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USERNAME_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + 'U_USER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'WARNING_TIME' => $user->format_date($row['warning_time']), 'WARNINGS' => $row['user_warnings'], @@ -167,9 +167,9 @@ class mcp_warn 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '', - 'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USERNAME_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + 'U_USER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'WARNING_TIME' => $user->format_date($row['user_last_warning']), 'WARNINGS' => $row['user_warnings'], diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 8db2fef2a3..681cc0df36 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1569,7 +1569,7 @@ switch ($mode) 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, 'S_GROUP_LEADER' => $is_leader, - 'U_VIEW_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id)) + 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username'])) ); if (isset($cp_row['row']) && sizeof($cp_row['row'])) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 596272636a..4a1c6202e5 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1175,7 +1175,7 @@ while ($row = $db->sql_fetchrow($result)) 'user_colour' => $row['user_colour'], 'online' => false, - 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id"), + 'profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', From db6e5a19f2f812012fa15047aa97e74608bff34c Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 26 Mar 2014 17:13:46 +0100 Subject: [PATCH 2/6] [ticket/7707] Remove unnecessary variables PHPBB3-7707 --- phpBB/includes/acp/acp_main.php | 4 +--- phpBB/includes/mcp/mcp_warn.php | 9 --------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 4512905539..542a8c549b 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -40,12 +40,10 @@ class acp_main $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $perm_from = get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']); - $template->assign_vars(array( 'S_RESTORE_PERMISSIONS' => true, 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'), - 'PERM_FROM' => $perm_from, + 'PERM_FROM' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')), )); diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 86738717ba..e8835dfbd0 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -96,9 +96,6 @@ class mcp_warn 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'WARNING_TIME' => $user->format_date($row['user_last_warning']), 'WARNINGS' => $row['user_warnings'], @@ -118,9 +115,6 @@ class mcp_warn 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'WARNING_TIME' => $user->format_date($row['warning_time']), 'WARNINGS' => $row['user_warnings'], @@ -167,9 +161,6 @@ class mcp_warn 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'WARNING_TIME' => $user->format_date($row['user_last_warning']), 'WARNINGS' => $row['user_warnings'], From 0edfcc5a28d9e13aa2f6e758bbfe0281e345ab27 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 29 Mar 2014 15:43:49 +0100 Subject: [PATCH 3/6] [ticket/7707] Add get_username_string() once more PHPBB3-7707 --- phpBB/phpbb/notification/type/admin_activate_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php index 426da4db03..62ea759a98 100644 --- a/phpBB/phpbb/notification/type/admin_activate_user.php +++ b/phpBB/phpbb/notification/type/admin_activate_user.php @@ -142,7 +142,7 @@ class admin_activate_user extends \phpbb\notification\type\base */ public function get_url() { - return append_sid($this->phpbb_root_path . 'memberlist.' . $this->php_ext, "mode=viewprofile&u={$this->item_id}"); + return $this->user_loader->get_username($this->item_id, 'profile'); } /** From 825077073bd173f43178e00da2d6f76c4c26b8a3 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 29 Mar 2014 15:49:31 +0100 Subject: [PATCH 4/6] [ticket/7707] Remove unnecessary variables PHPBB3-7707 --- phpBB/viewtopic.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4a1c6202e5..fc3a7321f0 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1110,7 +1110,6 @@ while ($row = $db->sql_fetchrow($result)) 'rank_image' => '', 'rank_image_src' => '', 'sig' => '', - 'profile' => '', 'pm' => '', 'email' => '', 'jabber' => '', @@ -1175,7 +1174,6 @@ while ($row = $db->sql_fetchrow($result)) 'user_colour' => $row['user_colour'], 'online' => false, - 'profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', @@ -1615,7 +1613,6 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '', 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '', - 'U_PROFILE' => $user_cache[$poster_id]['profile'], 'U_SEARCH' => $user_cache[$poster_id]['search'], 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '', 'U_EMAIL' => $user_cache[$poster_id]['email'], From 908057301c023a7d5efcd4aed0e8b8d4c793f15b Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 1 Apr 2014 22:03:59 +0200 Subject: [PATCH 5/6] [ticket/7707] Add comma to last entry of arrays PHPBB3-7707 --- phpBB/includes/acp/auth.php | 4 ++-- phpBB/memberlist.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 06f83b2775..5404efded3 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -650,8 +650,8 @@ class auth_admin extends \phpbb\auth\auth $template->assign_block_vars('role_mask.users', array( 'USER_ID' => $row['user_id'], 'USERNAME' => get_username_string('username', $row['user_id'], $row['username']), - 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'])) - ); + 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username']), + )); } $db->sql_freeresult($result); } diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 681cc0df36..1669deaec6 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1569,8 +1569,8 @@ switch ($mode) 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, 'S_GROUP_LEADER' => $is_leader, - 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username'])) - ); + 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username']), + )); if (isset($cp_row['row']) && sizeof($cp_row['row'])) { From 8f525e1ef5777c1dc77d7eb4d43039c5dd059f88 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 4 Apr 2014 23:48:14 +0200 Subject: [PATCH 6/6] [ticket/7707] Fix undefined variable: perm_from PHPBB3-7707 --- phpBB/includes/acp/acp_main.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 542a8c549b..4512905539 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -40,10 +40,12 @@ class acp_main $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); + $perm_from = get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']); + $template->assign_vars(array( 'S_RESTORE_PERMISSIONS' => true, 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'), - 'PERM_FROM' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), + 'PERM_FROM' => $perm_from, 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')), ));