set_filenames(array(
'body' => 'staff_body.tpl')
);
// forums
// $sql = "SELECT ug.user_id, f.forum_id, f.forum_name
// FROM " . FORUMS_TABLE . " f, " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
// LEFT JOIN " . USER_GROUP_TABLE . " ug2 ON ug2.user_id = " . $userdata['user_id'] . "
// LEFT JOIN " . AUTH_ACCESS_TABLE . " aa2 ON aa2.group_id = ug2.group_id AND aa2.auth_view = " . TRUE . "
// WHERE aa.auth_mod = " . TRUE . "
// AND ug.group_id = aa.group_id
// AND f.forum_id = aa.forum_id
// AND ( f.auth_view <= '.$auth.'
// OR aa2.auth_view = " . TRUE . ")
// GROUP BY ug.user_id, ug2.user_id
// ORDER BY ug.user_id";
$sql = "SELECT ug.user_id, f.forum_id, f.forum_name
FROM ".AUTH_ACCESS_TABLE." aa, ".USER_GROUP_TABLE." ug, ".FORUMS_TABLE." f
WHERE aa.auth_mod = " . TRUE . "
AND ug.group_id = aa.group_id
AND f.forum_id = aa.forum_id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not query forums.', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$forum_id = $row['forum_id'];
$staff2[$row['user_id']][$row['forum_id']] = 'ø '.$row['forum_name'].'
';
}
//main
$sql = "SELECT * FROM ".USERS_TABLE."
WHERE user_level >= 2
ORDER BY user_level = 3, user_level = 4";
if ( !($results = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user information.', '', __LINE__, __FILE__, $sql);
}
while($staff = $db->sql_fetchrow($results))
{
if ( $staff['user_avatar'] )
{
switch( $staff['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$avatar = ( $board_config['allow_avatar_upload'] ) ? '' : '';
break;
case USER_AVATAR_REMOTE:
$avatar = ( $board_config['allow_avatar_remote'] ) ? '' : '';
break;
case USER_AVATAR_GALLERY:
$avatar = ( $board_config['allow_avatar_local'] ) ? '' : '';
break;
}
}
else
{
$avatar = '';
}
$level = ( $staff['user_level'] == 2 ) ? ''.$lang['Admin'].'' : '';
$level .= ( $staff['user_level'] == 9 ) ? ''.$lang['Junior'].'' : '';
$level .= ( $staff['user_level'] == 4 ) ? ''.$lang['Super'].'' : '';
$level .= ( $staff['user_level'] == 3 ) ? ''.$lang['Mod'].'' : '';
$forums = '';
if ( !empty($staff2[$staff['user_id']]) )
{
asort($staff2[$staff['user_id']]);
$forums = implode(' ',$staff2[$staff['user_id']]);
}
$regdate = $staff['user_regdate'];
$nukedate = strtotime($regdate);
$memberdays = max(1, round( ( time() - $nukedate ) / 86400 ));
$posts_per_day = $staff['user_posts'] / $memberdays;
if ( $staff['user_posts'] != 0 )
{
$total_posts = get_db_stat('postcount');
$percentage = ( $total_posts ) ? min(100, ($staff['user_posts'] / $total_posts) * 100) : 0;
}
else
{
$percentage = 0;
}
$user_id = $staff['user_id'];
$sql = "SELECT post_time, post_id FROM ".POSTS_TABLE." WHERE poster_id = " . $user_id . " ORDER BY post_time DESC LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error getting user last post time', '', __LINE__, __FILE__, $post_time_sql);
}
$row = $db->sql_fetchrow($result);
$last_post = ( isset($row['post_time']) ) ? ''.create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']).'' : $lang['None'];
$mailto = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $staff['user_id']) : 'mailto:' . $staff['user_email'];
$mail = ( $staff['user_email'] ) ? '' : '';
$pmto = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$staff[user_id]");
$pm = '';
$msn = ( $staff['user_msnm'] ) ? '' : '';
$yim = ( $staff['user_yim'] ) ? '' : '';
$aim = ( $staff['user_aim'] ) ? '' : '';
$icq = ( $staff['user_icq'] ) ? '' : '';
$www = ( $staff['user_website'] ) ? '' : '';
$sql = "SELECT * FROM " . RANKS_TABLE . " ORDER BY rank_special, rank_min";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
}
$ranksrow = array();
while ( $row = $db->sql_fetchrow($result) )
{
$ranksrow[] = $row;
}
$db->sql_freeresult($result);
$rank = '';
$rank_image = '';
if ( $staff['user_rank'] )
{
for($j = 0; $j < count($ranksrow); $j++)
{
if ( $staff['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
{
$rank = $ranksrow[$j]['rank_title'];
$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '
' : '';
}
}
}
else
{
for($j = 0; $j < count($ranksrow); $j++)
{
if ( $staff['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
{
$rank = $ranksrow[$j]['rank_title'];
$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '
' : '';
}
}
}
$template->assign_block_vars('staff', array(
'AVATAR' => $avatar,
'RANK' => $rank,
'RANK_IMAGE' => $rank_image,
'U_NAME' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$staff[user_id]"),
'NAME' => CheckUsernameColor($staff['user_color_gc'], $staff['username']),
'LEVEL' => $level,
'FORUMS' => $forums,
'JOINED' => $staff['user_regdate'],
'PERIOD' => sprintf($lang['Period'], $memberdays),
'POSTS' => $staff['user_posts'],
'POST_DAY' => sprintf($lang['User_post_day_stats'], $posts_per_day),
'POST_PERCENT' => sprintf($lang['User_post_pct_stats'], $percentage),
'LAST_POST' => $last_post,
'MAIL' => $mail,
'PM' => $pm,
'MSN' => $msn,
'YIM' => $yim,
'AIM' => $aim,
'ICQ' => $icq,
'WWW' => $www)
);
}
$template->assign_vars(array(
'L_AVATAR' => $lang['Avatar'],
'L_USERNAME' => $lang['Username'],
'L_FORUMS' => $lang['Forums'],
'L_POSTS' => $lang['Posts'],
'L_JOINED' => $lang['Joined'],
'L_EMAIL' => $lang['Email'],
'L_PM' => $lang['Private_Message'],
'L_MESSENGER' => $lang['Messenger'],
'L_WWW' => $lang['Website'])
);
$template->pparse('body');
include('includes/page_tail.'.$phpEx);
?>