[geeklog-cvs] geeklog: Fixed voters do not get counted correctly when updating...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Feb 21 13:15:09 EST 2011


changeset 8124:53e89328a62f
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/53e89328a62f
user: Tom <websitemaster at cogeco.net>
date: Mon Feb 21 13:14:32 2011 -0500
description:
Fixed voters do not get counted correctly when updating a poll with multiple questions. Bug #0001056 partial patch provided by Erisco

diffstat:

 plugins/polls/functions.inc               |   4 ++--
 plugins/polls/language/english.php        |   1 +
 plugins/polls/templates/pollblock.thtml   |   2 +-
 plugins/polls/templates/pollresult.thtml  |   2 +-
 public_html/admin/plugins/polls/index.php |  12 +++++-------
 public_html/docs/history                  |   5 +++++
 6 files changed, 15 insertions(+), 11 deletions(-)

diffs (111 lines):

diff -r 2f477f31bbd2 -r 53e89328a62f plugins/polls/functions.inc
--- a/plugins/polls/functions.inc	Sun Feb 20 17:26:56 2011 +0100
+++ b/plugins/polls/functions.inc	Mon Feb 21 13:14:32 2011 -0500
@@ -500,7 +500,7 @@
                 } else {
                     $poll->set_var('lang_vote', $LANG_POLLS['start_poll']);
                 }
-                $poll->set_var('lang_votes', $LANG_POLLS['votes']);
+                $poll->set_var('lang_voters', $LANG_POLLS['voters']);
 
                 $results = '';
                 if (($P['is_open'] == 0) || ($P['hideresults'] == 0) ||
@@ -816,7 +816,7 @@
             $poll->set_var('poll_topic', $P['topic']);
             $poll->set_var('poll_id', $pid);
             $poll->set_var('num_votes', COM_numberFormat($P['voters']));
-            $poll->set_var('lang_votes', $LANG_POLLS['votes']);
+            $poll->set_var('lang_voters', $LANG_POLLS['voters']);
             $access = SEC_hasAccess($P['owner_id'], $P['group_id'],
                             $P['perm_owner'], $P['perm_group'],
                             $P['perm_members'], $P['perm_anon']);
diff -r 2f477f31bbd2 -r 53e89328a62f plugins/polls/language/english.php
--- a/plugins/polls/language/english.php	Sun Feb 20 17:26:56 2011 +0100
+++ b/plugins/polls/language/english.php	Mon Feb 21 13:14:32 2011 -0500
@@ -33,6 +33,7 @@
     'results'           => 'Results',
     'pollresults'       => 'Poll Results',
     'votes'             => 'votes',
+    'voters'            => 'voters',
     'vote'              => 'Vote',
     'pastpolls'         => 'Past Polls',
     'savedvotetitle'    => 'Vote Saved',
diff -r 2f477f31bbd2 -r 53e89328a62f plugins/polls/templates/pollblock.thtml
--- a/plugins/polls/templates/pollblock.thtml	Sun Feb 20 17:26:56 2011 +0100
+++ b/plugins/polls/templates/pollblock.thtml	Mon Feb 21 13:14:32 2011 -0500
@@ -10,5 +10,5 @@
 </form>
 
 <span class="pluginTinyText">
-    <a href="{site_url}/polls/index.php">{lang_polltopics}</a> | {num_votes} {lang_votes} {poll_comments}
+    <a href="{site_url}/polls/index.php">{lang_polltopics}</a> | {num_votes} {lang_voters} {poll_comments}
 </span>
\ No newline at end of file
diff -r 2f477f31bbd2 -r 53e89328a62f plugins/polls/templates/pollresult.thtml
--- a/plugins/polls/templates/pollresult.thtml	Sun Feb 20 17:26:56 2011 +0100
+++ b/plugins/polls/templates/pollresult.thtml	Mon Feb 21 13:14:32 2011 -0500
@@ -1,5 +1,5 @@
 <span class="floatright">{edit_icon}</span><div class="poll-topic">{poll_topic}</div>
 {poll_questions}
 <div class="pluginTinyText">
-    {notification} <a href="{site_url}/polls/index.php">{lang_polltopics}</a> | {num_votes} {lang_votes} {poll_comments}
+    {notification} <a href="{site_url}/polls/index.php">{lang_polltopics}</a> | {num_votes} {lang_voters} {poll_comments}
 </div>
\ No newline at end of file
diff -r 2f477f31bbd2 -r 53e89328a62f public_html/admin/plugins/polls/index.php
--- a/public_html/admin/plugins/polls/index.php	Sun Feb 20 17:26:56 2011 +0100
+++ b/public_html/admin/plugins/polls/index.php	Mon Feb 21 13:14:32 2011 -0500
@@ -229,10 +229,6 @@
         exit;
     }
 
-    if (empty ($voters)) {
-        $voters = 0;
-    }
-
     if ($_POLL_VERBOSE) {
         COM_errorLog('owner permissions: ' . $perm_owner, 1);
         COM_errorLog('group permissions: ' . $perm_group, 1);
@@ -260,7 +256,6 @@
     $meta_keywords = addslashes($meta_keywords);
 
     $k = 0; // set up a counter to make sure we do assign a straight line of question id's
-    $v = 0; // re-count votes sine they might have been changed
     // first dimension of array are the questions
     $num_questions = count($Q);
     for ($i = 0; $i < $num_questions; $i++) {
@@ -283,14 +278,17 @@
                     $sql = "INSERT INTO {$_TABLES['pollanswers']} (pid, qid, aid, answer, votes, remark) VALUES "
                         . "('$pid', '$k', " . ($j+1) . ", '{$A[$i][$j]}', {$V[$i][$j]}, '{$R[$i][$j]}');";
                     DB_query($sql);
-                    $v = $v + $V[$i][$j];
                 }
             }
             $k++;
         }
     }
+    
+    // determine the number of voters
+    $numvoters = DB_count($_TABLES['pollvoters'], 'pid', $pid);
+    
     // save topics after the questions so we can include question count into table
-    $sql = "'$pid','$topic','$meta_description','$meta_keywords',$v, $k, '$created_date', '" . date ('Y-m-d H:i:s');
+    $sql = "'$pid','$topic','$meta_description','$meta_keywords',$numvoters, $k, '$created_date', '" . date ('Y-m-d H:i:s');
 
     if ($mainpage == 'on') {
         $sql .= "',1";
diff -r 2f477f31bbd2 -r 53e89328a62f public_html/docs/history
--- a/public_html/docs/history	Sun Feb 20 17:26:56 2011 +0100
+++ b/public_html/docs/history	Mon Feb 21 13:14:32 2011 -0500
@@ -52,6 +52,11 @@
 ------------
 - Fixed text above the list of links, which was referring to a menu entry that
   no longer exists (bug #0001216)
+  
+Polls Plugin
+------------
+- Fixed voters do not get counted correctly when updating a poll with multiple 
+  questions. (patch #0001056, provided by Erisco)
 
 Static Pages Plugin
 -------------------



More information about the geeklog-cvs mailing list