Mercurial > hg > fapweb
changeset 24:5bc8bd5c7ecc
Make voting toggle for individual compos.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 07 Dec 2012 10:05:02 +0200 |
parents | e6ffab8414cc |
children | 8606c003ca48 |
files | admin.inc.php ajax.php compos.inc.php createdb.php msite.inc.php results.inc.php vote.inc.php |
diffstat | 7 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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 @@ "<div id=\"compo".$id."\">\n". "<h2>#".$id." - ".chentities($item["name"])."</h2>\n". stGetFormTextInput(40, 64, "name", $id, $prefix, $item["name"])."\n". - stGetFormCheckBoxInput("enabled", $id, $prefix, $item["enabled"], "Enabled")."<br />\n". + stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n". + stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n". stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n". stGetFormButtonInput("update", $id, $prefix, " Update ", "updateCompo(".$id.")")."\n". "</div>\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.");
--- 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) {
--- 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",
--- 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"];
--- 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 "<pre>\n"; foreach ($res as $compo)