annotate vote.inc.php @ 333:018817535fab

Make voting more visually pleasant(?).
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 28 Nov 2013 04:45:24 +0200
parents 78521cac3a42
children 87e57f0aa0e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
151
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
2 //
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
3 // FAPWeb Simple Demoparty System
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
4 // Competition voting page
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
6 //
98
0f00192e64af Obey userKeyLength site setting here when printing voting login.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
7 $sessionType = "user";
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 151
diff changeset
8 require_once "majax.php";
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
9
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
10
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
11 function stGetVoteButton()
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
12 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
13 return
326
64c28792ae08 Clarify voting form.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
14 " <div class=\"votectrl\">\n".
64c28792ae08 Clarify voting form.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
15 " ".stGetFormSubmitInput("vote", "Submit votes and log out", "")."\n".
64c28792ae08 Clarify voting form.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
16 " </div>\n";
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
17 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
18
127
6b71472cda77 A tiny bit of work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
19
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 // Check if voting is enabled
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 if (!stChkSetting("allowVoting"))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 {
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
23 echo
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
24 "<h1>Sorry, voting disabled!</h1>\n".
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
25 "<p>Voting functionality not available at this time.</p>\n";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 else
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
28 if (!stUserSessionAuth(FALSE))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 {
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
30 // Perform authentication if we are not in session already
190
a14663f6497d Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
31 $userKeyLen = stGetSetting("userKeyLength");
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
32
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
33 if (($error = stGetRequestItem("error", 0)) != 0)
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
34 {
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
35 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
36 "<h1>Voting system login failed</h1>\n".
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
37 "<p class=\"notice\">\n";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
38
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
39 switch ($error)
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
40 {
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
41 case 1:
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
42 echo "The votekey does not exist. Please try again.";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
43 break;
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
44
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
45 case 2:
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
46 echo "There was an error in the system. Contact an administrator.";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
47 break;
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
48
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
49 case 3:
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
50 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
51 "The votekey is not yet activated, try again later. If ".
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
52 "you are certain that it should be working now, go pester an organizer.";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
53 break;
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
54 }
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
55
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
56 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
57 "</p>\n";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
58 }
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
59 else
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
60 {
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
61 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
62 "<h1>Voting system</h1>\n";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
63 }
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
64
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
65 echo
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
66 stGetFormStart("vote", "usrlogin.php").
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
67 " ".stGetFormHiddenInput("mode", "vote")."\n".
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
68 " ".stGetFormHiddenInput("goto", "vote")."\n".
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
69 " <div class=\"votectrl\">\n".
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
70 " Enter your vote key:\n".
248
8d46f1358233 Add autofocus in vote login as well.
Matti Hamalainen <ccr@tnsp.org>
parents: 242
diff changeset
71 " ".stGetFormTextInput($userKeyLen > 30 ? $userKeyLen : 30, $userKeyLen, "key", "", "", "", "autocomplete=\"off\" autofocus=\"autofocus\"")."\n".
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
72 " ".stGetFormSubmitInput("login", "Login")."\n".
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
73 " </div>\n".
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
74 "</form>\n";
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
75 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
76 else
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
77 if (($mode = stGetSessionItem("mode")) == "vote")
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
78 {
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 117
diff changeset
79 stCommonAJAX("usrajax.php", "usrlogout.php", TRUE);
285
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
80 ?>
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
81 <script type="text/javascript">
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
82
285
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
83 function updateVote(eid, value)
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
84 {
330
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
85 var msuccess = function(txt)
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
86 {
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
87 }
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
88
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
89 var mfail = function(txt)
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
90 {
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
91 alert("Something went wrong. :(");
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
92 }
78521cac3a42 Add an error dialog.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
93
325
aac3bdd73ec1 More work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
94 sendPOSTRequest("action=set&entry_id="+eid+"&vote="+value, msuccess, mfail);
285
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
95 return false;
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
96 }
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
97
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
98 </script>
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
99 <?
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
100 // Try fetching previously stored votes
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
101 $sql = stPrepareSQL(
302
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 295
diff changeset
102 "SELECT entry_id,value FROM votes WHERE key_id=%d",
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 295
diff changeset
103 stGetSessionItem("key_id"));
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
104
221
2b39068c4968 Tiny bit of work on voting code.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
105 $votes = array();
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
106 if (($res = stExecSQL($sql)) !== false)
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
107 {
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
108 foreach ($res as $vote)
221
2b39068c4968 Tiny bit of work on voting code.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
109 $votes[$vote["entry_id"]] = $vote["value"];
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
110 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
112 // Output voting system HTML
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
113 echo
276
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
114 "<h1>Voting system</h1>\n".
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
115 stGetFormStart("vote", "usrajax.php").
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
116 " ".stGetFormHiddenInput("mode", "done")."\n".
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
117 " ".stGetFormHiddenInput("action", "submit")."\n".
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
118 stGetVoteButton();
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
119
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
120 foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0") as $compo)
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
121 {
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
122 $cid = $compo["id"];
277
f20df1da0903 Fix some 10L's.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
123 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$cid);
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
124 if ($nentries > 0)
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
125 {
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
126 echo
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
127 " <table class=\"vote\">\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
128 " <tr><th colspan=\"".($compo["showAuthors"] ? "3" : "2")."\">".chentities($compo["name"])."</th></tr>\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
129 " <tr>\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
130 " <th class=\"vshown\">#</th>\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
131 " <th class=\"vtitle\">Title</th>\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
132 ($compo["showAuthors"] ? " <th class=\"vauthor\">Author</th>\n" : "").
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
133 " ";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
135 for ($i = stGetSetting("voteMax"); $i >= stGetSetting("voteMin"); $i--)
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
136 {
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
137 echo "<th class=\"vvalue\">".$i."</th>";
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
138 }
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
139 echo "\n".
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
140 " </tr>\n";
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
141
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
142 $row = 0;
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
143 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$cid) as $entry)
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
144 {
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
145 $eid = $entry["id"];
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
146 echo
295
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
147 " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n".
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
148 " <td class=\"vshown\">".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n".
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
149 " <td class=\"vtitle\">".$entry["name"]."</td>\n".
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
150 ($compo["showAuthors"] ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : "").
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
151 " ";
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
152
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
153 $val = isset($votes[$eid]) ? $votes[$eid] : 0;
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
154
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
155 for ($i = stGetSetting("voteMax"); $i >= stGetSetting("voteMin"); $i--)
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
156 {
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
157 $nid = "ve".$eid."_".$i;
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
158 echo
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
159 "<td class=\"vvalue\">".
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
160 "<input type=\"radio\" id=\"".$nid.
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
161 "\" name=\"ventry".$eid."\" value=\"".$i."\" ".
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
162 "onClick=\"updateVote(".$eid.",".$i.")\" ".
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
163 ($val == $i ? "checked=\"checked\" ": "")."/>".
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
164 "<label for=\"".$nid."\"></label>".
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
165 "</td>";
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
166 }
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
167
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
168 echo
295
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
169 "\n".
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
170 " </tr>\n";
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
171
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
172 $row++;
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
173 }
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
174 echo
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
175 " </table>\n";
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
176 }
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
177 }
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
178
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
179 echo
225
1bb4f4bcb027 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 221
diff changeset
180 stGetVoteButton().
1bb4f4bcb027 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 221
diff changeset
181 "</form>\n";
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
182 }
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
183 else
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
184 if ($mode == "done")
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
185 {
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
186 // Voting finished
226
548a106b3f5b Use setting instead of hardcoded text.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
187 echo stGetSetting("voteFinishedText");
325
aac3bdd73ec1 More work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 304
diff changeset
188 echo "<p>Or perhaps <a href=\"vote\">vote again!</a></p>\n";
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
189 stSessionEnd(SESS_USER);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 }
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
191 ?>