Page 3 of 5

Posted: Thu Apr 14, 2005 9:01 pm
by M.O.B.
This is an excellent MOD! Thanks!

Below I included an EasyMOD version that will work well if in case you also installed Admin Voting 1.1.8 before installing this MOD.

Just want to let you know that most templates usually point to their own gif images. What you should do is just rename the template in the install file below so it points to your template or if you have both subSilver and other Template(s), then you should make all templates point to the subSilver gif images directory. (This is what I did since I have both subSilver and Odyssey on my site.) :D

Code: Select all

#############################################################
## MOD Title: Colour on poll results
## MOD Author: Manipe < admin@manipef1.com > (N/A) http://www.manipef1.com 
## MOD Description: Instead of the standard results images on the poll results, this hack shows colour on the results of a poll. Different colours are given to each range of percentages. Also it gives a certain colour to the option that you voted for (Default= Purple)
## MOD Version: 1.1.1 
## 
## Installation Level: Easy
## Installation Time: ~5 Minutes 
## Files To Edit: 
##		viewtopic.php
##		templates/subSilver/viewtopic_poll_result.tpl
##		posting.php
##
## Included Files: 
##		update_to_1.1.1.txt
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
## 
##	If you previously installed version 1.0.3 of this MOD, use update_to_1.1.1.txt to update this MOD to the most recent version
##	
############################################################## 
## MOD History: 
##
##
##   2004-12-09 - Version 1.1.1
##      - Forgot to add the code in posting.php
##
##   2004-12-03 - Version 1.1.0
##      - Added a function so that the option that you voted for is given a specific colour
##
##   2004-09-05 - Version 1.0.3
##      - Minor error fixed
##
##   2004-09-04 - Version 1.0.2
##      - Minor error fixed
##
##   2004-08-25 - Version 1.0.1
##      - Some bugs fixed
##
##   2004-08-14 - Version 1.0.0
##      - MOD created
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
# 
#-----[ SQL ]-------------------------------------------
# 
ALTER TABLE phpbb_vote_voters ADD vote_option_id mediumint( 8 ) NULL 

# 
#-----[ OPEN ]--------------------------------------------- 
# 
viewtopic.php

#
#-----[ FIND ]---------------------------------------------
#		
		if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
		{

#
#-----[ AFTER, ADD ]---------------------------------------------
# 
// Colour on Poll Results MOD, By Manipe (Begin)
			$sql1 = "SELECT vote_option_id 
				FROM " . VOTE_USERS_TABLE . " 
				WHERE vote_user_id = '" . $userdata['user_id'] . "' 
				AND vote_id = '" . $vote_id . "'";
			if ( !($result1 = $db->sql_query($sql1)) )
			{
			 	message_die(GENERAL_ERROR, 'Could not obtain user voted information', '', __LINE__, __FILE__, $sql);
			}
			$row1 = $db->sql_fetchrow($result1);
			$voted_option_id =  $row1['vote_option_id'];
			$db->sql_freeresult($result1);
// Colour on Poll Results MOD, By Manipe (End)

#
#-----[ FIND ]---------------------------------------------
# 
				$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;

#
#-----[ REPLACE WITH ]---------------------------------------------
# 
// Colour on Poll Results MOD, By Manipe (Begin)
				$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']);
// Colour on Poll Results MOD, By Manipe (End)

#
#-----[ FIND ]---------------------------------------------
# 
				if ( count($orig_word) )
				{
					$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
				}

#
#-----[ AFTER, ADD ]---------------------------------------------
# 
// Colour on Poll Results MOD, By Manipe (Begin)
				if ($voted_option_id == ($i+1)){
					$vote_color = 'purple';
				}
				else{
					if ( $vote_percent <= 0.3 ){
						$vote_color = 'green';
					}
					else if ( ($vote_percent > 0.3) && ($vote_percent <= 0.6) ){
						$vote_color = 'blue';
					}
					else if ( $vote_percent > 0.6 ){
						$vote_color = 'red';
					}
				}
// Colour on Poll Results MOD, By Manipe (End)

#
#-----[ FIND ]---------------------------------------------
# 
				$template->assign_block_vars("poll_option", array(
					'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)),

#
#-----[ AFTER, ADD ]---------------------------------------------
# 
// Colour on Poll Results MOD, By Manipe (Begin)
					'POLL_OPTION_COLOR' => $vote_color,
// Colour on Poll Results MOD, By Manipe (End)

# 
#-----[ OPEN ]--------------------------------------------- 
# 
posting.php

#
#-----[ FIND ]---------------------------------------------
# 
				$sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip, vote_cast) 
					VALUES ($vote_id, " . $userdata['user_id'] . ", '$user_ip', $vote_option_id)";

#
#-----[ REPLACE WITH ]---------------------------------------------
# 
// Colour on Poll Results MOD, By Manipe (Begin)
				$sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip, vote_cast, vote_option_id) 
					VALUES ($vote_id, " . $userdata['user_id'] . ", '$user_ip', '$vote_option_id')";
// Colour on Poll Results MOD, By Manipe (End)

# 
#-----[ OPEN ]--------------------------------------------- 
# 
templates/subSilver/viewtopic_poll_result.tpl

#
#-----[ FIND ]---------------------------------------------
# 
					<td><img src="templates/subSilver/images/vote_lcap.gif" width="4" alt="" height="12" /></td>
					<td><img src="{poll_option.POLL_OPTION_IMG}" width="{poll_option.POLL_OPTION_IMG_WIDTH}" height="12" alt="{poll_option.POLL_OPTION_PERCENT}" /></td>
					<td><img src="templates/subSilver/images/vote_rcap.gif" width="4" alt="" height="12" /></td>

#
#-----[ REPLACE WITH ]---------------------------------------------
# 
					<td width="{poll_option.POLL_OPTION_IMG_WIDTH}" height="12" bgcolor="{poll_option.POLL_OPTION_COLOR}"><IMG src="images/spacer.gif" height="12"></td>

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 

# EoM

Posted: Sat Sep 17, 2005 1:27 pm
by aeryk
getting error message with poll submit for all users:

Could not insert user_id for poll

DEBUG MODE

INSERT INTO phpbb_vote_voters (vote_id, vote_user_id, vote_user_ip, vote_option_id) VALUES (2, 4, '424376f9', '11')

Line : 500
File : .../posting.php


SQL had been created for this mod...

Posted: Mon Oct 10, 2005 3:24 am
by Arcadius
I installed this mod and everything looks fine but I am currently not able to see the colored bars. I can see little marks where the ends of the bars are supposed to be, but no colored bars themselves. This is using a near black background. Any help?

Posted: Tue Oct 25, 2005 11:11 pm
by sledcrew
Sry.. about this...


I figured it out...

I Should try most stuff before wasting you peoples time..

THanks anyways.

Posted: Sat Jan 28, 2006 2:16 am
by KandelCK1
Does this work with 2.0.17?

Posted: Sat Jan 28, 2006 1:10 pm
by Manipe
KandelCK1 wrote: Does this work with 2.0.17?

It should. BTW, you should update to the latest version, 2.0.19.
Go to the downloads page to get a package to update.

Posted: Tue Feb 07, 2006 6:13 pm
by shadav
I'm using easymod to try and install and it's given me a warning...
1 Warning(s) reported by the SQL Parser

1. Missing semicolon, it might be an indication of further syntax errors, statement: 1


will this be a problem?

Posted: Tue Feb 07, 2006 7:56 pm
by Manipe
shadav wrote: I'm using easymod to try and install and it's given me a warning...
1 Warning(s) reported by the SQL Parser

1. Missing semicolon, it might be an indication of further syntax errors, statement: 1


will this be a problem?

No not at all. That only becomes a problem when more than one SQL statement are executed in the same string.

The new SQL parser can be picky about that, but just run the MOD as normal.

Posted: Tue Feb 07, 2006 9:21 pm
by shadav
ok thank you :)

Posted: Tue Feb 07, 2006 9:22 pm
by shadav
[edit] sorry double posted...pc locked up

Posted: Tue Feb 21, 2006 10:39 pm
by n0ia
I've made some different color vote_lcap.gif, vote_rcap.gif, and voting_bar.gif images if anyone is interested.

I just copied the original, duplicated the layer and did a color overlay of the following:

Red
Blue
Green
Yellow
Purple
Turqoise
Pink

They are PNG images saved with a .gif extension so that they render the transparency correct. Let me know if anyone wants this and I'll give you a link or send it to someone to host.

Posted: Wed Feb 22, 2006 4:14 pm
by Manipe
n0ia wrote: I've made some different color vote_lcap.gif, vote_rcap.gif, and voting_bar.gif images if anyone is interested.

I just copied the original, duplicated the layer and did a color overlay of the following:

Red
Blue
Green
Yellow
Purple
Turqoise
Pink

They are PNG images saved with a .gif extension so that they render the transparency correct. Let me know if anyone wants this and I'll give you a link or send it to someone to host.

Actually, I once started making images like that, but decided against it because my designing skills have a lot to be desired.

Anyway, to cut a long story short, would you like me to introduce them in the package. I would like to have them as it would look better instead of just having colour backgrounds.
Please let me know how you feel.

Posted: Thu Apr 20, 2006 6:31 pm
by rohit4all
Manipe wrote:
rimski wrote:Hi

I have tried to install the colour mod to my forum but I get an error message so have now reverted to the pre install forum.
But could someone just quickly explain what the following code in the instructions mean

#
#-----[ SQL ]-------------------------------------------
#
ALTER TABLE phpbb_vote_voters ADD vote_option_id mediumint( 8 ) NULL


Well basically you have to add the column "vote_option_id" to the "phpbb_vote_voters" table.

You can do it through PhpMyAdmin.



Hey I am newbie, Can u explain it from scratch ?

Posted: Thu Apr 20, 2006 7:57 pm
by Manipe
Do you have phpMyAdmin?

Posted: Thu Apr 20, 2006 8:54 pm
by rohit4all
Yes I have . But I do not know how to create column .