mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12993] Improve get_user_ranks
Explanation in http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=46051 PHPBB3-12993
This commit is contained in:
parent
a82a88b555
commit
8671e40217
5 changed files with 31 additions and 15 deletions
|
@ -1378,7 +1378,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
|
||||||
/**
|
/**
|
||||||
* Get user rank title and image
|
* Get user rank title and image
|
||||||
*
|
*
|
||||||
* @param int $user_rank the current stored users rank id
|
* @param array $user_data the current stored users data
|
||||||
* @param int $user_posts the users number of posts
|
* @param int $user_posts the users number of posts
|
||||||
* @param string &$rank_title the rank title will be stored here after execution
|
* @param string &$rank_title the rank title will be stored here after execution
|
||||||
* @param string &$rank_img the rank image as full img tag is stored here after execution
|
* @param string &$rank_img the rank image as full img tag is stored here after execution
|
||||||
|
@ -1386,9 +1386,21 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
|
||||||
*
|
*
|
||||||
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
|
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
|
||||||
*/
|
*/
|
||||||
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
|
function get_user_rank($user_data, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
|
||||||
{
|
{
|
||||||
global $ranks, $config, $phpbb_root_path, $phpbb_path_helper;
|
global $ranks, $config, $phpbb_root_path, $phpbb_path_helper, $phpbb_dispatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preparing a user's rank before displaying
|
||||||
|
*
|
||||||
|
* @event core.modify_user_rank
|
||||||
|
* @var array user_data Array with user's data
|
||||||
|
* @var int user_posts User_posts to change
|
||||||
|
* @since 3.1.0-RC3
|
||||||
|
*/
|
||||||
|
|
||||||
|
$vars = array('user_data', 'user_posts');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.modify_user_rank', compact($vars)));
|
||||||
|
|
||||||
if (empty($ranks))
|
if (empty($ranks))
|
||||||
{
|
{
|
||||||
|
@ -1396,11 +1408,14 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
|
||||||
$ranks = $cache->obtain_ranks();
|
$ranks = $cache->obtain_ranks();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($user_rank))
|
if (!empty($user_data['user_rank']))
|
||||||
{
|
{
|
||||||
$rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : '';
|
|
||||||
$rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image']) : '';
|
$rank_title = (isset($ranks['special'][$user_data['user_rank']]['rank_title'])) ? $ranks['special'][$user_data['user_rank']]['rank_title'] : '';
|
||||||
$rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $rank_img_src . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';
|
|
||||||
|
$rank_img_src = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_data['user_rank']]['rank_image']) : '';
|
||||||
|
|
||||||
|
$rank_img = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? '<img src="' . $rank_img_src . '" alt="' . $ranks['special'][$user_data['user_rank']]['rank_title'] . '" title="' . $ranks['special'][$user_data['user_rank']]['rank_title'] . '" />' : '';
|
||||||
}
|
}
|
||||||
else if ($user_posts !== false)
|
else if ($user_posts !== false)
|
||||||
{
|
{
|
||||||
|
@ -1420,6 +1435,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare profile data
|
* Prepare profile data
|
||||||
*/
|
*/
|
||||||
|
@ -1431,7 +1447,7 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl
|
||||||
$user_id = $data['user_id'];
|
$user_id = $data['user_id'];
|
||||||
|
|
||||||
$rank_title = $rank_img = $rank_img_src = '';
|
$rank_title = $rank_img = $rank_img_src = '';
|
||||||
get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
get_user_rank($data, (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
||||||
|
|
||||||
if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
|
if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -341,7 +341,7 @@ class mcp_warn
|
||||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
get_user_rank($user_row, $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
||||||
$avatar_img = phpbb_get_user_avatar($user_row);
|
$avatar_img = phpbb_get_user_avatar($user_row);
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
|
@ -490,7 +490,7 @@ class mcp_warn
|
||||||
{
|
{
|
||||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||||
}
|
}
|
||||||
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
get_user_rank($user_row, $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
||||||
$avatar_img = phpbb_get_user_avatar($user_row);
|
$avatar_img = phpbb_get_user_avatar($user_row);
|
||||||
|
|
||||||
// OK, they didn't submit a warning so lets build the page for them to do so
|
// OK, they didn't submit a warning so lets build the page for them to do so
|
||||||
|
|
|
@ -408,7 +408,7 @@ function get_user_information($user_id, $user_row)
|
||||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']);
|
get_user_rank($user_row, $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']);
|
||||||
|
|
||||||
if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -284,7 +284,7 @@ switch ($mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
$rank_title = $rank_img = $rank_img_src = '';
|
$rank_title = $rank_img = $rank_img_src = '';
|
||||||
get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
get_user_rank($row, (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
||||||
|
|
||||||
$template->assign_block_vars('group.user', array(
|
$template->assign_block_vars('group.user', array(
|
||||||
'USER_ID' => $row['user_id'],
|
'USER_ID' => $row['user_id'],
|
||||||
|
@ -1083,7 +1083,7 @@ switch ($mode)
|
||||||
$rank_title = $rank_img = $rank_img_src = '';
|
$rank_title = $rank_img = $rank_img_src = '';
|
||||||
if ($group_row['group_rank'])
|
if ($group_row['group_rank'])
|
||||||
{
|
{
|
||||||
get_user_rank($group_row['group_rank'], false, $rank_title, $rank_img, $rank_img_src);
|
get_user_rank($group_roup, false, $rank_title, $rank_img, $rank_img_src);
|
||||||
|
|
||||||
if ($rank_img)
|
if ($rank_img)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
||||||
$user_cache[$poster_id] = $user_cache_data;
|
$user_cache[$poster_id] = $user_cache_data;
|
||||||
|
|
||||||
get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
get_user_rank($row, false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1238,7 +1238,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
||||||
$user_cache[$poster_id] = $user_cache_data;
|
$user_cache[$poster_id] = $user_cache_data;
|
||||||
|
|
||||||
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
get_user_rank($row, $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
||||||
|
|
||||||
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue