diff admajax.php @ 608:7d676c77e3f8

Add functionality for deleting a compo.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 31 Oct 2014 23:13:44 +0200
parents a42efdc2cca7
children b75ec194de52
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")