Ich arbeite immernoch an meiner Version von php_fetch_all im Bereich polls.php.
Als Erweiterung möchte ich, daß das Ergebnis der Umfrage angezeigt wird, wenn: der User nicht angemeldet ist, der Poll beendet ist oder er schon abgestimmt hat.
Das Problem: Bei mir zeigt er garnix an. Ich habe folgende polls_on_index.php gebaut:
Code: Alles auswählen
<?
define ('IN_PHPBB', true);
define('HEADER_INC', false);
$phpbb_root_path = '../forum/';
if (!file_exists($phpbb_root_path . 'extension.inc'))
{
die ('<tt><b>phpBB Fetch All:</b>
$phpbb_root_path is wrong and does not point to your forum.</tt>');
}
include_once ('extension.inc');
include_once ('common.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
include($phpbb_root_path. 'mods/phpbb_fetch_all/polls.php');
$vote = phpbb_fetch_poll_bt(56);
if ($vote)
{
if ($user_voted OR $poll_expired OR !$is_auth['auth_vote'] OR $forum_topic_data['topic_status'] = TOPIC_LOCKED )
{
echo'<table cellspacing="0" cellpadding="2" border="0" width="100%">
<tr>
<td align="center" class="textnormalohnerahmen" width="100%">' . $vote['vote_text'] . '</td>
</tr><tr><td>
<table cellspacing="0" cellpadding="0" border="0">';
$vote_results_sum = 0;
for($i = 0; $i < $vote_options; $i++)
{
$vote_results_sum += $vote_info[$i]['vote_result'];
}
$vote_graphic = 0;
$vote_graphic_max = count($images['voting_graphic']);
for($i = 0; $i < $vote_options; $i++)
{
$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
if ( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$vote_percent_self = sprintf("%.1d%%", ($vote_percent * 100));
echo' <tr>
<td colspan="4">' . $vote_info[$i]['vote_option_text'] . '</td>
</tr>
<tr>
<td><img src="' . $phpbb_root_path . 'templates/AdInfinitum/images/vote_lcap.gif" width="4" alt="" height="12" ></td>
<td><img src="' . $phpbb_root_path . 'templates/AdInfinitum/images/voting_bar.gif" width="' . $vote_graphic_length . ' " height="12" alt="'. $vote_percent_self .'" ></td>
<td><img src="' . $phpbb_root_path . 'templates/AdInfinitum/images/vote_rcap.gif" width="4" alt="" height="12" ></td>
<td>' . $vote_percent_self . '</td>
</tr>';
}
echo'</table>
</td>
</tr>
<tr>
<td class="textnormalohnerahmen" align="center"><a href="' . $phpbb_root_path . 'viewtopic.php?t=56">Zum Thread im Forum</a>
</td>
</tr>
</table>';
}
else
{
echo '<div class="textnormalohnerahmen">'.$vote['vote_text'].'</div>';
echo '<form method="post" action="' . $phpbb_root_path . 'posting.php?t=' . $vote['topic_id'] . '">';
for ($i = 0; $i < count($vote['options']); $i++)
{
echo '<div class="textnormalohnerahmen"><input type="radio" name="vote_id" value="'.$vote['options'][$i]['vote_option_id'] . '">'.$vote['options'][$i]['vote_option_text'].'</div>';
}
if ($userdata['session_logged_in'])
{
echo'<input type="submit" class="mainoption" name="submit" value="' . $lang['Submit_vote'] . '">';
echo'<input type="hidden" name="topic_id" value="' . $vote['topic_id'] . '">';
echo'<input type="hidden" name="mode" value="vote">';
}
else
{
echo'<div class="textnormalohnerahmen" align="center"><span class="gensmall">' . $lang['Rules_vote_cannot'] . '</span></div>';
}
echo '</form>';
}
echo '<table width="100%">
<tr>
<td align="center" class="textnormalohnerahmen">
Nur im Forum registrierte und angemeldete User können abstimmen
</td>
</tr>
</table>';
}
phpbb_disconnect();
?>Code: Alles auswählen
function phpbb_fetch_poll_bt($topic_id = null)
{
global $CFG;
if (!isset($topic_id))
{
return;
}
$sql = 'SELECT f.*, p.*, pt.*, t.*, u.*, vv.*, vr.*, vd.*
FROM ' . TOPICS_TABLE . ' AS t,
' . USERS_TABLE . ' AS u,
' . POSTS_TEXT_TABLE . ' AS pt,
' . POSTS_TABLE . ' AS p,
' . FORUMS_TABLE . ' AS f,
' . VOTE_DESC_TABLE . ' AS vd,
' . VOTE_VOTERS . ' AS vv,
' . VOTE_RESULTS . ' AS vr
WHERE vd.topic_id = ' . $topic_id . '
AND t.topic_poster = u.user_id
AND t.topic_first_post_id = pt.post_id
AND t.topic_first_post_id = p.post_id
AND t.topic_status <> 1
AND t.topic_status <> 2
AND t.topic_vote = 1
AND t.forum_id = f.forum_id
AND t.topic_id = vd.topic_id
AND u.user_id = vv.vote_user_id
AND vr.vote_result = vr.vote_result';
$sql .= '
ORDER BY p.post_time DESC
LIMIT 0,1';
$result = phpbb_fetch_row($sql);
if ($result)
{
//
// perform an auth check if requested
//
if ($CFG['auth_check'])
{
phpbb_get_auth_list();
if (!in_array($result['forum_id'], $CFG['auth_list']))
{
return;
}
}
$sql = 'SELECT *
FROM ' . VOTE_RESULTS_TABLE . '
WHERE vote_id = ' . $result['vote_id'] . '
ORDER BY vote_option_id';
$result['options'] = phpbb_fetch_rows($sql);
}
return $result;
} Hat jemand schon diese Erweiterung gebaut? Dann muß ich mich da nicht durchgraben, oder jemand eine Idee wo ich hier die Fehler mache?
Dankebar
EnzephaloN