Mercurial > hg > fapweb
changeset 635:59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
new features.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 01 Nov 2014 16:16:06 +0200 |
parents | b18a961dcf3e |
children | 4ea7a88cdb2f |
files | admajax.php admin.js |
diffstat | 2 files changed, 31 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Sat Nov 01 16:15:03 2014 +0200 +++ b/admajax.php Sat Nov 01 16:16:06 2014 +0200 @@ -17,7 +17,11 @@ array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_NAME, "Compo name too long.")) || !stChkRequestItem("description", $fake, array(CHK_ISGT, VT_STR, 10, "Compo description too short"), - array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long."))) + array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long.")) || + !stChkRequestItem("path", $fake, + array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long.")) || + !stChkRequestItem("type", $fake, + array(CHK_RANGE, VT_INT, array(COMPO_NORMAL, COMPO_ASSIGN), "Invalid compo type."))) return FALSE; if (!$full) @@ -81,14 +85,29 @@ function stGetCompoData($id, $item, $prefix) { + switch ($item["type"]) + { + case COMPO_NORMAL: + $str = " ". + stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting", "onChange=\"setCompoData(".$id.",'voting')\"")."<br />\n"; + break; + + default: + $str = " ". + stGetFormHiddenInput("voting", $id, $prefix, $item["voting"]); + break; + } + return " <h2>#".$id." - ".chentities($item["name"])."</h2>\n". - " ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."\n". - " ".stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n". - " ".stGetFormCheckBoxInput("show_authors", $id, $prefix, $item["show_authors"], "Show authors")."\n". - " ".stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n". - " ".stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n". - " ".stGetFormButtonInput("update", $id, $prefix, "Update", "updateCompo(".$id.")")."\n"; + " Name: ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."<br />\n". + " File path: ".stGetFormTextInput(40, SET_LEN_COMPO_PATH, "path", $id, $prefix, $item["path"])."<br />\n". + " ".stGetFormTextArea(8, 60, "description", $id, $prefix, $item["description"])."<br />\n". + " ".stGetFormButtonInput("update", $id, $prefix, "Update", "updateCompo(".$id.")")."\n". + " ".stGetFormButtonInput("delete", $id, $prefix, "Delete", "deleteCompo(".$id.")")."\n". + " ".stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible", "onChange=\"setCompoData(".$id.",'visible')\"")."\n". + " ".stGetFormCheckBoxInput("show_authors", $id, $prefix, $item["show_authors"], "Show authors", "onChange=\"setCompoData(".$id.",'show_authors')\"")."\n". + $str; } @@ -1418,8 +1437,8 @@ if ($type == "compo" && stValidateRequestCompoData(FALSE)) { $sql = stPrepareSQL( - "INSERT INTO compos (name,description,visible,voting,show_authors) VALUES (%S,%Q,0,0,0)", - "name", "description"); + "INSERT INTO compos (name,description,visible,voting,show_authors,path,type) VALUES (%S,%Q,%D,0,0,0,%S,%D)", + "name", "description", "path", "type"); stExecSQLCond($sql, "OK, compo added."); } @@ -1505,6 +1524,8 @@ "visible" => "B", "voting" => "B", "show_authors" => "B", + "path" => "S", + "type" => "D", )); stExecSQLCond($sql, "OK, compo updated.");
--- a/admin.js Sat Nov 01 16:15:03 2014 +0200 +++ b/admin.js Sat Nov 01 16:16:06 2014 +0200 @@ -296,7 +296,7 @@ function updateCompo(id) { - var args = jsMakePostArgs({"name":1, "description":1, "visible":3, "voting":3, "show_authors":3}, "co", id); + var args = jsMakePostArgs({"name":1, "description":1, "visible":3, "voting":3, "show_authors":3, "path":1}, "co", id); var msuccess = function(txt) {