Welcome to Geeklog, Anonymous Friday, April 19 2024 @ 11:16 am EDT

Geeklog Forums

Polls - GL 1.4.1


Status: offline

scarecrow

Forum User
Junior
Registered: 10/24/07
Posts: 33
These 2 patches will make polls 'voteable' from the polls list. Clicking on a poll in the list will open it in the center block for voting if the poll is 'open for voting' and the voting member has permissions to do so, and hasn't voted already. If the poll is closed, the member doesn't have permission, or has already voted, the poll results are displayed. Also plugs up a backdoor hole that allowed a vote to be made to a closed poll.

Might want to tweak the pollblock.thtml template a bit to your liking as well.

Files:
{geeklog}/plugins/polls/functions.inc
{public_html}/polls/index.php

Text Formatted Code
--- functions.inc.orig  2007-11-16 02:21:13.000000000 -0600
+++ functions.inc       2007-11-16 02:22:36.000000000 -0600
@@ -909,7 +909,16 @@
                 $retval = strftime ($_CONF['daytime'], $A['unixdate']);
                 break;
             case 'question':
-                $retval = "<a href=\"{$_CONF['site_url']}/polls/index.php?qid={$A['qid']}&amp;aid=-1\">$fieldvalue</a>";
+global $_TABLES;
+$zqid = $A['qid'];
+$zdisplay = DB_getItem ($_TABLES['pollquestions'], 'display',
+                               "qid = '$zqid'");
+
+ if( POLLS_ipAlreadyVoted($zqid) || $zdisplay==0){
+                $retval .= "<a href=\"{$_CONF['site_url']}/polls/index.php?qid={$A['qid']}&amp;aid=-1\">$fieldvalue</a>";
+}  else {
+                $retval .= "<a          href=\"{$_CONF['site_url']}/polls/index.php?qid=$zqid&amp;aid=\">$fieldvalue</a>";
+}
                 break;
             case 'access':
                 if ($access == 3) {

 


Text Formatted Code

--- index.orig  2007-11-16 01:01:39.000000000 -0600
+++ index.php   2007-11-16 01:04:42.000000000 -0600
@@ -146,6 +146,7 @@
 // an aid greater than 0 will save a vote for that answer on the selected poll
 // an aid of -1 will display the select poll
 
+$pdisplay = DB_getItem ($_TABLES['pollquestions'], 'display', "qid = '{$qid}'");
 $display = '';
 
 if (isset ($_POST['reply']) && ($_POST['reply'] == $LANG01[25])) {
@@ -174,6 +175,9 @@
         }
     }
 }
+if ($pdisplay == 0) {
+            $aid = -1;
+        }
 $order = '';
 if (isset ($_REQUEST['order'])) {
     $order = COM_applyFilter ($_REQUEST['order']);
 
 Quote

Status: offline

scarecrow

Forum User
Junior
Registered: 10/24/07
Posts: 33
Taking it a step further.... here's a patch that fixes the comments in the polls section. {geeklog}/system/lib-comment.php appears to reference a different polling system. A couple gentle nudges to two line makes the Threaded/Flat/Nested/No Comment types work correctly.
I have a couple polls out on the test site if you want to see all this in action, anon access. Mash the Website button below and follow the signs.

File:
{Geeklog}/system/lib-comment.php

Text Formatted Code

--- lib-comment.orig    2007-11-19 14:11:52.000000000 -0600
+++ lib-comment.php     2007-11-19 14:12:50.000000000 -0600
@@ -143,9 +143,9 @@
         }
         $commentbar->set_var( 'hidden_field', $hidden .
                 '<input type="hidden" name="mode" value="' . $_REQUEST['mode'] . '">' );
-    } else if( $type == 'poll' ) {
+    } else if( $type == 'polls' ) {
         $commentbar->set_var( 'parent_url',
-                              $_CONF['site_url'] . '/pollbooth.php' );
+                              $_CONF['site_url'] . '/polls/index.php?qid='.$sid );
         $commentbar->set_var( 'hidden_field',
                 '<input type="hidden" name="scale" value="400">' .
                 '<input type="hidden" name="qid" value="' . $sid . '">' .

 
 Quote

earnest

Anonymous
scarecrow:

Could you please tell us where the new code goes (what to replace, etc.)? I don't understand the things you've posted.
 Quote

All times are EDT. The time is now 11:16 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content