Portal Polls upgrade

Allgemeiner Support zum phpBB 2 Board und phpBB 2 Modifikationen
Forumsregeln
Auch wenn hier der Support für phpBB 2 weiterhin aufrecht erhalten bleibt, weisen wir darauf hin, dass das phpBB 2 nicht mehr offiziell unterstützt und weiterentwickelt wird!
Antworten
Benutzeravatar
skittles
Beiträge: 820
Registriert: So 04.Apr, 2004 01:07
Wohnort: Wien

Portal Polls upgrade

Beitrag von skittles »

Code: Alles auswählen

#################################################################
## 
## 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
##
#################################################################
Wollte grad diesen Mod einbauen, doch wenn ich in der portal.php

Code: Alles auswählen

#
#-----[ 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
//\\ 
Dies durchführen will kommt immer die FEhlermeldung
Es existieren keine Beiträge zu diesem Thema.
wenn ich das Portal aufrufe.
Funktioniert der Mod einfach nicht, oder was mache ich falsch??
[center]Populanten von transparenten Domizilen sollten
mit fester Materie keine transzendenten Bewegungen durchf?hren.
[/center]


Bild
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Der Mod funktioniert schon.
Erscheint das Portal dann überhaupt nicht mehr, sondern nur diese Fehlermeldung oder diese Meldung irgendwo oben im Portal?
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
skittles
Beiträge: 820
Registriert: So 04.Apr, 2004 01:07
Wohnort: Wien

Beitrag von skittles »

Es erscheint nur diese Meldung.
Sieht genau so aus, wie wenn du auf die Board suche gehst und dein gesuchter begriff nicht gefunden wird. Nur eben mit einer anderen meldung!
[center]Populanten von transparenten Domizilen sollten
mit fester Materie keine transzendenten Bewegungen durchf?hren.
[/center]


Bild
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Dann hast Du in der portal.php was falsch eingebaut.
Häng diese doch mal hier an, um nachzusehen.
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
skittles
Beiträge: 820
Registriert: So 04.Apr, 2004 01:07
Wohnort: Wien

Beitrag von skittles »

Ich kann es mir zwar nicht vorstellen, da nur ein einziger Block hinzugefügt wird mehr nicht.
Aber wenn du es hinbekommst bin ich dir sehr dankbar!
[center]Populanten von transparenten Domizilen sollten
mit fester Materie keine transzendenten Bewegungen durchf?hren.
[/center]


Bild
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Hier die Korrektur.
Was im Laufe der Zeit wohl verloren ging, ist die Bedingung, bzw. das fehlen derselben, ob ein Umfrage-Forum eingetragen ist.
Da man diesen Block aber ja sehen will, habe ich bei Dir diesen grundsätzlich aktiviert.
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
skittles
Beiträge: 820
Registriert: So 04.Apr, 2004 01:07
Wohnort: Wien

Beitrag von skittles »

Danke Oxpus für deine Korrektur!
Funktioniert aber leider nur teilweise.

Erstelle ich eine Umfrage, dann funktioniert es.
Ist keine Umfrage da habe ich die selbe fehlermeldung.

Es genau so wie vor deiner Korrektur.
if {Umfrage erstellt=ja}
no fehlermeldung
else fehlermeldung!
[center]Populanten von transparenten Domizilen sollten
mit fester Materie keine transzendenten Bewegungen durchf?hren.
[/center]


Bild
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Klar, hab ja auch noch einen Punkt übersehen.
Hier nun die endgültig korrekte Fassung.

BTW:

Code: Alles auswählen

if {Umfrage erstellt=ja}
no fehlermeldung
else fehlermeldung!
Würde immer zu einer Fehlermeldung führen ;)
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
skittles
Beiträge: 820
Registriert: So 04.Apr, 2004 01:07
Wohnort: Wien

Beitrag von skittles »

hehe! Ich weiß eh!

Und besten dank, jetzt klappts auch mit mit den nachbarn ähm ich mein mit dem Portal!
weiß auch net was heute los ist mit mir! Bin irgendwie so gut aufgelegt
[center]Populanten von transparenten Domizilen sollten
mit fester Materie keine transzendenten Bewegungen durchf?hren.
[/center]


Bild
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Freut mich ebenfalls, wenn es Dich freut :ok
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Antworten