Mercurial > hg > fapweb
comparison usrajax.php @ 153:aecf145e7c70
Some work on the voting backend.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 25 Oct 2013 15:07:43 +0300 |
parents | 5837b9333964 |
children | 5b92f130ba87 |
comparison
equal
deleted
inserted
replaced
152:6e6fba2da3d1 | 153:aecf145e7c70 |
---|---|
90 } | 90 } |
91 break; | 91 break; |
92 | 92 |
93 case "set": | 93 case "set": |
94 // | 94 // |
95 // Set vote | 95 // Set vote, if voting is enabled |
96 // | 96 // |
97 if ($type == "votes" && stChkRequestItem("voter_id") && | 97 if ($type == "votes" && stChkSetting("allowVoting") && |
98 stChkRequestItem("entry_id") && stChkRequestItem("vote")) | 98 stChkRequestItem("votekey") && |
99 stChkRequestItem("entry_id") && | |
100 stChkRequestItem("vote")) | |
99 { | 101 { |
100 stGetCompoList(FALSE); | 102 // Check if voting is enabled on the compo and voter is valid |
103 $entry_id = stGetRequestItem("entry_id"); | |
104 | |
105 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE key=%s", stGetRequestItem("votekey")); | |
106 if (($votekey = stFetchSQLColumn($sql)) !== false) | |
107 { | |
108 } | |
101 | 109 |
102 stSubmitOneVote(stGetRequestItem("voter_id"), stGetRequestItem("entry_id"), stGetRequestItem("vote")); | 110 |
111 $sql = stPrepareSQL("SELECT * FROM entries WHERE id=%d", $entry_id); | |
112 if (($entry = stFetchSQL($sql)) !== false) | |
113 { | |
114 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$entry["compo_id"])) !== false | |
115 && $compo["voting"] != 0) | |
116 { | |
117 stSubmitOneVote(stGetRequestItem("voter_id"), $entry_id, stGetRequestItem("vote")); | |
118 } | |
119 else | |
120 stSetStatus(902, "Voting not enabled on that compo."); | |
121 } | |
122 else | |
123 stSetStatus(902, "No such entry."); | |
103 } | 124 } |
104 else | 125 else |
105 stSetStatus(902, "No data."); | 126 stSetStatus(902, "No data."); |
106 break; | 127 break; |
107 | 128 |