# HG changeset patch # User Matti Hamalainen # Date 1416478245 -7200 # Node ID 48c279f2bbc393df193db3b34ee94ba93f77f0c5 # Parent 20fd7d2040d10b69359970e081290ed8c0491c0e It makes no sense to be able to change compo ID for compo types that are not COMPO_NORMAL, so make it impossibru. diff -r 20fd7d2040d1 -r 48c279f2bbc3 admajax.php --- 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 " \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 + "
". + 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). + "
\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 - "
". - 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). - "
\n". "
\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.");