# HG changeset patch # User Matti Hamalainen # Date 1354867502 -7200 # Node ID 5bc8bd5c7ecc580e053fa7015fa48a00ccb4802c # Parent e6ffab8414ccb12ce68014857b2d6854d7de1e26 Make voting toggle for individual compos. diff -r e6ffab8414cc -r 5bc8bd5c7ecc admin.inc.php --- a/admin.inc.php Thu Dec 06 23:08:46 2012 +0200 +++ b/admin.inc.php Fri Dec 07 10:05:02 2012 +0200 @@ -315,7 +315,7 @@ function updateCompo(id) { - var args = makePostArgs({"name":1, "description":1, "enabled":3}, "co", id); + var args = makePostArgs({"name":1, "description":1, "visible":3, "voting":3}, "co", id); sendPOSTRequest("action=update&type=compo&id="+id+"&"+args); } diff -r e6ffab8414cc -r 5bc8bd5c7ecc ajax.php --- a/ajax.php Thu Dec 06 23:08:46 2012 +0200 +++ b/ajax.php Fri Dec 07 10:05:02 2012 +0200 @@ -140,7 +140,7 @@ break; case "entries": - stGetCompoList(TRUE); + stGetCompoList(FALSE, FALSE); foreach ($compos as $id => $compo) { @@ -229,7 +229,8 @@ "
\n". "

#".$id." - ".chentities($item["name"])."

\n". stGetFormTextInput(40, 64, "name", $id, $prefix, $item["name"])."\n". - stGetFormCheckBoxInput("enabled", $id, $prefix, $item["enabled"], "Enabled")."
\n". + stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n". + stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."
\n". stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n
\n". stGetFormButtonInput("update", $id, $prefix, " Update ", "updateCompo(".$id.")")."\n". "
\n". @@ -352,14 +353,15 @@ else if ($type == "compo" && stChkRequestItem("id") && stChkRequestItem("name") && stChkRequestItem("description") && - stChkRequestItem("enabled")) + stChkRequestItem("visible") && stChkRequestItem("voting")) { $sql = stPrepareSQLUpdate("compos", "WHERE id=".intval(stGetRequestItem("id")), array( "name" => "S", "description" => "Q", - "enabled" => "B", + "visible" => "B", + "voting" => "B", )); execSQLCond($sql, "OK, compo updated."); diff -r e6ffab8414cc -r 5bc8bd5c7ecc compos.inc.php --- a/compos.inc.php Thu Dec 06 23:08:46 2012 +0200 +++ b/compos.inc.php Fri Dec 07 10:05:02 2012 +0200 @@ -47,7 +47,7 @@ return $str; } -$sql = "SELECT * FROM compos WHERE enabled<>0 ORDER BY id ASC"; +$sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY id ASC"; if (($res = stExecSQL($sql)) !== FALSE) { diff -r e6ffab8414cc -r 5bc8bd5c7ecc createdb.php --- a/createdb.php Thu Dec 06 23:08:46 2012 +0200 +++ b/createdb.php Fri Dec 07 10:05:02 2012 +0200 @@ -119,7 +119,7 @@ $sqlTables = array( "news" => "id INTEGER PRIMARY KEY AUTOINCREMENT, utime INT, title VARCHAR(128), text VARCHAR(4096), author VARCHAR(64), persist INT DEFAULT 0", "attendees" => "id INTEGER PRIMARY KEY AUTOINCREMENT, regtime INT, name VARCHAR(64), groups VARCHAR(64), oneliner VARCHAR(64), email VARCHAR(80)", - "compos" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(128), description VARCHAR(4096), enabled INT DEFAULT 0", + "compos" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(128), description VARCHAR(4096), visible INT DEFAULT 0, voting INT DEFAULT 0", "entries" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(64), author VARCHAR(64), compo_id INT DEFAULT NULL", "voters" => "id INTEGER PRIMARY KEY AUTOINCREMENT, key VARCHAR(64), name VARCHAR(64), enabled INT DEFAULT 0", "votes" => "id INTEGER PRIMARY KEY AUTOINCREMENT, entry_id INT DEFAULT NULL, voter_id INT DEFAULT NULL, value INT DEFAULT 0", diff -r e6ffab8414cc -r 5bc8bd5c7ecc msite.inc.php --- a/msite.inc.php Thu Dec 06 23:08:46 2012 +0200 +++ b/msite.inc.php Fri Dec 07 10:05:02 2012 +0200 @@ -491,12 +491,16 @@ } -function stGetCompoList($all) +function stGetCompoList($fvisible, $fvoting = FALSE) { global $compos; // Get entries and competitions into an array structure - $sql = "SELECT * FROM compos ".($all ? "" :"WHERE enabled<>0 ")."ORDER BY name DESC"; + $sql = "SELECT * FROM compos"; + if ($fvisible || $fvoting) + { + $sql .= " WHERE ".implode(" AND ", array($fvisible ? "visible<>0" : "", $fvoting ? "voting<>0" : "")); + } foreach (stExecSQL($sql) as $compo) { $id = $compo["id"]; diff -r e6ffab8414cc -r 5bc8bd5c7ecc results.inc.php --- a/results.inc.php Thu Dec 06 23:08:46 2012 +0200 +++ b/results.inc.php Fri Dec 07 10:05:02 2012 +0200 @@ -20,7 +20,7 @@ } else { - if (($res = stExecSQL("SELECT * FROM compos WHERE enabled<>0 ORDER BY name DESC")) !== FALSE) + if (($res = stExecSQL("SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC")) !== FALSE) { if ($text) echo "
\n";
     foreach ($res as $compo)
diff -r e6ffab8414cc -r 5bc8bd5c7ecc vote.inc.php
--- a/vote.inc.php	Thu Dec 06 23:08:46 2012 +0200
+++ b/vote.inc.php	Fri Dec 07 10:05:02 2012 +0200
@@ -44,7 +44,7 @@
   if ($mode == 1)
   {
     $showAuthors = stGetSetting("showVoteAuthors");
-    stGetCompoList(FALSE);
+    stGetCompoList(TRUE, TRUE);
 
     echo
     "

Voting system

\n".