changeset 30:ad25827304b6

Adding entries is now done via the regular entry submission system .. which is unfinished. To be fixed soon!
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 09 Dec 2012 05:58:14 +0200
parents 4b5a176805e2
children eaa65f0b3ce7
files admin.inc.php ajax.php
diffstat 2 files changed, 8 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/admin.inc.php	Sun Dec 09 05:41:18 2012 +0200
+++ b/admin.inc.php	Sun Dec 09 05:58:14 2012 +0200
@@ -320,24 +320,9 @@
   sendPOSTRequest("action=update&type=compo&id="+id+"&"+args);
 }
 
-
-function addEntry(id)
-{
-  var args = makePostArgs({"name":1, "author":1}, "ne", id);
-
-  var msuccess = function(txt)
-  {
-    setTimeout("refreshEntries();", 50);
-  }
-
-  sendPOSTRequest("action=add&type=entry&compo_id="+id+"&"+args, msuccess);
-  return false;
-}
-
-
 function updateEntry(id)
 {
-  var args = makePostArgs({"name":1, "author":1}, "en", id);
+  var args = makePostArgs({"name":1, "author":1, "compo_id":2}, "en", id);
 
   sendPOSTRequest(
     "action=update&type=entry&id="+id+"&"+args);
--- a/ajax.php	Sun Dec 09 05:41:18 2012 +0200
+++ b/ajax.php	Sun Dec 09 05:58:14 2012 +0200
@@ -148,9 +148,10 @@
             "<form>\n".
             " <table class=\"misc\">\n".
             "  <tr>\n".
-            "   <th colspan=\"3\">".chentities($compo["name"])."</th>\n".
+            "   <th colspan=\"3\">#".$id." - ".chentities($compo["name"])."</th>\n".
             "  </tr>\n".
             "  <tr>\n".
+            "   <th style=\"width:1%;\">Compo</th>\n".
             "   <th>Title</th>\n".
             "   <th>Author(s)</th>\n".
             "   <th>Actions</th>\n".
@@ -161,6 +162,7 @@
           {
             echo
               "  <tr id=\"entry".$eid."\">\n".
+              "   <td>".stGetFormTextInput(5, 5, "compo_id", $eid, "en", $id)."</td>\n".
               "   <td>".stGetFormTextInput(35, 64, "name", $eid, "en", $entry["name"])."</td>\n".
               "   <td>".stGetFormTextInput(30, 64, "author", $eid, "en", $entry["author"])."</td>\n".
               "   <td>".
@@ -169,13 +171,7 @@
               "</td>\n".
               "  </tr>\n";
           }
-          $prefix = "ne";
           echo
-            "  <tr>\n".
-            "   <td>".stGetFormTextInput(40, 64, "name", $id, "ne", "")."</td>\n".
-            "   <td>".stGetFormTextInput(40, 64, "author", $id, "ne", "")."</td>\n".
-            "   <td>".stGetFormButtonInput("add", $id, $prefix, " Add new ", "addEntry(".$id.")")."</td>\n".
-            "  </tr>\n".
             " </table>\n".
             "</form>\n";
         }
@@ -312,16 +308,6 @@
       execSQLCond($sql, "OK, compo added.");
     }
     else
-    if ($type == "entry" && stChkRequestItem("name") &&
-      stChkRequestItem("author") && stChkRequestItem("compo_id"))
-    {
-      $sql = stPrepareSQL(
-        "INSERT INTO entries (name,author,compo_id) VALUES (%S,%Q,%D)",
-        "name", "author", "compo_id");
-
-      execSQLCond($sql, "OK, entry added.");
-    }
-    else
       setStatus(902, "No data.");
     break;
 
@@ -384,14 +370,15 @@
     }
     else
     if ($type == "entry" && stChkRequestItem("id") &&
-      stChkRequestItem("name") && stChkRequestItem("author"))
+      stChkRequestItem("name") && stChkRequestItem("author") &&
+      stChkRequestItem("compo_id"))
     {
       $sql = stPrepareSQLUpdate("entries",
-        "WHERE id=".intval(stGetRequestItem("id").
-        " AND compo_id=".intval(stGetRequestItem("compo_id"))),
+        "WHERE id=".intval(stGetRequestItem("id")).
         array(
           "name" => "S",
           "author" => "S",
+          "compo_id" => "D",
         ));
 
       execSQLCond($sql, "OK, entry updated.");