Mercurial > hg > fapweb
changeset 1029:35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 19 Nov 2015 20:11:30 +0200 |
parents | 8f242f756b0b |
children | 3a8c016c50fc |
files | admajax.php msite.inc.php |
diffstat | 2 files changed, 24 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Thu Nov 19 20:05:26 2015 +0200 +++ b/admajax.php Thu Nov 19 20:11:30 2015 +0200 @@ -1738,22 +1738,8 @@ else if (stValidateRequestEntryData($cfake, FALSE, $compo["ctype"])) { - switch ($compo["ctype"]) - { - case COMPO_NORMAL: - $sql = stPrepareSQL( - "INSERT INTO entries (name,author,compo_id,info,notes,utime,owner_id) VALUES (%S,%S,%d,%Q,%Q,%d,0)", - "name", "author", $compo["id"], "info", "notes", time()); - break; - - case COMPO_POINTS: - case COMPO_ASSIGN: - $sql = stPrepareSQL( - "INSERT INTO entries (name,compo_id,notes,evalue,utime,owner_id) VALUES (%S,%d,%Q,%D,%d,0)", - "name", $compo["id"], "notes", "evalue", time()); - break; - } - stExecSQLCond($sql, "OK, entry added."); + // The function gets most of its data from request parameters + stAddCompoEntry($compo, 0); // User ID = 0 for admin } } stDBCommitTransaction();
--- a/msite.inc.php Thu Nov 19 20:05:26 2015 +0200 +++ b/msite.inc.php Thu Nov 19 20:11:30 2015 +0200 @@ -1323,4 +1323,26 @@ } +function stAddCompoEntry($compo, $uid) +{ + switch ($compo["ctype"]) + { + case COMPO_NORMAL: + $sql = stPrepareSQL( + "INSERT INTO entries (name,author,compo_id,info,notes,preview_type,utime,owner_id) VALUES (%S,%S,%d,%Q,%Q,%D,%d,%d)", + "name", "author", $compo["id"], "info", "notes", "preview_type", time(), $uid); + break; + + case COMPO_POINTS: + case COMPO_ASSIGN: + $sql = stPrepareSQL( + "INSERT INTO entries (name,compo_id,notes,evalue,utime,owner_id) VALUES (%S,%d,%Q,%D,%d,%d)", + "name", $compo["id"], "notes", "evalue", time(), $uid); + break; + } + + return stExecSQLCond($sql, "OK, entry added."); +} + + ?> \ No newline at end of file