Ability to fetch moderators with get_moderators() even if load_moderators setting is off. (Bug #35955)

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9640 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-06-21 09:36:13 +00:00
parent 9d56fa5e70
commit 050567483f
5 changed files with 28 additions and 22 deletions

View file

@ -135,6 +135,7 @@
<li>[Change] Changed behaviour of group_create() function to support specifying additional group columns</li> <li>[Change] Changed behaviour of group_create() function to support specifying additional group columns</li>
<li>[Change] Hide avatar when avatar-type is not allowed (Bug #46785 - Patch by cYbercOsmOnauT and nickvergessen)</li> <li>[Change] Hide avatar when avatar-type is not allowed (Bug #46785 - Patch by cYbercOsmOnauT and nickvergessen)</li>
<li>[Change] INCLUDEPHP not depending on phpbb_root_path (Bug #45805 - Patch by nickvergessen)</li> <li>[Change] INCLUDEPHP not depending on phpbb_root_path (Bug #45805 - Patch by nickvergessen)</li>
<li>[Change] Ability to fetch moderators with get_moderators() even if load_moderators setting is off. (Bug #35955)</li>
<li>[Feature] Add confirmation for deactivating styles (Bug #14304 - Patch by leviatan21)</li> <li>[Feature] Add confirmation for deactivating styles (Bug #14304 - Patch by leviatan21)</li>
<li>[Feature] Backported 3.2 captcha plugins.</li> <li>[Feature] Backported 3.2 captcha plugins.</li>
<li>[Feature] Introduced new ACM plugins: <li>[Feature] Introduced new ACM plugins:

View file

@ -663,14 +663,7 @@ function get_moderators(&$forum_moderators, $forum_id = false)
{ {
global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth; global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth;
// Have we disabled the display of moderators? If so, then return $forum_id_ary = array();
// from whence we came ...
if (!$config['load_moderators'])
{
return;
}
$forum_sql = '';
if ($forum_id !== false) if ($forum_id !== false)
{ {
@ -679,13 +672,8 @@ function get_moderators(&$forum_moderators, $forum_id = false)
$forum_id = array($forum_id); $forum_id = array($forum_id);
} }
// If we don't have a forum then we can't have a moderator // Exchange key/value pair to be able to faster check for the forum id existence
if (!sizeof($forum_id)) $forum_id_ary = array_flip($forum_id);
{
return;
}
$forum_sql = 'AND m.' . $db->sql_in_set('forum_id', $forum_id);
} }
$sql_array = array( $sql_array = array(
@ -706,17 +694,25 @@ function get_moderators(&$forum_moderators, $forum_id = false)
), ),
), ),
'WHERE' => "m.display_on_index = 1 $forum_sql", 'WHERE' => 'm.display_on_index = 1',
); );
// We query every forum here because for caching we should not have any parameter.
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql, 3600); $result = $db->sql_query($sql, 3600);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$f_id = (int) $row['forum_id'];
if (!isset($forum_id_ary[$f_id]))
{
continue;
}
if (!empty($row['user_id'])) if (!empty($row['user_id']))
{ {
$forum_moderators[$row['forum_id']][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
} }
else else
{ {
@ -724,11 +720,11 @@ function get_moderators(&$forum_moderators, $forum_id = false)
if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))
{ {
$forum_moderators[$row['forum_id']][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>'; $forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>';
} }
else else
{ {
$forum_moderators[$row['forum_id']][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>'; $forum_moderators[$f_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
} }
} }
} }

View file

@ -1183,7 +1183,10 @@ if (sizeof($post_data['poll_options']) && $post_data['poll_title'])
// Forum moderators? // Forum moderators?
$moderators = array(); $moderators = array();
if ($config['load_moderators'])
{
get_moderators($moderators, $forum_id); get_moderators($moderators, $forum_id);
}
// Generate smiley listing // Generate smiley listing
generate_smilies('inline', $forum_id); generate_smilies('inline', $forum_id);

View file

@ -135,8 +135,11 @@ if ($forum_data['left_id'] != $forum_data['right_id'] - 1)
else else
{ {
$template->assign_var('S_HAS_SUBFORUM', false); $template->assign_var('S_HAS_SUBFORUM', false);
if ($config['load_moderators'])
{
get_moderators($moderators, $forum_id); get_moderators($moderators, $forum_id);
} }
}
// Dump out the page header and load viewforum template // Dump out the page header and load viewforum template
page_header($user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']); page_header($user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']);

View file

@ -550,7 +550,10 @@ generate_forum_rules($topic_data);
// Moderators // Moderators
$forum_moderators = array(); $forum_moderators = array();
if ($config['load_moderators'])
{
get_moderators($forum_moderators, $forum_id); get_moderators($forum_moderators, $forum_id);
}
// This is only used for print view so ... // This is only used for print view so ...
$server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/'; $server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';