comparison usrajax.php @ 1092:95b74632cfe2

Rename votekeys table to userkeys, and all related variables and settings.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 26 Jan 2017 13:38:19 +0200
parents 4c76b4994414
children 0a2117349f46
comparison
equal deleted inserted replaced
1091:c4b93729269d 1092:95b74632cfe2
77 if (!stConnectSQLDB()) 77 if (!stConnectSQLDB())
78 die("Could not connect to SQL database."); 78 die("Could not connect to SQL database.");
79 79
80 stReloadSettings(); 80 stReloadSettings();
81 81
82 $voteKeyId = stGetSessionItem("key_id"); 82 $userKeyId = stGetSessionItem("key_id");
83 83
84 // 84 //
85 // Check vote key validity 85 // Check vote key validity
86 // 86 //
87 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%d", $voteKeyId); 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("Votekey does not exist."); 90 stError("Userkey does not exist.");
91 } 91 }
92 else 92 else
93 { 93 {
94 // Validate login based on current vote key mode 94 // Validate login based on current vote key mode
95 switch (stGetSetting("voteKeyMode")) 95 switch (stGetSetting("userKeyMode"))
96 { 96 {
97 case VOTE_ACTIVATE: 97 case VOTE_ACTIVATE:
98 if ($key["active"] == 0) 98 if ($key["active"] == 0)
99 stError("Votekey 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("Votekey 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
110 // 110 //
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($voteKeyId, $entry_id, $vote); 135 stUpdateVote($userKeyId, $entry_id, $vote);
136 } 136 }
137 stDBCommitTransaction(); 137 stDBCommitTransaction();
138 } 138 }
139 break; 139 break;
140 140
151 stDBBeginTransaction(); 151 stDBBeginTransaction();
152 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) 152 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
153 { 153 {
154 if (stCheckVoteValue("ventry".$entry["id"], $value)) 154 if (stCheckVoteValue("ventry".$entry["id"], $value))
155 { 155 {
156 if (!stUpdateVote($voteKeyId, $entry["id"], $value)) 156 if (!stUpdateVote($userKeyId, $entry["id"], $value))
157 stError("Could not set vote for compo #".$compo["id"].", entry #".$entry["id"]); 157 stError("Could not set vote for compo #".$compo["id"].", entry #".$entry["id"]);
158 } 158 }
159 } 159 }
160 stDBCommitTransaction(); 160 stDBCommitTransaction();
161 } 161 }