changeset 764:48c279f2bbc3

It makes no sense to be able to change compo ID for compo types that are not COMPO_NORMAL, so make it impossibru.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 20 Nov 2014 12:10:45 +0200
parents 20fd7d2040d1
children 24e56d150a3e
files admajax.php
diffstat 1 files changed, 30 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Thu Nov 20 11:43:55 2014 +0200
+++ b/admajax.php	Thu Nov 20 12:10:45 2014 +0200
@@ -60,9 +60,6 @@
     array(CHK_ISGT, VT_STR, 0, "Name too short."),
     array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Name too long."));
 
-  stChkRequestItemFail("compo_id", $compo_id, $res,
-    array(CHK_TYPE, VT_INT, "Invalid compo ID."));
-
   stChkRequestItemFail("notes", $fake, $res,
     array(CHK_TYPE, VT_TEXT, "Invalid data."),
     array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NOTES, "Entry notes too long."));
@@ -70,6 +67,9 @@
   switch ($ctype)
   {
     case COMPO_NORMAL:
+      stChkRequestItemFail("compo_id", $compo_id, $res,
+        array(CHK_TYPE, VT_INT, "Invalid compo ID."));
+
       stChkRequestItemFail("author", $fake, $res,
         array(CHK_ISGT, VT_STR, 0, "Author name not set."),
         array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long."));
@@ -237,8 +237,33 @@
           echo "    ".$previewTypeList[$item["preview_type"]][1];
 
         echo "   </div>\n";
-        break;
+      }
+
+      if ($mode == 1)
+      {
+        $sql =
+          "SELECT compos.*, ".
+          "COUNT(DISTINCT entries.id) AS nentries ".
+          "FROM compos LEFT JOIN entries ON compos.id=entries.compo_id ".
+          "GROUP BY compos.id ".
+          "ORDER BY compos.id DESC";
+
+        echo
+          "   <div class=\"entryCell entryCompoID\">".
+          stGetFormOptionListStart($prefix."compo_id".$eid, "    ", TRUE, 0);
         
+        foreach (stExecSQL($sql) as $cdata)
+        {
+          echo stGetFormOptionListItem("     ",
+            $cdata["id"],
+            ($cdata["id"] == $item["compo_id"]),
+            sprintf("%-20s (%d entries)", substr($cdata["name"], 0, 20), $cdata["nentries"])
+            );
+        }
+
+        echo
+          stGetFormOptionListEnd("    ", TRUE).
+          "</div>\n";
       }
       break;
     
@@ -273,29 +298,8 @@
   switch ($mode)
   {
     case 1:
-      $sql =
-        "SELECT compos.*, ".
-        "COUNT(DISTINCT entries.id) AS nentries ".
-        "FROM compos LEFT JOIN entries ON compos.id=entries.compo_id ".
-        "GROUP BY compos.id ".
-        "ORDER BY compos.id DESC";
 
       echo
-      "   <div class=\"entryCell entryCompoID\">".
-      stGetFormOptionListStart($prefix."compo_id".$eid, "    ", TRUE, 0);
-      
-      foreach (stExecSQL($sql) as $cdata)
-      {
-        echo stGetFormOptionListItem("     ",
-          $cdata["id"],
-          ($cdata["id"] == $item["compo_id"]),
-          sprintf("%-20s (%d entries)", substr($cdata["name"], 0, 20), $cdata["nentries"])
-          );
-      }
-
-      echo
-      stGetFormOptionListEnd("    ", TRUE).
-      "</div>\n".
       "<div class=\"entryCell entryActions\">\n".
       stGetFormButtonInput("update", $eid, $prefix, "Update", "updateEntry(".$item["compo_id"].",".$eid.")").
       stGetFormButtonInput("delete", $eid, $prefix, "Delete", "deleteEntry(".$item["compo_id"].",".$eid.")").
@@ -1751,6 +1755,7 @@
                 "filename" => "S",
                 "info" => "Q",
                 "preview_type" => "D",
+                "compo_id" => "D",
               );
               break;
             
@@ -1767,7 +1772,6 @@
             array_merge(array(
               "name" => "S",
               "notes" => "Q",
-              "compo_id" => "D",
             ), $cdata));
 
           stExecSQLCond($sql, "OK, entry updated.");