comparison usrajax.php @ 1104:0a2117349f46

s/true/TRUE/g; s/false/FALSE/g;
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 May 2019 14:45:36 +0300
parents 95b74632cfe2
children
comparison
equal deleted inserted replaced
1103:1fe7df7c77fb 1104:0a2117349f46
16 { 16 {
17 // Check if the vote already exists 17 // Check if the vote already exists
18 $sql = stPrepareSQL("SELECT id FROM votes WHERE key_id=%d AND entry_id=%d", 18 $sql = stPrepareSQL("SELECT id FROM votes WHERE key_id=%d AND entry_id=%d",
19 $key_id, $entry_id); 19 $key_id, $entry_id);
20 20
21 if (($res = stFetchSQLColumn($sql)) === false) 21 if (($res = stFetchSQLColumn($sql)) === FALSE)
22 { 22 {
23 // Didn't exist, insert it 23 // Didn't exist, insert it
24 $sql = stPrepareSQL( 24 $sql = stPrepareSQL(
25 "INSERT INTO votes (key_id,entry_id,value,utime) VALUES (%d,%d,%d,%d)", 25 "INSERT INTO votes (key_id,entry_id,value,utime) VALUES (%d,%d,%d,%d)",
26 $key_id, $entry_id, $vote, time()); 26 $key_id, $entry_id, $vote, time());
83 83
84 // 84 //
85 // Check vote key validity 85 // Check vote key validity
86 // 86 //
87 $sql = stPrepareSQL("SELECT * FROM userkeys WHERE id=%d", $userKeyId); 87 $sql = stPrepareSQL("SELECT * FROM userkeys WHERE id=%d", $userKeyId);
88 if (($key = stFetchSQL($sql)) === false) 88 if (($key = stFetchSQL($sql)) === FALSE)
89 { 89 {
90 stError("Userkey does not exist."); 90 stError("Userkey does not exist.");
91 } 91 }
92 else 92 else
93 { 93 {
99 stError("Userkey is not active."); 99 stError("Userkey is not active.");
100 break; 100 break;
101 101
102 case VOTE_ASSIGN: 102 case VOTE_ASSIGN:
103 $sql = stPrepareSQL("SELECT id FROM attendees WHERE key_id=%d", $key["id"]); 103 $sql = stPrepareSQL("SELECT id FROM attendees WHERE key_id=%d", $key["id"]);
104 if (stFetchSQL($sql) === false) 104 if (stFetchSQL($sql) === FALSE)
105 stError("Userkey is not assigned to any user."); 105 stError("Userkey is not assigned to any user.");
106 break; 106 break;
107 } 107 }
108 } 108 }
109 109
125 stCheckVoteValue("vote", $vote)) 125 stCheckVoteValue("vote", $vote))
126 { 126 {
127 // Check if the entry_id is actually valid 127 // Check if the entry_id is actually valid
128 stDBBeginTransaction(); 128 stDBBeginTransaction();
129 $sql = stPrepareSQL("SELECT * FROM entries WHERE id=%d", $entry_id); 129 $sql = stPrepareSQL("SELECT * FROM entries WHERE id=%d", $entry_id);
130 if (($entry = stFetchSQL($sql)) !== false) 130 if (($entry = stFetchSQL($sql)) !== FALSE)
131 { 131 {
132 // Check if the compo is valid for the entry 132 // Check if the compo is valid for the entry
133 $sql = stPrepareSQL("SELECT * FROM compos WHERE id=%d", $entry["compo_id"]); 133 $sql = stPrepareSQL("SELECT * FROM compos WHERE id=%d", $entry["compo_id"]);
134 if (($compo = stFetchSQL($sql)) !== false && $compo["voting"] != 0) 134 if (($compo = stFetchSQL($sql)) !== FALSE && $compo["voting"] != 0)
135 stUpdateVote($userKeyId, $entry_id, $vote); 135 stUpdateVote($userKeyId, $entry_id, $vote);
136 } 136 }
137 stDBCommitTransaction(); 137 stDBCommitTransaction();
138 } 138 }
139 break; 139 break;