annotate pages/vote.inc.php @ 1096:bbc0a3d0b51e

Major renaming / refactor of site messages. Some that were previously modifiable from admin interface are now "hardcoded" in the configuration file. Having these settings made modifiable from there made no sense and just took space in the UI.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 27 Jan 2017 22:15:06 +0200
parents 95b74632cfe2
children b2bca5f6d0ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1075
7e497188e4c6 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1069
diff changeset
1 <?php
151
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
2 //
571
ce11ea112a65 Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 565
diff changeset
3 // FAPWeb - Simple Web-based Demoparty Management System
151
a778629edff9 Add copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
4 // Competition voting page
1001
ffacd904fd1f Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 999
diff changeset
5 // (C) Copyright 2012-2015 Tecnic Software productions (TNSP)
151
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";
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
8
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
9
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
10 function stGetVoteButton()
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
11 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
12 return
709
1a9005eafb37 Change some element names.
Matti Hamalainen <ccr@tnsp.org>
parents: 708
diff changeset
13 " <div class=\"voteControls\">\n".
326
64c28792ae08 Clarify voting form.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
14 " ".stGetFormSubmitInput("vote", "Submit votes and log out", "")."\n".
64c28792ae08 Clarify voting form.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
15 " </div>\n";
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
16 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
17
1087
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
18 function stVoteLoginForm()
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
19 {
1088
4f132374df75 Fix a 10L.
Matti Hamalainen <ccr@tnsp.org>
parents: 1087
diff changeset
20 $userKeyLen = stGetSetting("userKeyLength");
1087
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
21 return
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
22 "<div class=\"voteLogin\">\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
23 " ".stGetFormStart("vote", "usrlogin.php").
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
24 " ".stGetFormHiddenInput("mode", "vote")."\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
25 " ".stGetFormHiddenInput("goto", "vote")."\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
26 " Enter your vote key:\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
27 " ".stGetFormTextInput($userKeyLen > 30 ? $userKeyLen : 30, $userKeyLen, "key", "", "", "", "autocomplete=\"off\" autofocus=\"autofocus\"")."\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
28 " ".stGetFormSubmitInput("login", "Login")."\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
29 " </form>\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
30 "</div>\n";
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
31 }
127
6b71472cda77 A tiny bit of work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
32
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 // Check if voting is enabled
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 if (!stChkSetting("allowVoting"))
1096
bbc0a3d0b51e Major renaming / refactor of site messages. Some that were previously
Matti Hamalainen <ccr@tnsp.org>
parents: 1092
diff changeset
35 echo stGetSetting("msgVotingDisabled");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 else
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
37 if (!stUserSessionAuth(FALSE))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 {
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
39 // Perform authentication if we are not in session already
358
0244aeeab6e7 Use GET for error parameter.
Matti Hamalainen <ccr@tnsp.org>
parents: 343
diff changeset
40 if (($error = stGetRequestItem("error", 0, TRUE)) != 0)
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
41 {
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
42 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
43 "<h1>Voting system login failed</h1>\n".
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
44 "<p class=\"notice\">\n";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
45
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
46 switch ($error)
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
47 {
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
48 case 1:
1092
95b74632cfe2 Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 1088
diff changeset
49 echo "The userkey does not exist. Please try again.";
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
50 break;
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
51
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
52 case 2:
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
53 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
54 break;
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 case 3:
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
57 echo
1092
95b74632cfe2 Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 1088
diff changeset
58 "The userkey is not yet activated, try again later. If ".
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
59 "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
60 break;
672
123aceb0ac4f Add undefined error case.
Matti Hamalainen <ccr@tnsp.org>
parents: 667
diff changeset
61
123aceb0ac4f Add undefined error case.
Matti Hamalainen <ccr@tnsp.org>
parents: 667
diff changeset
62 default:
123aceb0ac4f Add undefined error case.
Matti Hamalainen <ccr@tnsp.org>
parents: 667
diff changeset
63 echo
123aceb0ac4f Add undefined error case.
Matti Hamalainen <ccr@tnsp.org>
parents: 667
diff changeset
64 "Undefined error occured.";
123aceb0ac4f Add undefined error case.
Matti Hamalainen <ccr@tnsp.org>
parents: 667
diff changeset
65 break;
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
66 }
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
67
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
68 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
69 "</p>\n";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
70 }
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
71 else
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
72 {
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
73 echo
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
74 "<h1>Voting system</h1>\n";
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
75 }
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
76
1087
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
77 echo stVoteLoginForm();
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
78 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
79 else
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
80 if (($mode = stGetSessionItem("mode")) == "vote")
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
81 {
285
4c00e9cbb84e Work on the voting interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
82 ?>
999
3714c6c53529 Add helpful notice for people who have JavaScript disabled while voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 988
diff changeset
83 <noscript>
3714c6c53529 Add helpful notice for people who have JavaScript disabled while voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 988
diff changeset
84 <div class="notice">If your browser supports JavaScript, enable it for smoother voting experience.</div>
3714c6c53529 Add helpful notice for people who have JavaScript disabled while voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 988
diff changeset
85 </noscript>
1085
01783161eeb2 Fix usr and adm ajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1075
diff changeset
86 <script type="text/javascript" src="usrajax.js.php"></script>
1075
7e497188e4c6 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1069
diff changeset
87 <?php
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
88 // Try fetching previously stored votes
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
89 $sql = stPrepareSQL(
302
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 295
diff changeset
90 "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
91 stGetSessionItem("key_id"));
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
92
221
2b39068c4968 Tiny bit of work on voting code.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
93 $votes = array();
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
94 if (($res = stExecSQL($sql)) !== false)
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
95 {
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
96 foreach ($res as $vote)
221
2b39068c4968 Tiny bit of work on voting code.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
97 $votes[$vote["entry_id"]] = $vote["value"];
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
98 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
100 // Output voting system HTML
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
101 echo
276
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
102 "<h1>Voting system</h1>\n".
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
103 stGetFormStart("vote", "usrajax.php").
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
104 " ".stGetFormHiddenInput("mode", "done")."\n".
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
105 " ".stGetFormHiddenInput("action", "submit")."\n".
789
24bbd1f89794 Add few new settings, bump database version.
Matti Hamalainen <ccr@tnsp.org>
parents: 786
diff changeset
106 " ".stGetFormHiddenInput("onerror", "noauthvote")."\n".
276
92698b090c35 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 248
diff changeset
107 stGetVoteButton();
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
108
988
7d7bd913649c Order the compos on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 972
diff changeset
109 foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0 ORDER BY id") as $compo)
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
110 {
972
c1738ee91f6a Fix SQL for PostGres.
Matti Hamalainen <ccr@tnsp.org>
parents: 789
diff changeset
111 $esql = stPrepareSQL("FROM entries WHERE (flags & %d)=0 AND compo_id=%d", EFLAG_DISQUALIFIED, $compo["id"]);
598
ba84d8e35d6b Do not count entries that have been flagged as disqualified.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
112 $nentries = stFetchSQLColumn("SELECT COUNT(*) ".$esql);
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
113 if ($nentries > 0)
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
114 {
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
115 echo
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
116 " <table class=\"vote\">\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
117 " <tr>\n".
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
118 " <th class=\"vshown\">#</th>\n".
726
9a5e1087698a Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 721
diff changeset
119 " <th class=\"vcompo\">".chentities($compo["name"])."</th>\n";
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
120 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
121 {
708
114b77baf1c2 Mostly cosmetic changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 672
diff changeset
122 echo " <th class=\"vvalue\">".$i."</th>\n";
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
123 }
708
114b77baf1c2 Mostly cosmetic changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 672
diff changeset
124 echo
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
125 " </tr>\n";
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
126
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
127 $row = 0;
972
c1738ee91f6a Fix SQL for PostGres.
Matti Hamalainen <ccr@tnsp.org>
parents: 789
diff changeset
128 foreach (stExecSQL("SELECT * ".$esql." ORDER BY show_id ASC") as $entry)
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
129 {
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
130 $eid = $entry["id"];
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
131 echo
295
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
132 " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n".
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
133 " <td class=\"vshown\">".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n".
712
61c8bbc80e94 Some work on voting page.
Matti Hamalainen <ccr@tnsp.org>
parents: 710
diff changeset
134 " <td class=\"ventry\">\n".
729
0d064dcef03e Vote page layout adjustments and add missing </td> tag for entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
135 " <div class=\"vpreview\">";
712
61c8bbc80e94 Some work on voting page.
Matti Hamalainen <ccr@tnsp.org>
parents: 710
diff changeset
136
774
d6668b73bb01 Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents: 732
diff changeset
137 stPrintPreviewElements($compo, $entry);
721
69a829f687a9 Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 712
diff changeset
138
712
61c8bbc80e94 Some work on voting page.
Matti Hamalainen <ccr@tnsp.org>
parents: 710
diff changeset
139 echo
729
0d064dcef03e Vote page layout adjustments and add missing </td> tag for entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
140 "</div>\n".
712
61c8bbc80e94 Some work on voting page.
Matti Hamalainen <ccr@tnsp.org>
parents: 710
diff changeset
141 " <div class=\"vinfo\">".
61c8bbc80e94 Some work on voting page.
Matti Hamalainen <ccr@tnsp.org>
parents: 710
diff changeset
142 "<span class=\"vtitle\">".$entry["name"]."</span>".
61c8bbc80e94 Some work on voting page.
Matti Hamalainen <ccr@tnsp.org>
parents: 710
diff changeset
143 ($compo["show_authors"] ? "<span class=\"vby\"> by </span><span class=\"vauthor\">".$entry["author"]."</span>" : "").
729
0d064dcef03e Vote page layout adjustments and add missing </td> tag for entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
144 "</div>\n".
0d064dcef03e Vote page layout adjustments and add missing </td> tag for entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
145 " </td>\n";
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
146
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
147 $val = isset($votes[$eid]) ? $votes[$eid] : 0;
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
148
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
149 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
150 {
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
151 $nid = "ve".$eid."_".$i;
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
152 echo
729
0d064dcef03e Vote page layout adjustments and add missing </td> tag for entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
153 " <td class=\"vvalue\">".
333
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
154 "<input type=\"radio\" id=\"".$nid.
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
155 "\" name=\"ventry".$eid."\" value=\"".$i."\" ".
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
156 "onClick=\"updateVote(".$eid.",".$i.")\" ".
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
157 ($val == $i ? "checked=\"checked\" ": "")."/>".
018817535fab Make voting more visually pleasant(?).
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
158 "<label for=\"".$nid."\"></label>".
708
114b77baf1c2 Mostly cosmetic changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 672
diff changeset
159 "</td>\n";
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
160 }
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
161
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
162 echo
295
e387d717cf46 Indentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
163 " </tr>\n";
242
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
164
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
165 $row++;
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 echo
c52ca3a89989 Some random broken work on vote page.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
168 " </table>\n";
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
169 }
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
170 }
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
171
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
172 echo
225
1bb4f4bcb027 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 221
diff changeset
173 stGetVoteButton().
1bb4f4bcb027 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 221
diff changeset
174 "</form>\n";
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
175 }
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
176 else
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
177 if ($mode == "done")
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
178 {
1087
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
179 // Voting finished successfully
1096
bbc0a3d0b51e Major renaming / refactor of site messages. Some that were previously
Matti Hamalainen <ccr@tnsp.org>
parents: 1092
diff changeset
180 echo stGetSetting("msgVoteFinished");
68
3ae137411706 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
181 stSessionEnd(SESS_USER);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 }
1087
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
183 else
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
184 if ($mode == "error")
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
185 {
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
186 // Error cases in session, when using form submit
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
187 echo
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
188 "<h1>Voting system error</h1>\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
189 "<ul class=\"notice\">\n";
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
190
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
191 foreach (stGetSessionItem("error") as $msg)
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
192 echo " <li>".chentities($msg)."</li>\n";
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
193
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
194 echo
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
195 "</ul>\n".
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
196 stVoteLoginForm();
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
197
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
198 stSessionEnd(SESS_USER);
4c76b4994414 Somewhat refactor usrajax and voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 1085
diff changeset
199 }
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents: 98
diff changeset
200 ?>