[geeklog-cvs] geeklog: Fix voters count problem when saving a poll in the admi...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Tue Jan 31 14:48:04 EST 2012
changeset 8485:b765e5090111
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/b765e5090111
user: Tom <websitemaster at cogeco.net>
date: Tue Jan 31 14:47:10 2012 -0500
description:
Fix voters count problem when saving a poll in the admin (bug #0001419)
diffstat:
public_html/admin/plugins/polls/index.php | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diffs (41 lines):
diff -r ddc379cfe41e -r b765e5090111 public_html/admin/plugins/polls/index.php
--- a/public_html/admin/plugins/polls/index.php Tue Jan 24 19:46:07 2012 -0500
+++ b/public_html/admin/plugins/polls/index.php Tue Jan 31 14:47:10 2012 -0500
@@ -258,9 +258,13 @@
$k = 0; // set up a counter to make sure we do assign a straight line of question id's
// first dimension of array are the questions
$num_questions = count($Q);
+ $num_total_votes = 0;
+ $num_questions_exist = 0;
for ($i = 0; $i < $num_questions; $i++) {
$Q[$i] = COM_stripslashes($Q[$i]);
if (strlen($Q[$i]) > 0) { // only insert questions that exist
+ $num_questions_exist++;
+
$Q[$i] = addslashes($Q[$i]);
DB_save($_TABLES['pollquestions'], 'qid, pid, question',
"'$k', '$pid', '$Q[$i]'");
@@ -278,14 +282,21 @@
$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);
+
+ $num_total_votes = $num_total_votes + $V[$i][$j];
}
}
$k++;
}
}
- // determine the number of voters
- $numvoters = DB_count($_TABLES['pollvoters'], 'pid', $pid);
+ // determine the number of voters (cannot use records in pollvoters table since they get deleted after a time $_PO_CONF['polladdresstime'])
+ if ($num_questions_exist > 0) {
+ $numvoters = $num_total_votes / $num_questions_exist;
+ } else {
+ // This shouldn't happen
+ $numvoters = $num_total_votes;
+ }
// save topics after the questions so we can include question count into table
$sql = "'$pid','$topic','$meta_description','$meta_keywords',$numvoters, $k, '$created_date', '" . date ('Y-m-d H:i:s');
More information about the geeklog-cvs
mailing list