Mercurial > hg > fapweb
comparison admajax.php @ 435:7f950ab60be4
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Dec 2013 22:43:23 +0200 |
parents | d948f1f12b23 |
children | cefa64c8be63 |
comparison
equal
deleted
inserted
replaced
434:d948f1f12b23 | 435:7f950ab60be4 |
---|---|
1276 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) | 1276 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
1277 { | 1277 { |
1278 if ($type == "attendees" && stValidateRequestUserData(TRUE)) | 1278 if ($type == "attendees" && stValidateRequestUserData(TRUE)) |
1279 { | 1279 { |
1280 $sql = stPrepareSQLUpdate("attendees", | 1280 $sql = stPrepareSQLUpdate("attendees", |
1281 "WHERE id=".intval(stGetRequestItem("id")), | 1281 "WHERE id=".$id, |
1282 array( | 1282 array( |
1283 "name" => "S", | 1283 "name" => "S", |
1284 "groups" => "S", | 1284 "groups" => "S", |
1285 "email" => "S", | 1285 "email" => "S", |
1286 "oneliner" => "S", | 1286 "oneliner" => "S", |
1290 } | 1290 } |
1291 else | 1291 else |
1292 if ($type == "news" && stValidateRequestNewsData()) | 1292 if ($type == "news" && stValidateRequestNewsData()) |
1293 { | 1293 { |
1294 $sql = stPrepareSQLUpdate("news", | 1294 $sql = stPrepareSQLUpdate("news", |
1295 "WHERE id=".intval(stGetRequestItem("id")), | 1295 "WHERE id=".$id, |
1296 array( | 1296 array( |
1297 "title" => "S", | 1297 "title" => "S", |
1298 "text" => "Q", | 1298 "text" => "Q", |
1299 "author" => "S" | 1299 "author" => "S" |
1300 )); | 1300 )); |
1303 } | 1303 } |
1304 else | 1304 else |
1305 if ($type == "compo" && stValidateRequestCompoData(TRUE)) | 1305 if ($type == "compo" && stValidateRequestCompoData(TRUE)) |
1306 { | 1306 { |
1307 $sql = stPrepareSQLUpdate("compos", | 1307 $sql = stPrepareSQLUpdate("compos", |
1308 "WHERE id=".intval(stGetRequestItem("id")), | 1308 "WHERE id=".$id, |
1309 array( | 1309 array( |
1310 "name" => "S", | 1310 "name" => "S", |
1311 "description" => "Q", | 1311 "description" => "Q", |
1312 "visible" => "B", | 1312 "visible" => "B", |
1313 "voting" => "B", | 1313 "voting" => "B", |
1324 stError("No such compo ID."); | 1324 stError("No such compo ID."); |
1325 } | 1325 } |
1326 else | 1326 else |
1327 { | 1327 { |
1328 $sql = stPrepareSQLUpdate("entries", | 1328 $sql = stPrepareSQLUpdate("entries", |
1329 "WHERE id=".intval(stGetRequestItem("id")), | 1329 "WHERE id=".$id, |
1330 array( | 1330 array( |
1331 "name" => "S", | 1331 "name" => "S", |
1332 "author" => "S", | 1332 "author" => "S", |
1333 "filename" => "S", | 1333 "filename" => "S", |
1334 "info" => "Q", | 1334 "info" => "Q", |
1336 )); | 1336 )); |
1337 | 1337 |
1338 stExecSQLCond($sql, "OK, entry updated."); | 1338 stExecSQLCond($sql, "OK, entry updated."); |
1339 } | 1339 } |
1340 } | 1340 } |
1341 else | 1341 } |
1342 if ($type == "votekey") | 1342 break; |
1343 { | 1343 |
1344 switch (stGetRequestItem("mode")) | 1344 case "votekey": |
1345 { | 1345 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
1346 case "assign": | 1346 { |
1347 // Check if already assigned to someone .. | 1347 switch ($type) |
1348 $key_id = intval(stGetRequestItem("key_id", 0)); | 1348 { |
1349 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%d", $key_id); | 1349 case "assign": |
1350 if (stFetchSQL($sql) === false) | 1350 // Check if already assigned to someone .. |
1351 stError("Invalid key ID #."); | 1351 $key_id = intval(stGetRequestItem("key_id", 0)); |
1352 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%d", $key_id); | |
1353 if (stFetchSQL($sql) === false) | |
1354 stError("Invalid key ID #."); | |
1355 else | |
1356 { | |
1357 $sql = stPrepareSQL("SELECT * FROM attendees WHERE key_id=%d", $key_id); | |
1358 if (($attn = stFetchSQL($sql)) !== false && $attn["id"] != $id) | |
1359 stError("That key has already been assigned to another attendee!"); | |
1352 else | 1360 else |
1353 { | 1361 { |
1354 $sql = stPrepareSQL("SELECT * FROM attendees WHERE key_id=%d", $key_id); | 1362 // Assign .. |
1355 if (($attn = stFetchSQL($sql)) !== false && $attn["id"] != $id) | 1363 $sql = stPrepareSQL("UPDATE attendees SET key_id=%d WHERE id=%d", $key_id, $id); |
1356 stError("That key has already been assigned to another attendee!"); | 1364 stExecSQLCond($sql, "Assigned key updated."); |
1357 else | |
1358 { | |
1359 // Assign .. | |
1360 $sql = stPrepareSQL("UPDATE attendees SET key_id=%d WHERE id=%d", $key_id, $id); | |
1361 stExecSQLCond($sql, "Assigned key updated."); | |
1362 } | |
1363 } | 1365 } |
1364 break; | 1366 } |
1365 | 1367 break; |
1366 case "clear": | 1368 |
1367 $sql = stPrepareSQL("UPDATE attendees SET key_id=NULL WHERE id=%D", "id"); | 1369 case "clear": |
1368 stExecSQLCond($sql, "Assigned key cleared."); | 1370 $sql = stPrepareSQL("UPDATE attendees SET key_id=NULL WHERE id=%d", $id); |
1369 break; | 1371 stExecSQLCond($sql, "Assigned key cleared."); |
1370 | 1372 break; |
1371 case "active": | 1373 |
1372 // Autobots activate! | 1374 case "active": |
1373 $sql = stPrepareSQL("UPDATE votekeys SET active=%B WHERE id=%D", "active", "id"); | 1375 // Autobots activate! |
1374 stExecSQLCond($sql, "Votekey status changed."); | 1376 $sql = stPrepareSQL("UPDATE votekeys SET active=%B WHERE id=%d", "active", $id); |
1375 break; | 1377 stExecSQLCond($sql, "Votekey status changed."); |
1376 } | 1378 break; |
1377 } | 1379 } |
1378 } | 1380 } |
1379 break; | 1381 break; |
1380 | 1382 |
1381 default: | 1383 default: |