POLL hack - locking poll for only view votes and reset votes

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
chip_rider
Posts: 40
Joined: Wed 2. Nov 2005, 21:41

POLL hack - locking poll for only view votes and reset votes

Post by chip_rider »

AUF MEINER EIGENEN ANFRAGE HABE ICH SELBER VERSUCHT DAS POLLSYSTEM UMZUÄNDERN!
http://www.phpwcms.de/forum/viewtopic.p ... light=poll

Hallo Leute!

1. Ich habe mein poll umgeändert so das man jetz ein poll sperren kann (checkbox im backend cnt-poll). Wenn er also gesperrt wird sieht man im Frontend nur die Anzahl der Stimmen ohne das man abstimmen kann. Somit ist es möglich auch alle geschlossenen polls anzuzeigen.

2. Beim editieren des polls werden immer alle votes automatisch auf null gesetzt. Das habe ich auch umgeändert. Jetz ist es möglich Verbesserungen am Text durchzuführen ohne das die votes auf null gesetzt werden. Mit einer checkbox im backend cnt-poll kann man jetz alle votes auf null setzen.

Hier die Änderungen:

Datei: /include/inc_tmpl/content/cnt89.inc.php
In der letzten Zeile (in the last line):

Code: Select all

<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10"></td></tr>
vorher diesen Code einfügen (insert befor):

Code: Select all

<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="5"></td></tr>
<tr>
<td align="right" class="chatlist"><?php echo $BL['be_login_cpactive'] ?>:&nbsp;</td>
<td valign="top">
	<table border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td bgcolor="#E7E8EB"><input name="cpoll_final" type="checkbox" id="cpoll_final" value="1" <?php is_checked(1, $content['poll_form']['final']); ?>></td>
	  <td bgcolor="#E7E8EB" class="v10" align="left">&nbsp;<?php echo $BL['be_fprivfunc_cactive'] ?>&nbsp;</td>
	</tr>
	</table>
</td>
</tr>
<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="5"></td></tr>
<tr>
<td align="right" class="chatlist">Reset:&nbsp;</td>
<td valign="top">
	<table border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td bgcolor="#E7E8EB"><input name="cpoll_reset" type="checkbox" id="cpoll_reset" value="1" <?php is_checked(1, $content['reset_poll']); ?>></td>
	  <td bgcolor="#E7E8EB" class="v10" align="left">&nbsp;auf Null setzen&nbsp;</td>
	</tr>
	</table>
</td>
</tr>

----------------------------------------------------------------------------------


Datei: /include/inc_lib/content/cnt89.readform.inc.php
Nach dieser Zeile (after this line):

Code: Select all

$content["poll_zoom"] 		= isset($_POST["cpoll_zoom"]) ? 1 : 0;
diesen Code einfügen (insert):

Code: Select all

//---------------------------final-------------------------------
$content['poll_final']      = isset($_POST["cpoll_final"]) ? 1 : 0;
$content['reset_poll']      = isset($_POST["cpoll_reset"]) ? 1 : 0;
//---------------------------end final---------------------------
Nch diesen beiden Zeilen suchen (search):

Code: Select all

$content['poll_form']['count'] = array();
$content['poll_form']['ip'] = array();
Und mit folgenden Code AUSTAUSCHEN (replace with):

Code: Select all

//---------------------------final-------------------------------
if($content['reset_poll']==1){
//---------------------------end final---------------------------

	$content['poll_form']['count'] = array();
	$content['poll_form']['ip'] = array();

//---------------------------final-------------------------------
}
//---------------------------end final---------------------------
Nach der folgenden foreach Schleife suchen - search this code:

Code: Select all

foreach($content['poll_cctext'] as $key => $value)
{
        $content['poll_form']['count'][$key] = 0; // initialize count to zero
}
Und mit folgenden Code AUSTAUSCHEN (replace with):

Code: Select all

//---------------------------final-------------------------------
$content['poll_form']['final']	=  $content["poll_final"];
if($content['reset_poll']==1){
//---------------------------end final---------------------------

	foreach($content['poll_cctext'] as $key => $value)
	{
		$content['poll_form']['count'][$key] = 0; // initialize count to zero
	}
	
//---------------------------final-------------------------------
}
//---------------------------end final---------------------------

----------------------------------------------------------------------------------


Datei: /include/inc_front/content/cnt89.article.inc.php
Folgenden Code - search for this code (ca. Zeile/line 47):

Code: Select all

if($poll_id == $crow['acontent_id'] && isset($_POST["poll"]) && !in_array($remoteIP, $poll_form["ip"])) {
mit folgenden Code austauschen (replace with):

Code: Select all

if($poll_id == $crow['acontent_id'] && isset($_POST["poll"]) && !in_array($remoteIP, $poll_form["ip"]) && $poll_form["final"]==1) {
Folgenden Code - search for this code (ca. Zeile/line 67):

Code: Select all

if(in_array(remoteIP, $poll_form["ip"])) {
mit folgenden Code austauschen (replace with):

Code: Select all

if(in_array($remoteIP, $poll_form["ip"]) || $poll_form["final"]==0) {


Bei Problemen einfach posten oder eine PN senden!
Viel Spaß mit dem poll hack
JensZ
Posts: 136
Joined: Wed 16. Feb 2005, 12:18
Location: Stockholm, Sweden
Contact:

Post by JensZ »

Can someone please translate?

Cheers,

Jens
chip_rider
Posts: 40
Joined: Wed 2. Nov 2005, 21:41

Post by chip_rider »

JensZ wrote:Can someone please translate?

Cheers,

Jens

This little POLL hack expand the POLL CNT!

1. Function
OPEN or CLOSE a POLL
So you can block a poll for only view the results or make open the poll to vote.

2.Function
If you edit the poll in the contenpart and save it, all votes go to NULL. With this hack the votes go only to NULL if the checkbox "set to null" is selected (backend).

Sorry, but my english is not good!
godmd

Re: POLL hack - locking poll for only view votes and reset votes

Post by godmd »

Hallo chip_rider!

Ist diese Anleitung zum Schließen eines Polls immer noch aktuell, d.h. kann sie in der Snapshotversion 1.3.5 eine zu eins, d.h. ohne Fehler zu verursachen, umgesetzt werden?

Falls ja, würde sich ja auch eine Übersetzung noch lohnen (würde ich dann machen) und vielleicht eine Übernahmen in die FAQ.

Gruß,
Anka
Post Reply