Cache moderator names?

git-svn-id: file:///svn/phpbb/trunk@3060 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-11-18 18:56:27 +00:00
parent 68d4dcf0d3
commit ce40939e60
3 changed files with 95 additions and 86 deletions

View file

@ -111,6 +111,7 @@ define('GROUPS_TABLE', $table_prefix.'groups');
define('ICONS_TABLE', $table_prefix.'icons'); define('ICONS_TABLE', $table_prefix.'icons');
define('LOG_ADMIN_TABLE', $table_prefix.'log_admin'); define('LOG_ADMIN_TABLE', $table_prefix.'log_admin');
define('LOG_MOD_TABLE', $table_prefix.'log_moderator'); define('LOG_MOD_TABLE', $table_prefix.'log_moderator');
define('MODERATOR_TABLE', $table_prefix.'moderator_cache');
define('POSTS_TABLE', $table_prefix.'posts'); define('POSTS_TABLE', $table_prefix.'posts');
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text'); define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs'); define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');

View file

@ -81,41 +81,31 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl
} }
// Obtain list of moderators of each forum // Obtain list of moderators of each forum
// First users, then groups ... broken into two queries
// We could cache this ... certainly into a DB table. Would
// better allow the admin to decide which moderators are
// displayed(?)
function cache_moderators($type = false, $id = false)
{
}
function get_moderators(&$forum_moderators, $forum_id = false) function get_moderators(&$forum_moderators, $forum_id = false)
{ {
global $SID, $db, $acl_options, $phpEx; global $SID, $db, $acl_options, $phpEx;
if (is_array($forum_id) && !empty($forum_id)) if (!empty($forum_id) && is_array($forum_id))
{ {
$forum_sql = 'AND a.forum_id IN (' . implode(', ', $forum_id) . ')'; $forum_sql = 'AND forum_id IN (' . implode(', ', $forum_id) . ')';
} }
else else
{ {
$forum_sql = ( $forum_id ) ? 'AND a.forum_id = ' . $forum_id : ''; $forum_sql = ($forum_id) ? 'AND forum_id = ' . $forum_id : '';
} }
/*
$sql = "SELECT m.forum_id, u.user_id, u.username, g.group_id, g.group_name $sql = 'SELECT *
FROM phpbb_moderators m FROM ' . MODERATOR_TABLE . "
LEFT JOIN phpbb_users u ON u.user_id = m.user_id WHERE display_on_index = 1
LEFT JOIN phpbb_groups g ON g.group_id = m.group_id
WHERE m.display_on_index = 1
$forum_sql"; $forum_sql";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$forum_moderators[$row['forum_id']][] = ( !empty($row['user_id']) ) ? '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>' : '<a href="groupcp.' . $phpEx . $SID . '&amp;g=' . $row['group_id'] . '">' . $row['group_name'] . '</a>'; $forum_moderators[$row['forum_id']][] = (!empty($row['user_id'])) ? '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>' : '<a href="groupcp.' . $phpEx . $SID . '&amp;g=' . $row['group_id'] . '">' . $row['groupname'] . '</a>';
}*/ }
$db->sql_freeresult($result);
/*
$sql = "SELECT a.forum_id, u.user_id, u.username $sql = "SELECT a.forum_id, u.user_id, u.username
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_USERS_TABLE . " a, " . USERS_TABLE . " u FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_USERS_TABLE . " a, " . USERS_TABLE . " u
WHERE a.auth_option_id = o.auth_option_id WHERE a.auth_option_id = o.auth_option_id
@ -129,6 +119,7 @@ function get_moderators(&$forum_moderators, $forum_id = false)
{ {
$forum_moderators[$row['forum_id']][] = '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>'; $forum_moderators[$row['forum_id']][] = '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
} }
$db->sql_freeresult($result);
$sql = "SELECT a.forum_id, g.group_name, g.group_id $sql = "SELECT a.forum_id, g.group_name, g.group_id
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " a, " . GROUPS_TABLE . " g FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " a, " . GROUPS_TABLE . " g
@ -144,7 +135,8 @@ function get_moderators(&$forum_moderators, $forum_id = false)
{ {
$forum_moderators[$row['forum_id']][] = '<a href="groupcp.' . $phpEx . $SID . '&amp;g=' . $row['group_id'] . '">' . $row['group_name'] . '</a>'; $forum_moderators[$row['forum_id']][] = '<a href="groupcp.' . $phpEx . $SID . '&amp;g=' . $row['group_id'] . '">' . $row['group_name'] . '</a>';
} }
$db->sql_freeresult($result);
*/
return; return;
} }
@ -155,11 +147,11 @@ function get_forum_rules($mode, &$rules, &$forum_id)
{ {
global $SID, $auth, $user; global $SID, $auth, $user;
$rules .= ( ( $auth->acl_get('f_post', $forum_id) ) ? $user->lang['Rules_post_can'] : $user->lang['Rules_post_cannot'] ) . '<br />'; $rules .= (($auth->acl_gets('f_post', 'm_', 'a_', $forum_id)) ? $user->lang['Rules_post_can'] : $user->lang['Rules_post_cannot']) . '<br />';
$rules .= ( ( $auth->acl_get('f_reply', $forum_id) ) ? $user->lang['Rules_reply_can'] : $user->lang['Rules_reply_cannot'] ) . '<br />'; $rules .= (($auth->acl_gets('f_reply', 'm_', 'a_', $forum_id)) ? $user->lang['Rules_reply_can'] : $user->lang['Rules_reply_cannot']) . '<br />';
$rules .= ( ( $auth->acl_get('f_edit', $forum_id) ) ? $user->lang['Rules_edit_can'] : $user->lang['Rules_edit_cannot'] ) . '<br />'; $rules .= (($auth->acl_gets('f_edit', 'm_', 'a_', $forum_id)) ? $user->lang['Rules_edit_can'] : $user->lang['Rules_edit_cannot']) . '<br />';
$rules .= ( ( $auth->acl_get('f_delete', $forum_id) || $auth->acl_get('m_delete', $forum_id) ) ? $user->lang['Rules_delete_can'] : $user->lang['Rules_delete_cannot'] ) . '<br />'; $rules .= (($auth->acl_gets('f_delete', 'm_', 'a_', $forum_id) || $auth->acl_get('m_delete', $forum_id)) ? $user->lang['Rules_delete_can'] : $user->lang['Rules_delete_cannot']) . '<br />';
$rules .= ( ( $auth->acl_get('f_attach', $forum_id) ) ? $user->lang['Rules_attach_can'] : $user->lang['Rules_attach_cannot'] ) . '<br />'; $rules .= (($auth->acl_gets('f_attach', 'm_', 'a_', $forum_id)) ? $user->lang['Rules_attach_can'] : $user->lang['Rules_attach_cannot']) . '<br />';
return; return;
} }
@ -193,7 +185,7 @@ function make_jumpbox($action, $forum_id = false)
$right = $row['right_id']; $right = $row['right_id'];
$linefeed = FALSE; $linefeed = FALSE;
if ( ( $auth->acl_get('f_list', $forum_id) || $auth->acl_get('a_') )) if ($auth->acl_gets('f_list', 'm_', 'a_', $forum_id))
{ {
$selected = ($row['forum_id'] == $forum_id) ? ' selected="selected"' : ''; $selected = ($row['forum_id'] == $forum_id) ? ' selected="selected"' : '';

View file

@ -224,6 +224,22 @@ CREATE TABLE phpbb_log_admin (
); );
# --------------------------------------------------------
#
# Table structure for table 'phpbb_moderator_cache'
#
CREATE TABLE phpbb_moderator_cache (
forum_id mediumint(8) unsigned NOT NULL,
user_id mediumint(8) unsigned default NULL,
username char(30) default NULL,
group_id mediumint(8) unsigned default NULL,
groupname char(30) default NULL,
display_on_index tinyint(4) NOT NULL default '1',
KEY display_on_index (display_on_index),
KEY forum_id (forum_id)
)
# -------------------------------------------------------- # --------------------------------------------------------
# #
# Table structure for table 'phpbb_vote_results' # Table structure for table 'phpbb_vote_results'
@ -397,7 +413,7 @@ CREATE TABLE phpbb_sessions (
session_time int(11) DEFAULT '0' NOT NULL, session_time int(11) DEFAULT '0' NOT NULL,
session_ip varchar(40) DEFAULT '0' NOT NULL, session_ip varchar(40) DEFAULT '0' NOT NULL,
session_browser varchar(100) DEFAULT '' NULL, session_browser varchar(100) DEFAULT '' NULL,
session_page varchar(50) DEFAULT '0' NOT NULL, session_page varchar(100) DEFAULT '0' NOT NULL,
PRIMARY KEY (session_id), PRIMARY KEY (session_id),
KEY session_time (session_time) KEY session_time (session_time)
); );