# HG changeset patch # User Matti Hamalainen # Date 1384712454 -7200 # Node ID 3870601c17c3bda0de3c4eb8c491181436a3e969 # Parent 8985d2bdb29b1372d2e46e2422ce1a99ae31222b More work. diff -r 8985d2bdb29b -r 3870601c17c3 admajax.php --- a/admajax.php Sun Nov 17 20:04:50 2013 +0200 +++ b/admajax.php Sun Nov 17 20:20:54 2013 +0200 @@ -416,77 +416,6 @@ // // Update existing entry // - if ($type == "attendees" && stCheckRequestUserData(TRUE)) - { - $sql = stPrepareSQLUpdate("attendees", - "WHERE id=".intval(stGetRequestItem("id")), - array( - "name" => "S", - "groups" => "S", - "email" => "S", - "oneliner" => "S", - )); - - stExecSQLCond($sql, "OK, attendee updated."); - } - else - if ($type == "news" && stChkRequestItem("id") && - stChkRequestItem("text") && stChkRequestItem("author") && - stChkRequestItem("title")) - { - $sql = stPrepareSQLUpdate("news", - "WHERE id=".intval(stGetRequestItem("id")), - array( - "title" => "S", - "text" => "Q", - "author" => "S" - )); - - stExecSQLCond($sql, "OK, news item updated."); - } - else - if ($type == "compo" && stChkRequestItem("id") && - stChkRequestItem("name") && stChkRequestItem("description") && - stChkRequestItem("visible") && stChkRequestItem("voting") && - stChkRequestItem("showAuthors")) - { - $sql = stPrepareSQLUpdate("compos", - "WHERE id=".intval(stGetRequestItem("id")), - array( - "name" => "S", - "description" => "Q", - "visible" => "B", - "voting" => "B", - "showAuthors" => "B", - )); - - stExecSQLCond($sql, "OK, compo updated."); - } - else - if ($type == "entry" && stChkRequestItem("id") && - stChkRequestItem("name") && stChkRequestItem("author") && - stChkRequestItem("compo_id")) - { - $cid = stGetRequestItem("compo_id"); - if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$cid) === FALSE) - { - stError("No such compo id."); - } - else - { - $sql = stPrepareSQLUpdate("entries", - "WHERE id=".intval(stGetRequestItem("id")), - array( - "name" => "S", - "author" => "S", - "filename" => "S", - "compo_id" => "D", - )); - - stExecSQLCond($sql, "OK, entry updated."); - } - } - else if ($type == "settings") { foreach (stExecSQL("SELECT * FROM settings") as $item) @@ -496,6 +425,79 @@ stExecSQLCond($sql, "OK, setting updated."); } } + if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) + { + if ($type == "attendees" && stCheckRequestUserData(TRUE)) + { + $sql = stPrepareSQLUpdate("attendees", + "WHERE id=".intval(stGetRequestItem("id")), + array( + "name" => "S", + "groups" => "S", + "email" => "S", + "oneliner" => "S", + )); + + stExecSQLCond($sql, "OK, attendee updated."); + } + else + if ($type == "news" && + stChkRequestItem("text") && stChkRequestItem("author") && + stChkRequestItem("title")) + { + $sql = stPrepareSQLUpdate("news", + "WHERE id=".intval(stGetRequestItem("id")), + array( + "title" => "S", + "text" => "Q", + "author" => "S" + )); + + stExecSQLCond($sql, "OK, news item updated."); + } + else + if ($type == "compo" && + stChkRequestItem("name") && stChkRequestItem("description") && + stChkRequestItem("visible") && stChkRequestItem("voting") && + stChkRequestItem("showAuthors")) + { + $sql = stPrepareSQLUpdate("compos", + "WHERE id=".intval(stGetRequestItem("id")), + array( + "name" => "S", + "description" => "Q", + "visible" => "B", + "voting" => "B", + "showAuthors" => "B", + )); + + stExecSQLCond($sql, "OK, compo updated."); + } + else + if ($type == "entry" && + stChkRequestItem("name") && stChkRequestItem("author") && + stChkRequestItem("compo_id")) + { + $cid = stGetRequestItem("compo_id"); + if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$cid) === FALSE) + { + stError("No such compo id."); + } + else + { + $sql = stPrepareSQLUpdate("entries", + "WHERE id=".intval(stGetRequestItem("id")), + array( + "name" => "S", + "author" => "S", + "filename" => "S", + "compo_id" => "D", + )); + + stExecSQLCond($sql, "OK, entry updated."); + } + } + } break; default: diff -r 8985d2bdb29b -r 3870601c17c3 admin.php --- a/admin.php Sun Nov 17 20:04:50 2013 +0200 +++ b/admin.php Sun Nov 17 20:20:54 2013 +0200 @@ -151,6 +151,18 @@ } +function refreshCCAttendee(cid) +{ + var msuccess = function(txt) + { + var nitem = document.getElementById("attendee"+cid); + if (nitem) nitem.innerHTML = txt; + } + + sendPOSTRequest("action=get&type=attendee&id="+cid, msuccess); +} + + function refreshCCVoters() { refreshItems("tabContCCVoters", "voters", "Voters list"); @@ -223,10 +235,15 @@ { var args = makePostArgs({"name":1,"groups":0,"oneliner":0,"email":0}, "at", id); + var msuccess2 = function(txt) + { + var nitem = document.getElementById("attendee"+id); + if (nitem) nitem.innerHTML = txt; + } + var msuccess = function(txt) { - activeAttendee = -1; - setTimeout("refreshCCAttendees();", 50); + sendPOSTRequest("action=get&type=attendee&id="+id+"&edit=1", msuccess2); } if (args != "")