Portal Polls Upgrade

Hulp nodig bij een modificaties of op zoek naar een MOD? Bekijk ons archief. Support wordt helaas niet meer verleend.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
Gebruikersavatar
eXo
Berichten: 234
Lid geworden op: 08 jun 2004, 09:50
Locatie: W`veen
Contacteer:

Portal Polls Upgrade

Bericht door eXo » 19 jul 2004, 20:50

Graag zou ik de volgende Mod willen op mijn ezportal.
Nu werkt hij niet op 2.0.10. Dit is de error die ik krijg:
Ik zelf zie niet wat er fout zit. Mischien zien jullie het of hebben jullie er een die wel werkt met .10?
Don`t bother als het moeilijk is ;)

Code: Selecteer alles

Couldn't obtain poll information.

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '9 AND t.topic_status <> 1 AND t.topic_status <> 2 AND 

SELECT t.*, vd.* FROM topics AS t, vote_desc AS vd WHERE t.forum_id = 7,9 AND t.topic_status <> 1 AND t.topic_status <> 2 AND t.topic_vote = 1 AND t.topic_id = vd.topic_id ORDER BY t.topic_time DESC LIMIT 0,1

Line : 753
File : /home/never/public_html/forum/portal.php

Code: Selecteer alles

#################################################################
## 
## Title: Portal Polls Upgrade (Add-on for Smartor's EzPortal)
## Version: 2.0	2003-10-27
## Author: vgan <transflux@msn.com> (Steve Cvar)
## Description: Alters the display and behavior of the Poll Block.
##		If a user has already voted, graphic bars are shown
##		with results similar to the normal Topic View.	
##
##	*Some code based on Nutzy's Nutport - http://blizzhackers.com
##
##	NOTE: Tested on phpBB v. 2.0.4 - 2.0.6 
##	      Verified on Subsilver (subBlack, smartDark,and smartBlue require extra step at end)						
##
## Installation Level: 	Easy
## Installation Time: 	10 Minutes
##
## Files To Edit: 2
##	portal.php
##	templates/subSilver/portal_body.tpl
##
## Included Files: 2
##	templates/subSilver/portal_poll_ballot.tpl
##	templates/subSilver/portal_poll_result.tpl
##
## MOD Copyright: 2003 Steve Cvar
##
#################################################################
## This MOD is released under the GPL License.
## Intellectual Property is retained by the MOD Author(s) listed above
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
##
## Revision History:
##
## 2003-08-10 V. 1.0
##    - Release! 
##
## 2003-08-11 V. 1.1
##    - Adjusted POLL_OPTION_IMG_WIDTH to /1 and removed the Excess middle images.  --thx to dante!
##    - Added Link to topic on results view. - thx to dante and Frold
##    - Changed all the font classes to gensmall. - Request from Superform
##
## 2003-08-12 v. 1.2
##    - Adjusted colspan in portal_poll_result.tpl - thx dante
##
## 2003-10-27 v. 2.0
##    - Adapted code to utilize default EZportal poll forum config
##    - Fixed issue where script would break on newest post without poll
##    - User not logged in link now redirects properly
##    - Cleaned up templates
##    - Defined smaller vote graphic length and made it easier to change    
##
#################################################################
## Demo Forum: http://sonicforum.com  <-- Not for suport, Demo Only
#################################################################


#
#-----[ OPEN ]------------------------------------------
#
portal.php

#
#-----[ FIND ]-----------------------------------
#


//
// Fetch Poll
//
$fetchpoll = phpbb_fetch_poll($CFG['poll_forum']);

if (!empty($fetchpoll))
{
	$template->assign_vars(array(		
		'S_POLL_QUESTION' => $fetchpoll['vote_text'],
		'S_POLL_ACTION' => append_sid('posting.'.$phpEx.'?'.POST_TOPIC_URL.'='.$fetchpoll['topic_id']),
		'S_TOPIC_ID' => $fetchpoll['topic_id'],
		'L_SUBMIT_VOTE' => $lang['Submit_vote'],
		'L_LOGIN_TO_VOTE' => $lang['Login_to_vote']		
		)
	);

	for ($i = 0; $i < count($fetchpoll['options']); $i++)
	{
		$template->assign_block_vars('poll_option_row', array(
			'OPTION_ID' => $fetchpoll['options'][$i]['vote_option_id'],
			'OPTION_TEXT' => $fetchpoll['options'][$i]['vote_option_text'],
			'VOTE_RESULT' => $fetchpoll['options'][$i]['vote_result'],
			)
		);
	}	
}
else
{
	$template->assign_vars(array(		
		'S_POLL_QUESTION' => $lang['No_poll'],
		'DISABLED' => 'disabled="disabled"'
		)
	);
}



#
#-----[ REPLACE WITH ]-----------------------------------
#


//\\ 
//\\ Start - vgan's Portal Poll Mod V. 2.0
//\\


// Set the vote graphic length to 100
// 	Note: If the bars look too long at %100, (only 1 vote) set this value lower.
// 	      Likewise, if it looks too short to you, increase it here.
$length = 100;

//  Get the poll forum from EZportal config above
$poll_forum = $CFG['poll_forum'];

{
	$template->assign_block_vars('PORTAL_POLL', array());

	$sql = 'SELECT
 		  t.*, vd.*
		FROM 
		  ' . TOPICS_TABLE . ' AS t,
		  ' . VOTE_DESC_TABLE . ' AS vd
		WHERE
		  t.forum_id = ' . $poll_forum . ' AND
		  t.topic_status <> 1 AND
		  t.topic_status <> 2 AND
		  t.topic_vote = 1 AND
		  t.topic_id = vd.topic_id
		ORDER BY
		  t.topic_time DESC 
		LIMIT
		  0,1';


	if(!$result = $db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, "Couldn't obtain poll information.", "", __LINE__, __FILE__, $sql);
	}

	if(!$total_posts = $db->sql_numrows($result))
	{
		message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
	}
	$pollrow = $db->sql_fetchrowset($result);
	$db->sql_freeresult($result);

	$topic_id = $pollrow[0]['topic_id'] ;

		$sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
			FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
			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) )
		{
			message_die(GENERAL_ERROR, "Couldn't obtain vote data for this topic", "", __LINE__, __FILE__, $sql);
		}

		if( $vote_options = $db->sql_numrows($result) )
		{
			$vote_info = $db->sql_fetchrowset($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 = $vote_id
					AND vote_user_id = " . $userdata['user_id'];
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't obtain user vote data for this topic", "", __LINE__, __FILE__, $sql);
			}

			$user_voted = ( $db->sql_numrows($result) ) ? TRUE : 0;

			if( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
			{
				$view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == "viewresult" ) ? TRUE : 0;
			}
			else
			{
				$view_result = 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 || $forum_row['topic_status'] == TOPIC_LOCKED )
			{

				$template->set_filenames(array(
					"pollbox" => "portal_poll_result.tpl")
				);

				$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;
					$portal_vote_graphic_length = round($vote_percent * $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" => $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" => $vote_graphic_img,
						"POLL_OPTION_IMG_WIDTH" => $portal_vote_graphic_length/1)
					);
				}

				$template->assign_vars(array(
					"L_TOTAL_VOTES" => $lang['Total_votes'],
					"TOTAL_VOTES" => $vote_results_sum,
               			"L_VIEW_RESULTS" => $lang['View_results'], 
               			"U_VIEW_RESULTS" => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult"))
				);

			}
			else
			{
				$template->set_filenames(array(
					"pollbox" => "portal_poll_ballot.tpl")
				);

				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" => $vote_info[$i]['vote_option_id'],
						"POLL_OPTION_CAPTION" => $vote_info[$i]['vote_option_text'])		
					);
				}
				$template->assign_vars(array(
					"LOGIN_TO_VOTE" => '<b><a href="' . append_sid("login.$phpEx?redirect=portal.$phpEx") . '">' . $lang['Login_to_vote'] . '</a><b>')
				);

				$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" => $vote_title,
				"L_SUBMIT_VOTE" => $lang['Submit_vote'],
				"S_HIDDEN_FIELDS" => ( !empty($s_hidden_fields) ) ? $s_hidden_fields : "",
				"S_POLL_ACTION" => append_sid("posting.$phpEx?" . POST_TOPIC_URL . "=$topic_id"))
			);

			$template->assign_var_from_handle("PORTAL_POLL", "pollbox");
		}
}

//\\ 
//\\ End - vgan's Portal Poll Mod V. 2.0
//\\ 







#
#-----[ OPEN ]-----------------------------------
#

portal_body.tpl

#
#-----[ FIND ]-----------------------------------
#

		  <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
		   <tr>
			<td class="catHead" height="25"><span class="genmed"><b>{L_POLL}</b></span></td>
		   </tr>
		   <tr>
			<td class="row1" align="left"><span class="gensmall">
				<form method="post" action="{S_POLL_ACTION}">
				<center><b>{S_POLL_QUESTION}</b></center><br />
				<!-- BEGIN poll_option_row -->
				<input type="radio" name="vote_id" value="{poll_option_row.OPTION_ID}">{poll_option_row.OPTION_TEXT}&nbsp;[{poll_option_row.VOTE_RESULT}]<br />
				<!-- END poll_option_row -->
				<br />
				<!-- BEGIN switch_user_logged_out -->
				<center>{L_LOGIN_TO_VOTE}</center>
				<!-- END switch_user_logged_out -->
				<!-- BEGIN switch_user_logged_in -->
				<center><input type="submit" class="mainoption" name="submit" value="{L_VOTE_BUTTON}" {DISABLED}></center>
				<input type="hidden" name="topic_id" value="{S_TOPIC_ID}">
				<input type="hidden" name="mode" value="vote">
				<!-- END switch_user_logged_in -->
				</form><br />
			</span></td>
		   </tr>
		  </table>

#
#-----[ REPLACE WITH ]-----------------------------------
#

		   
		  {PORTAL_POLL}


# 
#-----[ COPY ]------------------------------------------ 
#
#  Note:
#  If using a template other than subSilver, you'll need to update the left and right image cap locations in portal_poll_result.tpl.
# 

Copy	templates/subSilver/portal_poll_ballot.tpl
Copy	templates/subSilver/portal_poll_result.tpl


# 
#-----[ SAVE/CLOSE ALL FILES ]----------------------------
@14krpm

Gebruikersavatar
desert spider
Berichten: 1101
Lid geworden op: 08 feb 2004, 18:51

Bericht door desert spider » 19 jul 2004, 21:59

ik dacht dat het aan mijn portal lach dat er geen balkje komt als je gestemt hebt maar dat is dus niet zo
waar kan ik deze mod downlaoden op phpbb2.de en phpbbhacks kon ik het niet vinden

Gebruikersavatar
eXo
Berichten: 234
Lid geworden op: 08 jun 2004, 09:50
Locatie: W`veen
Contacteer:

Bericht door eXo » 20 jul 2004, 11:28

Deze is het: http://www.phpbbhacks.com/download/1734

Krijg hem alleen niet aan de praat met 2.0.10.
@14krpm


Gebruikersavatar
eXo
Berichten: 234
Lid geworden op: 08 jun 2004, 09:50
Locatie: W`veen
Contacteer:

Bericht door eXo » 20 jul 2004, 12:18

Vaag nog maar eens proberen dan :)

Handig btw dat test account op je forum ;)
@14krpm

Gebruikersavatar
desert spider
Berichten: 1101
Lid geworden op: 08 feb 2004, 18:51

Bericht door desert spider » 20 jul 2004, 12:19

oeps vergeten te verwijderen had er niet mogen zijn(laat hem er nu toch maar op)

Gebruikersavatar
eXo
Berichten: 234
Lid geworden op: 08 jun 2004, 09:50
Locatie: W`veen
Contacteer:

Bericht door eXo » 20 jul 2004, 12:31

Nog een keer geprobeerd maar helaas.
Vreemd hoor... :shock:
@14krpm

Gebruikersavatar
Stef
Berichten: 9080
Lid geworden op: 04 jun 2003, 20:47

Bericht door Stef » 20 jul 2004, 13:17

Weet je zeker dat je hem helemaal goed hebt vervangen?

Gebruikersavatar
eXo
Berichten: 234
Lid geworden op: 08 jun 2004, 09:50
Locatie: W`veen
Contacteer:

Bericht door eXo » 20 jul 2004, 13:34

Stefkuh schreef:Weet je zeker dat je hem helemaal goed hebt vervangen?
Jah exact zoals er staat. Die error blijft trouwens hetzelfde :)
Kan iemand daaruit afleiden wat er niet klopt?
@14krpm

Gebruikersavatar
Stef
Berichten: 9080
Lid geworden op: 04 jun 2003, 20:47

Bericht door Stef » 20 jul 2004, 13:56

Als ik het goed heb zit er hier iets verkeerd:

Code: Selecteer alles

   $sql = 'SELECT
        t.*, vd.*
      FROM
        ' . TOPICS_TABLE . ' AS t,
        ' . VOTE_DESC_TABLE . ' AS vd
      WHERE
        t.forum_id = ' . $poll_forum . ' AND
        t.topic_status <> 1 AND
        t.topic_status <> 2 AND
        t.topic_vote = 1 AND
        t.topic_id = vd.topic_id
      ORDER BY
        t.topic_time DESC
      LIMIT
        0,1'; 
Maar dat lijkt mij niet omdat hij bij die andere wel doet.

Gesloten