Mercurial > hg > fapweb
diff admajax.php @ 644:de35a9743557
Implement changing of compo type.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 03 Nov 2014 02:14:54 +0200 |
parents | d32b5f601670 |
children | 2eeca16e9c96 |
line wrap: on
line diff
--- a/admajax.php Mon Nov 03 02:11:10 2014 +0200 +++ b/admajax.php Mon Nov 03 02:14:54 2014 +0200 @@ -87,6 +87,9 @@ function stGetCompoData($id, $item, $prefix) { + global $compoModeData; + + // XXX TODO Dropdown menu or so for selecting compo type switch ($item["ctype"]) { case COMPO_NORMAL: @@ -101,6 +104,9 @@ return " <h2>#".$id." - ".chentities($item["name"])."</h2>\n". + " Type: ".stGetOptionListFromArray("cotype".$id, " ", FALSE, $compoModeData, $item["ctype"], 0)." ". + stGetFormButtonInput("change", $id, $prefix, "Change", "updateCompoType(".$id.")"). + " - ".$compoModeData[$item["ctype"]][1]."<br />\n". " Name: ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."<br />\n". " File path: ".stGetFormTextInput(40, SET_LEN_COMPO_PATH, "cpath", $id, $prefix, $item["cpath"])."<br />\n". " ".stGetFormTextArea(8, 60, "description", $id, $prefix, $item["description"])."<br />\n". @@ -959,7 +965,9 @@ "SELECT compos.*, ". "COUNT(DISTINCT entries.id) AS nentries ". "FROM compos LEFT JOIN entries ON compos.id=entries.compo_id ". - "GROUP BY compos.id HAVING COUNT(DISTINCT entries.id) > 0 ORDER BY compos.id DESC"; + "GROUP BY compos.id ". + "HAVING COUNT(DISTINCT entries.id) > 0 AND compos.ctype=".COMPO_NORMAL." ". + "ORDER BY compos.id DESC"; $currCompoID = stGetDisplayVar("compoID"); if (($res = stExecSQL($sql)) !== false) @@ -1511,6 +1519,17 @@ stExecSQLCond($sql, "OK, news item updated."); } else + if ($type == "compotype") + { + $sql = stPrepareSQLUpdate("compos", + "WHERE id=".$id, + array( + "ctype" => "D", + )); + + stExecSQLCond($sql, "OK, compo updated."); + } + else if ($type == "compo" && stValidateRequestCompoData(TRUE)) { $sql = stPrepareSQLUpdate("compos",