From 11d8d3455a97bae1945bb578c761eaa67292622f Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 18 Jun 2009 12:59:43 +0000 Subject: [PATCH] Changes to r9617 Fix a template compilation issue, and reshuffle the code. The added template complexity made it more of a problem to check the variables correctly, hence simplification. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9619 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/memberlist.php | 49 +++++++++++-------- .../prosilver/template/memberlist_view.html | 4 +- .../subsilver2/template/memberlist_view.html | 4 +- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index d8e6d99471..08451ac6b2 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -500,7 +500,29 @@ switch ($mode) $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']); - $template->assign_vars(show_profile($member)); + // We need to check if the modules 'zebra', 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links + $zebra_enabled = $user_notes_enabled = $warn_user_enabled = false; + + // Only check if the user is logged in + if ($user->data['is_registered']) + { + if (!class_exists('p_master')) + { + include($phpbb_root_path . 'includes/functions_module.' . $phpEx); + } + $module = new p_master(); + + $module->list_modules('ucp'); + $module->list_modules('mcp'); + + $user_notes_enabled = ($module->loaded('notes', 'user_notes')) ? true : false; + $warn_user_enabled = ($module->loaded('warn', 'warn_user')) ? true : false; + $zebra_enabled = ($module->loaded('zebra')) ? true : false; + + unset($module); + } + + $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); // Custom Profile Fields $profile_fields = array(); @@ -512,23 +534,6 @@ switch ($mode) $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array(); } - // We need to check if the modules 'zebra', 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links - $zebra_enabled = $user_notes_enabled = $warn_user_enabled = false; - - if (!class_exists('p_master')) - { - include($phpbb_root_path . 'includes/functions_module.' . $phpEx); - } - $module = new p_master(); - - $module->list_modules('ucp'); - $module->list_modules('mcp'); - $user_notes_enabled = ($module->loaded('notes', 'user_notes')) ? true : false; - $warn_user_enabled = ($module->loaded('warn', 'warn_user')) ? true : false; - $zebra_enabled = ($module->loaded('zebra')) ? true : false; - - unset($module); - // If the user has m_approve permission or a_user permission, then list then display unapproved posts if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) { @@ -1538,7 +1543,7 @@ page_footer(); /** * Prepare profile data */ -function show_profile($data) +function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false) { global $config, $auth, $template, $user, $phpEx, $phpbb_root_path; @@ -1624,9 +1629,11 @@ function show_profile($data) 'ICQ_STATUS_IMG' => (!empty($data['user_icq'])) ? '' : '', 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, + 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, + 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', - 'U_NOTES' => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', - 'U_WARN' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', + 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', + 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', 'U_EMAIL' => $email, 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 8352583d2a..b9e6f5006d 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -78,9 +78,9 @@
{L_JOINED}:
{JOINED}
{L_VISITED}:
{VISITED}
- +
{L_WARNINGS}:
-
{WARNINGS} [ {L_VIEW_NOTES} | {L_WARN_USER} ]
+
{WARNINGS} [ {L_VIEW_NOTES} | {L_WARN_USER} ]
{L_TOTAL_POSTS}:
{POSTS} | {L_SEARCH_USER_POSTS} diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index 8cfe4d9276..33f229d860 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -66,10 +66,10 @@ {L_VISITED}: {VISITED} - + {L_WARNINGS}: - {WARNINGS}
[ {L_VIEW_NOTES} | {L_WARN_USER} ] + {WARNINGS}
[ {L_VIEW_NOTES} | {L_WARN_USER} ]