Porting the maemo changes
I copied the maemo PHP files over the wml files and cherrypicked the necessary changes, i.e. I didn't update the Elections name and left the old elections@gnome.org address in place.
This commit is contained in:
		
							parent
							
								
									31fd299c8c
								
							
						
					
					
						commit
						78387ca5e5
					
				
					 3 changed files with 167 additions and 110 deletions
				
			
		|  | @ -38,84 +38,27 @@ if ($display && $election_id >= 0) { | ||||||
|     $error .= "The voting period for the specified ".elec_election_get_type ($election)." starts on ".$election["voting_start"]." (UTC) and ends on ".$election["voting_end"]." (UTC). It is not possible to see the results now.<br />\n"; |     $error .= "The voting period for the specified ".elec_election_get_type ($election)." starts on ".$election["voting_start"]." (UTC) and ends on ".$election["voting_end"]." (UTC). It is not possible to see the results now.<br />\n"; | ||||||
|     $display = FALSE; |     $display = FALSE; | ||||||
|   } |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     $results = elec_get_results($handle, $election_id); | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if (isset ($election) && $election !== FALSE) { | if (isset ($election) && $election !== FALSE) { | ||||||
|  |   if ($results !== FALSE) | ||||||
|  |   { | ||||||
|     echo "<h1>Results for the ".$election["name"]."</h1>\n"; |     echo "<h1>Results for the ".$election["name"]."</h1>\n"; | ||||||
| } |   } else { | ||||||
| 
 |     $error .= "The voting period for the specified ".elec_election_get_type ($election)." has closed, but the results of the election have not yet been calculated. It is not possible to see the results now.<br />\n"; | ||||||
| if ($display) { |     echo "<p>In the meantime, you can look at the <a href=\"votes.php?election_id=".$election_id."\">list of all votes</a> and verify that your vote is correct.</p>\n"; | ||||||
|   $anon_tokens = elec_get_anon_tokens_for_election ($handle, $election_id); |  | ||||||
|   if ($anon_tokens === FALSE) { |  | ||||||
|     $error .= "Can not get the anonymous tokens for this ".elec_election_get_type ($election).".\n"; |  | ||||||
|     $display = FALSE; |     $display = FALSE; | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if ($display) { | if ($display) { | ||||||
|   $results = elec_get_results_election ($handle, $election_id); |   echo "<hr/>"; | ||||||
|   if ($results === FALSE) { |   echo $results["result"]; | ||||||
|     $error .= "Can not get the results for this ".elec_election_get_type ($election).".\n"; |   echo "<hr/>"; | ||||||
|     $display = FALSE; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| if ($display) { |  | ||||||
|   $blank_results = elec_get_blank_votes_election ($handle, $election_id); |  | ||||||
|   if ($results === FALSE) { |  | ||||||
|     $error .= "Can not get the blank votes for this ".elec_election_get_type ($election).".\n"; |  | ||||||
|     $display = FALSE; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| if ($display) { |  | ||||||
|   $choices = elec_choices_get ($handle, $election_id); |  | ||||||
|   if ($choices === FALSE) { |  | ||||||
|     $error .= "The ".elec_election_get_type ($election)." is not properly set up.\n"; |  | ||||||
|     $display = FALSE; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| if ($display) { |  | ||||||
|   $nb_voters = count ($anon_tokens); |  | ||||||
| 
 |  | ||||||
|   $automatic_results = array (); |  | ||||||
| 
 |  | ||||||
|   echo "<p>Please note that these results are automatically calculated and are thus not the official results.</p>\n"; |  | ||||||
| 
 |  | ||||||
|   echo "<p><strong>".$election["question"]."</strong></p>"; |  | ||||||
|   echo "<p>".$nb_voters." members voted for this ".elec_election_get_type ($election).". The repartition of the votes is:</p>\n"; |  | ||||||
| 
 |  | ||||||
|   echo "<div class=\"votedata\">\n"; |  | ||||||
|   foreach ($results as $result) { |  | ||||||
|     $found = FALSE; |  | ||||||
|     foreach ($choices as $choice) { |  | ||||||
|       if ($choice["id"] == $result["choice_id"]) { |  | ||||||
|         echo "<em>".$choice["choice"]."</em> (<strong>".$result["total_choice"]."</strong> votes)<br />\n"; |  | ||||||
|         $automatic_results[] = $choice["choice"]; |  | ||||||
|         $found = TRUE; |  | ||||||
|         break; |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (!$found) { |  | ||||||
|       echo "<em>Unknown value (".$result["choice_id"].")</em> (<strong>".$result["total_choice"]."</strong> votes)<br />\n"; |  | ||||||
|       $automatic_results[] = "Unknown value (".$result["choice_id"].")"; |  | ||||||
|       $error .= "There was an unkown vote: ".$result["choice_id"]."<br />\n"; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   if ($blank_results > 0) { |  | ||||||
|     echo "<br />"; |  | ||||||
|     echo "blank votes: <strong>".$blank_results."</strong><br />\n"; |  | ||||||
|   } |  | ||||||
|   echo "</div>\n"; |  | ||||||
| 
 |  | ||||||
|   echo "<p>The automatic result of this ".elec_election_get_type ($election)." is thus:</p>\n"; |  | ||||||
|   echo "<div class=\"votedata\">\n"; |  | ||||||
|   for ($i = 0; $i < $election["choices_nb"]; $i++) { |  | ||||||
|     echo "<em>".$automatic_results[$i]."</em><br />\n"; |  | ||||||
|   } |  | ||||||
|   echo "</div>\n"; |  | ||||||
|     |     | ||||||
|   echo "<p>Please look at the <a href=\"votes.php?election_id=".$election_id."\">list of all votes</a> and verify that your vote is correct.</p>\n"; |   echo "<p>Please look at the <a href=\"votes.php?election_id=".$election_id."\">list of all votes</a> and verify that your vote is correct.</p>\n"; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,14 +1,6 @@ | ||||||
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||||||
| <html> | <html> | ||||||
| 
 | 
 | ||||||
|   <head> |  | ||||||
|     <link rel="stylesheet" type="text/css" href="vote.css" /> |  | ||||||
|     <title>The GNOME Foundation - Votes</title> |  | ||||||
|     <meta name="cvsdate" content="$Date$" /> |  | ||||||
|     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |  | ||||||
|   </head> |  | ||||||
| 
 |  | ||||||
|   <body> |  | ||||||
| <?php | <?php | ||||||
| require_once ("include/election-sql.php"); | require_once ("include/election-sql.php"); | ||||||
| 
 | 
 | ||||||
|  | @ -67,40 +59,156 @@ if ($step > 1) { | ||||||
| 
 | 
 | ||||||
|   if (!elec_verify_email_tmp_token ($handle, $election_id, $email, $tmp_token)) { |   if (!elec_verify_email_tmp_token ($handle, $election_id, $email, $tmp_token)) { | ||||||
|     $step = 1; |     $step = 1; | ||||||
|     $error .= "The e-mail address and token you gave do not match an existing voter.<br />\n"; |     $error .= "The e-mail address and token you gave do not match an existing voter, or you have already voted.<br />\n"; | ||||||
|   } else { |   } else { | ||||||
| 
 | 
 | ||||||
|     $choices_nb = $election["choices_nb"]; |  | ||||||
|     $choices = elec_choices_get ($handle, $election_id); |     $choices = elec_choices_get ($handle, $election_id); | ||||||
| 
 | 
 | ||||||
|     if (!elec_verify_elections ($choices_nb, $choices)) { |     if (!elec_verify_elections ($choices)) { | ||||||
|       $error .= "The ".elec_election_get_type ($election)." is not properly set up.\n"; |       $error .= "The ".elec_election_get_type ($election)." is not properly set up.\n"; | ||||||
|       $step = 0; |       $step = 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | ?> | ||||||
|  |   <head> | ||||||
|  |     <link rel="stylesheet" type="text/css" href="vote.css" /> | ||||||
|  | <?php | ||||||
|  | if ($step==2) | ||||||
|  | { | ||||||
|  | ?> | ||||||
|  |     <style> | ||||||
|  | .canddata, .prefdata{ | ||||||
|  | width:30%; | ||||||
|  | height: <?php echo 1.8*count($choices); ?>em; | ||||||
|  | background: #E0FFD0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | .canddata ul{ | ||||||
|  | list-style-type: none; | ||||||
|  | list-style-position: inside; | ||||||
|  | } | ||||||
|  | .prefdata ol{ | ||||||
|  | list-style-position: outside; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .canddata ul li:hover, .prefdata ol li:hover{ | ||||||
|  | background: #E0E0E0; | ||||||
|  | cursor: pointer; | ||||||
|  | } | ||||||
|  |     </style> | ||||||
|  | <?php | ||||||
|  | } | ||||||
|  | ?> | ||||||
|  |     <title>The GNOME Foundation - Votes</title> | ||||||
|  |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||||||
|  | 
 | ||||||
|  | <?php | ||||||
|  | if ($step==2) | ||||||
|  | { | ||||||
|  | ?> | ||||||
|  | <script type="text/javascript"> | ||||||
|  | //<![CDATA[ | ||||||
|  | function addPreference(listItem) | ||||||
|  | { | ||||||
|  | var preferenceList = document.getElementById('preferences'); | ||||||
|  | listItem.parentNode.removeChild(listItem); | ||||||
|  | preferenceList.appendChild(listItem); | ||||||
|  | listItem.setAttribute('onclick', 'removePreference(this)'); | ||||||
|  | } | ||||||
|  | function removePreference(listItem) | ||||||
|  | { | ||||||
|  | var candidateList = document.getElementById('candidates'); | ||||||
|  | listItem.parentNode.removeChild(listItem); | ||||||
|  | candidateList.appendChild(listItem); | ||||||
|  | listItem.setAttribute('onclick', 'addPreference(this)'); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function populateList(){ | ||||||
|  |   var candidateList = document.getElementById('candidates'); | ||||||
|  |   var listItem; | ||||||
|  |   var prefInput; | ||||||
|  |   var listItemText; | ||||||
|  | 
 | ||||||
|  | <?php | ||||||
|  |   $index=0; | ||||||
|  |   foreach ($choices as $choice) { | ||||||
|  |     $index++; | ||||||
|  |     echo "  listItem = document.createElement('li');\n"; | ||||||
|  |     echo "  listItem.setAttribute('name', 'vote" . $choice["id"] . "');\n"; | ||||||
|  |     echo "  listItem.setAttribute('onclick', 'addPreference(this)');\n"; | ||||||
|  |     echo "  listItemText = document.createTextNode('" . $choice["choice"] . "');\n"; | ||||||
|  |     echo "  listItem.appendChild(listItemText);\n"; | ||||||
|  |     echo "  candidateList.appendChild(listItem);\n\n"; | ||||||
|  | 
 | ||||||
|  |     echo "  prefInput = document.createElement('input');\n"; | ||||||
|  |     echo "  prefInput.value = '';\n"; | ||||||
|  |     echo "  prefInput.name = 'pref$index';\n"; | ||||||
|  |     echo "  prefInput.id = 'pref$index';\n"; | ||||||
|  |     echo "  prefInput.type = 'hidden';\n"; | ||||||
|  |     echo "  document.forms[0].appendChild(prefInput);\n"; | ||||||
|  |     echo "\n"; | ||||||
|  |   } | ||||||
|  | ?> | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function submitPreferences() { | ||||||
|  |   // Traverse OL, get name & position of preferences, and for each preference,  | ||||||
|  |   // set value of hidden input with name prefN to value voteM before submitting | ||||||
|  |   var preferenceList = document.getElementById('preferences'); | ||||||
|  |   var pref; | ||||||
|  |   var i = 0; | ||||||
|  |   var index = 0; | ||||||
|  | 
 | ||||||
|  |   // Iterate through the list  | ||||||
|  |   for( i = 0; i < preferenceList.childNodes.length; i++ )  | ||||||
|  |   { | ||||||
|  |     node = preferenceList.childNodes[i]; | ||||||
|  |     // If we have a list item, get its name & set the appropriate hidden input | ||||||
|  |     if (node.nodeName.toLowerCase() == 'li') | ||||||
|  |     { | ||||||
|  |        index++; | ||||||
|  |        pref=document.getElementById('pref'+index) | ||||||
|  |        pref.value = node.getAttribute('name'); | ||||||
|  |       // DEBUG: alert(pref.name + '=' + pref.value); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | //]]> | ||||||
|  |     </script> | ||||||
|  | <?php | ||||||
|  |  } | ||||||
|  | ?> | ||||||
|  |   </head> | ||||||
|  | 
 | ||||||
|  | <?php | ||||||
|  | if ($step==2){ | ||||||
|  | ?> | ||||||
|  |   <body onLoad="populateList()"> | ||||||
|  | <?php | ||||||
|  | } else { | ||||||
|  | ?> | ||||||
|  |   <body> | ||||||
|  | <?php | ||||||
|  | } | ||||||
|  | ?> | ||||||
|  | 
 | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| if (isset ($election) && $election !== FALSE) { | if (isset ($election) && $election !== FALSE) { | ||||||
|   echo "<h1>".$election["name"]."</h1>\n"; |   echo "<h1>".$election["name"]."</h1>\n"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if ($step >= 2) { | if ($step >= 2) { | ||||||
|   if ($choices_nb == 1) { |  | ||||||
|     $votes_array = array (); |  | ||||||
| 
 |  | ||||||
|     if (isset ($_POST["vote"])) |  | ||||||
|       $vote = $_POST["vote"]; |  | ||||||
|     else |  | ||||||
|       $vote = -1; |  | ||||||
| 
 |  | ||||||
|   } else { |  | ||||||
| 
 |  | ||||||
|     $votes_array = elec_vote_get_votes_from_post ($choices); |     $votes_array = elec_vote_get_votes_from_post ($choices); | ||||||
|     $vote = -1; |     $vote = -1; | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   $res = elec_verify_vote_is_valid ($choices_nb, $choices, $vote, $votes_array); |   $res = elec_verify_vote_is_valid ($choices, $vote, $votes_array); | ||||||
|    |    | ||||||
|   if ($res != "") { |   if ($res != "") { | ||||||
|     $error .= "The vote you made is not valid: ".$res."<br />\n"; |     $error .= "The vote you made is not valid: ".$res."<br />\n"; | ||||||
|  | @ -142,7 +250,11 @@ if (isset ($error) && $error != "") { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if ($step != $max_step && $step >= 1) { | if ($step != $max_step && $step >= 1) { | ||||||
|   echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n"; |   echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\""; | ||||||
|  |   if ($step == 2) { | ||||||
|  |     echo "onsubmit=\"submitPreferences()\""; | ||||||
|  |   } | ||||||
|  |   echo ">\n"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| echo $result; | echo $result; | ||||||
|  | @ -153,23 +265,22 @@ if ($step != $max_step && $step >= 1) { | ||||||
|     echo "  <input type=\"hidden\" name=\"tmp_token\" value=\"".$tmp_token."\" />\n"; |     echo "  <input type=\"hidden\" name=\"tmp_token\" value=\"".$tmp_token."\" />\n"; | ||||||
|   } |   } | ||||||
|   if ($step > 2) { |   if ($step > 2) { | ||||||
|     if ($choices_nb == 1) |       $index=0; | ||||||
|       echo "  <input type=\"hidden\" name=\"vote\" value=\"".$vote."\" />\n"; | 
 | ||||||
|     else { |       foreach ($votes_array as $vote) { | ||||||
|       foreach ($choices as $choice) { |   	$index++; | ||||||
|         $name = "vote".$choice["id"]; |         $name = "pref".$index; | ||||||
|         if (in_array ($choice["id"], $votes_array)) |         $value = "vote".$vote; | ||||||
|           $value = "on"; |  | ||||||
|         else |  | ||||||
|           $value = ""; |  | ||||||
| 
 | 
 | ||||||
|         echo "  <input type=\"hidden\" name=\"".$name."\" value=\"".$value."\" />\n"; |         echo "  <input type=\"hidden\" name=\"".$name."\" value=\"".$value."\" />\n"; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   } |  | ||||||
|   echo "  <input type=\"hidden\" name=\"election_id\" value=\"".$election_id."\" />\n"; |   echo "  <input type=\"hidden\" name=\"election_id\" value=\"".$election_id."\" />\n"; | ||||||
|   echo "  <input type=\"hidden\" name=\"step\" value=\"".($step + 1)."\" />\n"; |   echo "  <input type=\"hidden\" name=\"step\" value=\"".($step + 1)."\" />\n"; | ||||||
|   echo "  <input type=\"submit\" value=\"Continue to next step\" />\n"; |   echo "  <input type=\"submit\" value=\"Continue to next step\" />\n"; | ||||||
|   echo "</form>\n"; |   echo "</form>\n"; | ||||||
| } | } | ||||||
| ?> | ?> | ||||||
|  | </body> | ||||||
|  | </html> | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -66,7 +66,8 @@ if ($display) { | ||||||
|     $choices_name[$choice["id"]] = $choice["choice"]; |     $choices_name[$choice["id"]] = $choice["choice"]; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   echo "<p>Please look at the <a href=\"results.php?election_id=".$election_id."\">automatic results</a> to have a summary of the votes.</p>\n"; |   echo "<p>Please look at the <a href=\"results.php?election_id=".$election_id."\">automatic results</a> to have a summary of the votes. "; | ||||||
|  |   echo "You can also <a href=\"blt.php?election_id=".$election_id."\">download the ballots</a> in the OpenSTV .blt file format and verify the results.</p>\n"; | ||||||
| 
 | 
 | ||||||
|   echo "<p>Please note that these results are automatically calculated and are thus not the official results.</p>\n"; |   echo "<p>Please note that these results are automatically calculated and are thus not the official results.</p>\n"; | ||||||
| 
 | 
 | ||||||
|  | @ -92,14 +93,16 @@ if ($display) { | ||||||
|     } else if (count ($votes) == 0) { |     } else if (count ($votes) == 0) { | ||||||
|       echo "This member chose to vote for<br />none of the possible choices."; |       echo "This member chose to vote for<br />none of the possible choices."; | ||||||
|     } else { |     } else { | ||||||
|  |       echo "<ol>"; | ||||||
|       foreach ($votes as $vote) { |       foreach ($votes as $vote) { | ||||||
|         if (array_key_exists ($vote, $choices_name)) |         if (array_key_exists ($vote["choice_id"], $choices_name)) | ||||||
|           echo "<em>".$choices_name[$vote]."</em><br />\n"; |           echo "<li><em>".$votes["preference"]." ".$choices_name[$vote["choice_id"]]."</em></li>\n"; | ||||||
|         else { |         else { | ||||||
|           echo "<em>Unknown value (".$vote.")</em><br />\n"; |           echo "<li><em>Unknown value (".$vote["choice_id"].")</em></li>\n"; | ||||||
|           $error .= "There was an unkown vote for anonymous token ".$anon_token["anon_token"].": ".$vote."<br />\n"; |           $error .= "There was an unkown vote for anonymous token ".$anon_token["anon_token"].": ".$vote["choice_id"]."<br />\n"; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |       echo "</ol>"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     echo "</td>\n"; |     echo "</td>\n"; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Tobias Mueller
						Tobias Mueller