comparison admajax.php @ 1029:35a00a986f79

Factorize compo entry adding into stAddCompoEntry().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 19 Nov 2015 20:11:30 +0200
parents 87eda2e9023f
children 3a8c016c50fc
comparison
equal deleted inserted replaced
1028:8f242f756b0b 1029:35a00a986f79
1736 if (($compo = stFetchSQL(stPrepareSQL("SELECT * FROM compos WHERE id=%D", "compo_id"))) === FALSE) 1736 if (($compo = stFetchSQL(stPrepareSQL("SELECT * FROM compos WHERE id=%D", "compo_id"))) === FALSE)
1737 stError("No such compo ID."); 1737 stError("No such compo ID.");
1738 else 1738 else
1739 if (stValidateRequestEntryData($cfake, FALSE, $compo["ctype"])) 1739 if (stValidateRequestEntryData($cfake, FALSE, $compo["ctype"]))
1740 { 1740 {
1741 switch ($compo["ctype"]) 1741 // The function gets most of its data from request parameters
1742 { 1742 stAddCompoEntry($compo, 0); // User ID = 0 for admin
1743 case COMPO_NORMAL:
1744 $sql = stPrepareSQL(
1745 "INSERT INTO entries (name,author,compo_id,info,notes,utime,owner_id) VALUES (%S,%S,%d,%Q,%Q,%d,0)",
1746 "name", "author", $compo["id"], "info", "notes", time());
1747 break;
1748
1749 case COMPO_POINTS:
1750 case COMPO_ASSIGN:
1751 $sql = stPrepareSQL(
1752 "INSERT INTO entries (name,compo_id,notes,evalue,utime,owner_id) VALUES (%S,%d,%Q,%D,%d,0)",
1753 "name", $compo["id"], "notes", "evalue", time());
1754 break;
1755 }
1756 stExecSQLCond($sql, "OK, entry added.");
1757 } 1743 }
1758 } 1744 }
1759 stDBCommitTransaction(); 1745 stDBCommitTransaction();
1760 break; 1746 break;
1761 1747