changeset 722:bf33cec02dc6

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 18 Nov 2014 20:00:41 +0200
parents 69a829f687a9
children 5ef230336e67
files usrajax.php
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/usrajax.php	Tue Nov 18 19:19:10 2014 +0200
+++ b/usrajax.php	Tue Nov 18 20:00:41 2014 +0200
@@ -90,9 +90,7 @@
         // Check if the compo is valid for the entry
         $sql = stPrepareSQL("SELECT * FROM compos WHERE id=%d", $entry["compo_id"]);
         if (($compo = stFetchSQL($sql)) !== false && $compo["voting"] != 0)
-        {
           stUpdateVote($voteKeyId, $entry_id, $vote);
-        }
       }
       stDBCommitTransaction();
     }
@@ -103,21 +101,19 @@
       stError("Voting is not enabled.");
     else
     {
-      stDBBeginTransaction();
       foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0") as $compo)
       {
-        $cid = $compo["id"];
-        foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$cid) as $entry)
+        stDBBeginTransaction();
+        foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
         {
           $value = stGetRequestItem("ventry".$entry["id"], 0);
           if (!stUpdateVote($voteKeyId, $entry["id"], $value))
           {
-            stError("Could not set vote for compo #".$cid.", entry #".$entry["id"]);
-            break;
+            stError("Could not set vote for compo #".$compo["id"].", entry #".$entry["id"]);
           }
         }
+        stDBCommitTransaction();
       }
-      stDBCommitTransaction();
 
       if ($errorSet)
       {