diff --git a/AJAXPoll.php b/AJAXPoll.php index dd591ce..5ce3430 100644 --- a/AJAXPoll.php +++ b/AJAXPoll.php @@ -19,7 +19,7 @@ * @author Jack Phoenix * @author Thomas Gries * @maintainer Thomas Gries - * @version 1.73 + * @version 1.74 * @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation */ @@ -31,7 +31,7 @@ if( !defined( 'MEDIAWIKI' ) ) { $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'AJAX Poll', - 'version' => '1.73 20120314', + 'version' => '1.74 20120315', 'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries' ), 'descriptionmsg' => 'ajaxpoll-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll', diff --git a/AJAXPoll_body.php b/AJAXPoll_body.php index 4e26012..1103b0f 100644 --- a/AJAXPoll_body.php +++ b/AJAXPoll_body.php @@ -321,10 +321,13 @@ class AJAXPoll { for ( $i = 1; $i < count( $lines ); $i++ ) { $vote = !( $canRevoke && ( $i == count( $lines ) - 1 ) ); - $voteValue = ( $vote ) ? $i : 0; - $ans_no = $i - 1; - $xid = "$id-$ans_no"; + // answers are counted from 1 ... n + // last answer is pseudo-answer for "I want to revoke vote" + // and becomes answer number 0 + + $answer = ( $vote ) ? $i : 0; + $xid = $id . "-" . $answer; if ( $amountOfVotes == 0 ) { $percent = 0; @@ -341,7 +344,7 @@ class AJAXPoll { if ( $wgUser->isAllowed( 'ajaxpoll-vote' ) ) { if ( $wgUseAjax ) { - $submitJS = "sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $voteValue . "\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);"; + $submitJS = "sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $answer . "\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);"; } else { $submitJS = "$(\"#ajaxpoll-answer-id-" . $id . "\").submit();"; } @@ -352,13 +355,13 @@ class AJAXPoll { if ( $vote ) { $ret .= " -