Mercurial > hg > fapweb
changeset 608:7d676c77e3f8
Add functionality for deleting a compo.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 31 Oct 2014 23:13:44 +0200 |
parents | e78d90ca4f4a |
children | b75ec194de52 |
files | admajax.php admin.js |
diffstat | 2 files changed, 38 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Fri Oct 31 23:10:47 2014 +0200 +++ b/admajax.php Fri Oct 31 23:13:44 2014 +0200 @@ -1347,6 +1347,31 @@ $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id); stExecSQLCond($sql, "OK, entry ".$id." votes deleted."); } + else + if ($type == "compo") + { + stDBBeginTransaction(); + + // Delete votes for compo entry + foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$id) as $sentry) + { + stExecSQLCond( + "DELETE FROM votes WHERE entry_id=".$sentry["id"], + "OK, entry ".$sentry["id"]." votes deleted."); + } + + // Delete entries for the compo + stExecSQLCond( + "DELETE FROM entries WHERE compo_id=".$id, + "OK, compo entries for compo ".$id." deleted."); + + // Delete the compo itself + stExecSQLCond( + "DELETE FROM compos WHERE id=".$id, + "OK, compo ".$id." deleted."); + + stDBCommitTransaction(); + } } else if ($type == "votekeys")
--- a/admin.js Fri Oct 31 23:10:47 2014 +0200 +++ b/admin.js Fri Oct 31 23:13:44 2014 +0200 @@ -42,7 +42,7 @@ } -function jsDeleteItem(id,prefix,type,func,dsc) +function jsDeleteItem(id,prefix,type,func,dsc,dsc2) { var msuccess = function(txt) { @@ -68,7 +68,10 @@ item.style.background = tmp; } - jsConfirmBox("Are you sure you want to delete "+dsc+" #"+id+"?", mcb_ok, mcb_cancel, 0); + if (dsc) + jsConfirmBox("Are you sure you want to delete "+dsc+" #"+id+"?", mcb_ok, mcb_cancel, 0); + else + jsConfirmBox(dsc2, mcb_ok, mcb_cancel, 0); } @@ -275,6 +278,14 @@ } +function deleteCompo(id) +{ + jsDeleteItem(id, "compo", "compo", "refreshDispatchCC('Compos');", 0, + "Are you ABSOLUTELY sure you want to delete compo #"+id+"? "+ + "This will delete all votes AND entries related to it!"); +} + + function addEntry(id) { var args = jsMakePostArgs({"name":1, "author":1, "filename":1, "info":1}, "ne", id);