aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2002-02-12 22:57:03 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2002-02-12 22:57:03 +0000
commit6bbd11cad59049d2a5bc75905ed2cd9f24a9d10a (patch)
tree5d2c2e0bfff99f23bbe35cf79e50c2236f606af0
parenta8f0ef6285d0d050f88f7b05db7af13910c28744 (diff)
downloadforums-6bbd11cad59049d2a5bc75905ed2cd9f24a9d10a.tar
forums-6bbd11cad59049d2a5bc75905ed2cd9f24a9d10a.tar.gz
forums-6bbd11cad59049d2a5bc75905ed2cd9f24a9d10a.tar.bz2
forums-6bbd11cad59049d2a5bc75905ed2cd9f24a9d10a.tar.xz
forums-6bbd11cad59049d2a5bc75905ed2cd9f24a9d10a.zip
Bu**er bu**er bu**er damn damn damn ...
git-svn-id: file:///svn/phpbb/trunk@2117 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/viewtopic.php84
1 files changed, 46 insertions, 38 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index cb071384f2..7f6a506b1c 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -668,40 +668,28 @@ if( !empty($forum_row['topic_vote']) )
WHERE vd.topic_id = $topic_id
AND vr.vote_id = vd.vote_id
ORDER BY vr.vote_option_id ASC";
- if( !($result = $db->sql_query($sql)) )
+ if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain vote data for this topic", "", __LINE__, __FILE__, $sql);
}
- if( $row = $db->sql_fetchrow($result) )
+ if( $vote_options = $db->sql_numrows($result) )
{
- $poll_id = $row['vote_id'];
- $poll_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $row['vote_text']) : $row['vote_text'];
- $poll_length = $row['vote_length'];
- $poll_start = $row['vote_start'];
+ $vote_info = $db->sql_fetchrowset($result);
- $option_id = array();
- $option_text = array();
- $option_result = array();
-
- do
- {
- $option_id[] = $row['vote_option_id'];
- $option_text[] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $row['vote_option_text']) : $row['vote_option_text'];
- $option_result[] = $row['vote_result'];
- }
- while ( $row = $db->sql_fetchrow($result) );
+ $vote_id = $vote_info[0]['vote_id'];
+ $vote_title = $vote_info[0]['vote_text'];
$sql = "SELECT vote_id
FROM " . VOTE_USERS_TABLE . "
- WHERE vote_id = $poll_id
+ WHERE vote_id = $vote_id
AND vote_user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
+ if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain user vote data for this topic", "", __LINE__, __FILE__, $sql);
}
- $user_voted = ( $row = $db->sql_fetchrow($result) ) ? true : 0;
+ $user_voted = ( $db->sql_numrows($result) ) ? TRUE : 0;
if( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
{
@@ -712,37 +700,46 @@ if( !empty($forum_row['topic_vote']) )
$view_result = 0;
}
- $poll_expired = ( $poll_length ) ? ( ( $poll_start + $poll_length < time() ) ? TRUE : 0 ) : 0;
+ $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
if( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_row['topic_status'] == TOPIC_LOCKED )
{
+
+ $template->set_filenames(array(
+ "pollbox" => "viewtopic_poll_result.tpl")
+ );
+
$vote_results_sum = 0;
+
for($i = 0; $i < $vote_options; $i++)
{
$vote_results_sum += $vote_info[$i]['vote_result'];
}
- $template->set_filenames(array(
- "pollbox" => "viewtopic_poll_result.tpl")
- );
-
$vote_graphic = 0;
$vote_graphic_max = count($images['voting_graphic']);
- for($i = 0; $i < count($option_id); $i++)
+ for($i = 0; $i < $vote_options; $i++)
{
- $vote_percent = ( $vote_results_sum > 0 ) ? $option_result[$i] / $vote_results_sum : 0;
+ $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']);
+ }
$template->assign_block_vars("poll_option", array(
- "POLL_OPTION_CAPTION" => $option_text[$i],
- "POLL_OPTION_RESULT" => $option_result[$i],
- "POLL_OPTION_PERCENT" => sprintf("%.1d%%", ( $vote_percent * 100 )),
+ "POLL_OPTION_CAPTION" => $vote_info[$i]['vote_option_text'],
+ "POLL_OPTION_RESULT" => $vote_info[$i]['vote_result'],
+ "POLL_OPTION_PERCENT" => sprintf("%.1d%%", ($vote_percent * 100)),
- "POLL_OPTION_IMG" => $images['voting_graphic'][$vote_graphic],
- "POLL_OPTION_IMG_WIDTH" => round($vote_percent * $board_config['vote_graphic_length']))
+ "POLL_OPTION_IMG" => $vote_graphic_img,
+ "POLL_OPTION_IMG_WIDTH" => $vote_graphic_length)
);
-
- $vote_graphic = ( $vote_graphic < $vote_graphic_max - 1 ) ? $vote_graphic + 1 : 0;
}
$template->assign_vars(array(
@@ -757,11 +754,16 @@ if( !empty($forum_row['topic_vote']) )
"pollbox" => "viewtopic_poll_ballot.tpl")
);
- for($i = 0; $i < count($option_id); $i++)
+ for($i = 0; $i < $vote_options; $i++)
{
+ if( count($orig_word) )
+ {
+ $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
+ }
+
$template->assign_block_vars("poll_option", array(
- "POLL_OPTION_ID" => $option_id[$i],
- "POLL_OPTION_CAPTION" => $option_text[$i])
+ "POLL_OPTION_ID" => $vote_info[$i]['vote_option_id'],
+ "POLL_OPTION_CAPTION" => $vote_info[$i]['vote_option_text'])
);
}
@@ -775,14 +777,20 @@ if( !empty($forum_row['topic_vote']) )
$s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '"><input type="hidden" name="mode" value="vote">';
}
+ if( count($orig_word) )
+ {
+ $vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
+ }
+
$template->assign_vars(array(
- "POLL_QUESTION" => $poll_title,
+ "POLL_QUESTION" => $vote_title,
"S_HIDDEN_FIELDS" => ( !empty($s_hidden_fields) ) ? $s_hidden_fields : "",
"S_VOTE_ACTION" => append_sid("posting.$phpEx?" . POST_TOPIC_URL . "=$topic_id"))
);
$template->assign_var_from_handle("POLL_DISPLAY", "pollbox");
+
}
}