Mandy
modul.php
Code: Alles auswählen
<?php
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
// DB Cache used here
//
// Top Posting Users
//
$template->assign_vars(array(
'L_RANK' => $lang['Rank'],
'L_POINTS' => $lang['Points'],
'L_PERCENTAGE' => $lang['Percent'],
'L_USERNAME' => $lang['Username'],
'L_GRAPH' => $lang['Graph'],
'MODULE_NAME' => $lang['module_name'])
);
$statistics->init_bars();
$sql = "SELECT SUM(quiz_points) as total_quiz_points FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS;
if ( !($result = $stat_db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve users data', '', __LINE__, __FILE__, $sql);
}
$row = $stat_db->sql_fetchrow($result);
$total_points = $row['total_quiz_points'];
$sql = 'SELECT user_id, username, quiz_points
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . ' AND quiz_points > 0
ORDER BY quiz_points DESC
LIMIT ' . $return_limit;
if ( !($result = $stat_db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve users data', '', __LINE__, __FILE__, $sql);
}
$user_count = $stat_db->sql_numrows($result);
$user_data = $stat_db->sql_fetchrowset($result);
$firstcount = $user_data[0]['quiz_points'];
for ($i = 0; $i < $user_count; $i++)
{
$class = ( !($i % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
$statistics->do_math($firstcount, $user_data[$i]['quiz_points'], $total_points);
$template->assign_block_vars('quiz_users', array(
'RANK' => $i+1,
'CLASS' => $class,
'USERNAME' => $user_data[$i]['username'],
'PERCENTAGE' => $statistics->percentage,
'BAR' => $statistics->bar_percent,
'URL' => append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $user_data[$i]['user_id']),
'POINTS' => $user_data[$i]['quiz_points'])
);
}