changeset 55:4fac95384753

Make visibility of entry authors per compo.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 05 Oct 2013 09:33:06 +0300
parents 30385b66ca1c
children 243e9a51920b
files admin.inc.php ajax.php createdb.php vote.inc.php
diffstat 4 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/admin.inc.php	Sat Oct 05 08:44:05 2013 +0300
+++ b/admin.inc.php	Sat Oct 05 09:33:06 2013 +0300
@@ -330,7 +330,7 @@
 
 function updateCompo(id)
 {
-  var args = makePostArgs({"name":1, "description":1, "visible":3, "voting":3}, "co", id);
+  var args = makePostArgs({"name":1, "description":1, "visible":3, "voting":3, "showAuthors":3}, "co", id);
 
   sendPOSTRequest("action=update&type=compo&id="+id+"&"+args);
 }
--- a/ajax.php	Sat Oct 05 08:44:05 2013 +0300
+++ b/ajax.php	Sat Oct 05 09:33:06 2013 +0300
@@ -231,6 +231,7 @@
           "<h2>#".$id." - ".chentities($item["name"])."</h2>\n".
           stGetFormTextInput(40, 64, "name", $id, $prefix, $item["name"])."\n".
           stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n".
+          stGetFormCheckBoxInput("showAuthors", $id, $prefix, $item["showAuthors"], "Show authors")."\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".
@@ -297,7 +298,7 @@
       stChkRequestItem("description"))
     {
       $sql = stPrepareSQL(
-        "INSERT INTO compos (name,description,visible,voting) VALUES (%S,%Q,0,0)",
+        "INSERT INTO compos (name,description,visible,voting,showAuthors) VALUES (%S,%Q,0,0,0)",
         "name", "description");
 
       execSQLCond($sql, "OK, compo added.");
@@ -353,7 +354,8 @@
     else
     if ($type == "compo" && stChkRequestItem("id") &&
       stChkRequestItem("name") && stChkRequestItem("description") &&
-      stChkRequestItem("visible") && stChkRequestItem("voting"))
+      stChkRequestItem("visible") && stChkRequestItem("voting") &&
+      stChkRequestItem("showAuthors"))
     {
       $sql = stPrepareSQLUpdate("compos",
         "WHERE id=".intval(stGetRequestItem("id")),
@@ -362,6 +364,7 @@
           "description" => "Q",
           "visible" => "B",
           "voting" => "B",
+          "showAuthors" => "B",
         ));
 
       execSQLCond($sql, "OK, compo updated.");
--- a/createdb.php	Sat Oct 05 08:44:05 2013 +0300
+++ b/createdb.php	Sat Oct 05 09:33:06 2013 +0300
@@ -56,7 +56,6 @@
 
   "showResults"      => array(VT_BOOL, false, "Enable results page"),
   "showResAuthors"   => array(VT_BOOL, false, "Show entry authors on results page"),
-  "showVoteAuthors"  => array(VT_BOOL, false, "Show entry authors on voting page"),
 
   "requireEMail"     => array(VT_BOOL, false, "Require e-mail address in registrations"),
 
@@ -161,7 +160,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), key VARCHAR(64), active INT DEFAULT 0",
-  "compos" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(128), description VARCHAR(4096), visible INT DEFAULT 0, voting INT DEFAULT 0",
+  "compos" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(128), description VARCHAR(4096), visible INT DEFAULT 0, voting INT DEFAULT 0, showAuthors INT DEFAULT 0",
   "entries" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(64), author VARCHAR(64), compo_id INT DEFAULT NULL, filename VARCHAR(256) DEFAULT NULL, screenshot VARCHAR(128) DEFAULT NULL",
   "votes" => "id INTEGER PRIMARY KEY AUTOINCREMENT, entry_id INT DEFAULT NULL, voter_id INT DEFAULT NULL, value INT DEFAULT 0",
   "settings" => "key VARCHAR(32) PRIMARY KEY, vtype INT, vstr VARCHAR(128), vtext TEXT, vint INT, desc VARCHAR(128)",
--- a/vote.inc.php	Sat Oct 05 08:44:05 2013 +0300
+++ b/vote.inc.php	Sat Oct 05 09:33:06 2013 +0300
@@ -27,7 +27,6 @@
   
   if ($status == 1)
   {
-    $showAuthors = stGetSetting("showVoteAuthors");
     stGetCompoList(TRUE, TRUE);
 
     // Try fetching previously stored votes
@@ -59,7 +58,7 @@
       "  <tr><th colspan=\"3\">".chentities($compo["name"])."</th></tr>\n".
       "  <tr>\n".
       "   <th class=\"vtitle\">Title</th>\n".
-      ($showAuthors ? "   <th class=\"vauthor\">Author</th>\n" : "").
+      ($compo["showAuthors"] ? "   <th class=\"vauthor\">Author</th>\n" : "").
       "   ";
 
       for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++)
@@ -76,7 +75,7 @@
         echo
         "  <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n".
         "   <td class=\"vtitle\">".$entry["name"]."</td>\n".
-        ($showAuthors ? "   <td class=\"vauthor\">".$entry["author"]."</td>\n" : "").
+        ($compo["showAuthors"] ? "   <td class=\"vauthor\">".$entry["author"]."</td>\n" : "").
         "   ";
 
         for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++)