changeset 52:cba0b944da79

Start combining "users" with "attendees".
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 05 Oct 2013 07:29:42 +0300
parents 7bdf89601ba0
children 71256605546b
files admin.inc.php ajax.php msite.inc.php
diffstat 3 files changed, 27 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/admin.inc.php	Sat Oct 05 06:55:58 2013 +0300
+++ b/admin.inc.php	Sat Oct 05 07:29:42 2013 +0300
@@ -258,12 +258,6 @@
 }
 
 
-function refreshUsers()
-{
-  refreshItems("nusers", "users", "Users list");
-}
-
-
 function addNews()
 {
   var args = makePostArgs({"title":1,"text":1,"author":1}, "nn", "");
@@ -294,12 +288,27 @@
 
 function updateAttendee(id)
 {
-  var args = makePostArgs({"oneliner":0,"email":0}, "at", id);
+  var args = makePostArgs({"oneliner":0,"email":0,"active":3}, "at", id);
 
   sendPOSTRequest("action=update&type=attendees&id="+id+"&"+args);
 }
 
 
+function updateAttendee2(id)
+{
+  var elem = document.getElementById("atactive"+id);
+  if (elem && !elem.checked)
+  {
+    if (confirm("Are you sure you want deactivate vote ID #"+id+"?"))
+      updateAttendee(id);
+    else
+      setTimeout("refreshAttendees();", 50);
+  }
+  else
+    updateAttendee(id);
+}
+
+
 function addCompo()
 {
   var args = makePostArgs({"name":1, "description":1}, "nc", "");
@@ -336,33 +345,6 @@
 }
 
 
-function updateVoter(id)
-{
-  var args = makePostArgs({"active":3, "name":0}, "vo", id);
-
-  var msuccess = function(txt)
-  {
-    setTimeout("refreshUsers();", 50);
-  }
-
-  sendPOSTRequest("action=update&type=user&id="+id+"&"+args, msuccess);
-}
-
-
-function updateVoter2(id)
-{
-  var elem = document.getElementById("voactive"+id);
-  if (elem && !elem.checked)
-  {
-    if (confirm("Are you sure you want deactivate vote ID #"+id+"?"))
-      updateVoter(id);
-    else
-      setTimeout("refreshUsers();", 50);
-  }
-  else
-    updateVoter(id);
-}
-
 var registeredTabs = Object();
 
 
@@ -478,15 +460,6 @@
 
 <!-- ========================== -->
 
-<div id="tabUsers">
-  <p>
-    Key entries can only be generated via the shell-utility 'keygen'.
-  </p>
-  <div id="nusers"></div>
-</div>
-
-<!-- ========================== -->
-
 <script type="text/javascript">
   registerTab("tabSettings", "Settings");
   registerTab("tabNews", "News");
@@ -494,7 +467,6 @@
   registerTab("tabDump", "Dump");
   registerTab("tabCompos", "Compos");
   registerTab("tabEntries", "Entries");
-  registerTab("tabUsers", "Users");
   updateTabList();
   switchActiveTab("tabSettings");
 </script>
--- a/ajax.php	Sat Oct 05 06:55:58 2013 +0300
+++ b/ajax.php	Sat Oct 05 07:29:42 2013 +0300
@@ -178,9 +178,6 @@
             "</form>\n";
         }
         break;
-      
-      case "users":
-        $sql = "SELECT * FROM users ORDER BY id ASC";
     }
     
     if (isset($sql) && ($res = execSQLCond($sql, "")) !== FALSE)
@@ -210,6 +207,8 @@
         "  <th class=\"oneliner\">Oneliner</th>\n".
         "  <th class=\"email\">E-mail</th>\n".
         "  <th>Actions</th>\n".
+        "  <th class=\"vkey\">User key</th>\n".
+        "  <th class=\"vactive\">Active</th>\n".
         " </tr>\n";
         $row = 0;
         foreach ($res as $item)
@@ -235,37 +234,6 @@
           "<hr />\n";
         }
       }
-      else
-      if ($type == "users")
-      {
-        echo
-        "<table class=\"users\">\n".
-        " <tr>\n".
-        "  <th class=\"vid\">#</th>\n".
-        "  <th class=\"vkey\">User key</th>\n".
-        "  <th class=\"vname\">Name</th>\n".
-        "  <th class=\"vactive\">Active</th>\n".
-        " </tr>\n";
-        $row = 0;
-        foreach ($res as $item)
-        {
-          $id = $item["id"];
-          $prefix = "vo";
-          echo
-          " <tr>\n".
-          " <tr class=\"".($item["active"] ? "vactive " : "").
-            ($row % 2 == 1 ? "rodd" : "reven")."\" id=\"user".$id."\">\n".
-          "  <td class=\"vid\">".sprintf("%04d", $id)."</td>\n".
-          "  <td class=\"vkey\">".chentities($item["key"])."</td>\n".
-          "  <td class=\"vname\">".stGetFormTextInput(40, 64, "name", $id, $prefix, $item["name"],
-          "onBlur=\"updateVoter(".$id.")\" autocomplete=\"off\"")."</td>\n".
-          "  <td class=\"vactive\">".stGetFormCheckBoxInput("active", $id, $prefix, $item["active"], "",
-          "onClick=\"updateVoter2(".$id.")\"")."</td>\n".
-          " </tr>\n";
-          $row++;
-        }
-        echo "</table>\n";
-      }
     }
     break;
 
@@ -315,13 +283,15 @@
 
   case "update":
     if ($type == "attendees" && stChkRequestItem("id") &&
-      stChkRequestItem("email") && stChkRequestItem("oneliner"))
+      stChkRequestItem("email") && stChkRequestItem("oneliner") &&
+      stChkRequestItem("active"))
     {
       $sql = stPrepareSQLUpdate("attendees",
         "WHERE id=".intval(stGetRequestItem("id")),
         array(
           "email" => "S",
           "oneliner" => "S",
+          "active" => "B",
         ));
 
       execSQLCond($sql, "OK, attendee updated.");
@@ -358,19 +328,6 @@
       execSQLCond($sql, "OK, compo updated.");
     }
     else
-    if ($type == "user" && stChkRequestItem("id") &&
-      stChkRequestItem("name") && stChkRequestItem("active"))
-    {
-      $sql = stPrepareSQLUpdate("users",
-        "WHERE id=".intval(stGetRequestItem("id")),
-        array(
-          "name" => "S",
-          "active" => "B",
-        ));
-
-      execSQLCond($sql, "OK, user updated.");
-    }
-    else
     if ($type == "entry" && stChkRequestItem("id") &&
       stChkRequestItem("name") && stChkRequestItem("author") &&
       stChkRequestItem("compo_id"))
--- a/msite.inc.php	Sat Oct 05 06:55:58 2013 +0300
+++ b/msite.inc.php	Sat Oct 05 07:29:42 2013 +0300
@@ -397,10 +397,15 @@
   {
     echo
       stGetTDEditTextItem($edit, 20, 40, "email", $id, $prefix, $item["email"], "autocomplete=\"off\"").
+
       "<td>".
       "<button class=\"button\" id=\"atupd".$id."\" type=\"button\" onclick=\"updateAttendee(".$id.")\">Update</button>".
       "<button class=\"button\" id=\"atdel".$id."\" type=\"button\" onclick=\"deleteAttendee(".$id.")\">Delete</button>".
-      "</td>";
+      "</td>".
+
+      "  <td class=\"vkey\">".chentities($item["key"])."</td>\n".
+      "  <td class=\"vactive\">".stGetFormCheckBoxInput("active", $id, $prefix, $item["active"], "",
+      "onClick=\"updateAttendee2(".$id.")\"")."</td>\n";
   }
 
   echo "</tr>\n";