Mercurial > hg > fapweb
changeset 611:79a222ac404b
Merged.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 01 Nov 2014 00:48:13 +0200 |
parents | 6a02ae8018ca (current diff) 167ca3827c31 (diff) |
children | 1abcb1295d5d |
files | |
diffstat | 5 files changed, 51 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Mon Oct 27 12:41:07 2014 +0200 +++ b/admajax.php Sat Nov 01 00:48:13 2014 +0200 @@ -1347,6 +1347,31 @@ $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id); stExecSQLCond($sql, "OK, entry ".$id." votes deleted."); } + else + if ($type == "compo") + { + stDBBeginTransaction(); + + // Delete votes for compo entry + foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$id) as $sentry) + { + stExecSQLCond( + "DELETE FROM votes WHERE entry_id=".$sentry["id"], + "OK, entry ".$sentry["id"]." votes deleted."); + } + + // Delete entries for the compo + stExecSQLCond( + "DELETE FROM entries WHERE compo_id=".$id, + "OK, compo entries for compo ".$id." deleted."); + + // Delete the compo itself + stExecSQLCond( + "DELETE FROM compos WHERE id=".$id, + "OK, compo ".$id." deleted."); + + stDBCommitTransaction(); + } } else if ($type == "votekeys") @@ -1410,12 +1435,14 @@ // if ($type == "settings") { + stDBBeginTransaction(); foreach (stExecSQL("SELECT * FROM settings") as $item) if (($val = stGetRequestItem($item["key"], FALSE)) !== FALSE) { $sql = "UPDATE settings SET ".stGetSettingSQL($item, $val)." WHERE key=".$db->quote($item["key"]); stExecSQLCond($sql, "OK, setting updated."); } + stDBCommitTransaction(); } else if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data.")))
--- a/admin.js Mon Oct 27 12:41:07 2014 +0200 +++ b/admin.js Sat Nov 01 00:48:13 2014 +0200 @@ -42,7 +42,7 @@ } -function jsDeleteItem(id,prefix,type,func,dsc) +function jsDeleteItem(id,prefix,type,func,dsc,dsc2) { var msuccess = function(txt) { @@ -68,7 +68,10 @@ item.style.background = tmp; } - jsConfirmBox("Are you sure you want to delete "+dsc+" #"+id+"?", mcb_ok, mcb_cancel, 0); + if (dsc) + jsConfirmBox("Are you sure you want to delete "+dsc+" #"+id+"?", mcb_ok, mcb_cancel, 0); + else + jsConfirmBox(dsc2, mcb_ok, mcb_cancel, 0); } @@ -275,6 +278,14 @@ } +function deleteCompo(id) +{ + jsDeleteItem(id, "compo", "compo", "refreshDispatchCC('Compos');", 0, + "Are you ABSOLUTELY sure you want to delete compo #"+id+"? "+ + "This will delete all votes AND entries related to it!"); +} + + function addEntry(id) { var args = jsMakePostArgs({"name":1, "author":1, "filename":1, "info":1}, "ne", id);
--- a/index.php Mon Oct 27 12:41:07 2014 +0200 +++ b/index.php Sat Nov 01 00:48:13 2014 +0200 @@ -60,6 +60,7 @@ stGetSetting("siteInfoText"). " <div id=\"menu\">\n". " ".stGetSetting("siteMenuHeader")."\n". + " <div id=\"menuInner\">\n". stGetMainPageLink("about", "About"). stGetMainPageLink("news", "News", stGetSetting("showNews")). stGetMainPageLink("compos", "Compos", stGetSetting("showCompos")). @@ -78,6 +79,7 @@ stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")). stGetSetting("siteMenuFooter"). " </div>\n". + " </div>\n". "</div>\n". "<div id=\"infobox\">".$pageBasename."</div>\n"; ?>
--- a/msite.inc.php Mon Oct 27 12:41:07 2014 +0200 +++ b/msite.inc.php Sat Nov 01 00:48:13 2014 +0200 @@ -54,8 +54,8 @@ // // Competition types // -define("COMPO_NORMAL", 0); // Normal voting compo -define("COMPO_POINTS", 1); // Assigned points (no voting) +define("COMPO_NORMAL", 0); // Normal voting compo, points determine placement +define("COMPO_POINTS", 1); // Assigned points, points determines placement (no voting) define("COMPO_ASSIGN", 2); // Assigned places (no voting) @@ -312,7 +312,7 @@ return FALSE; } - if (strlen($email) > 0 && (strpos($email, "@") === FALSE || strpos($email, ".") === FALSE)) + if (strlen($email) > 0 && preg_match("/^[a-z0-9][a-z0-9\+\-\.\%_]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", $email) != 1) { stError("E-mail address not in proper format."); return FALSE; @@ -414,7 +414,7 @@ } -function stGetCompoResultsSQL($mode, $compo_id) +function stGetCompoResultsSQL($mode, $compo) { switch ($mode) { @@ -448,7 +448,7 @@ } $sql .= " ". - "WHERE entries.compo_id=".$compo_id." ". + "WHERE entries.compo_id=".$compo["id"]." ". "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0 ". "GROUP BY entries.id ". "ORDER BY votesum DESC"; @@ -459,7 +459,8 @@ function stGetCompoResultsASCIIStr($showAuthors, $html) { - if (($res = stExecSQL("SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC")) === false) + $sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC"; + if (($res = stExecSQL($sql)) === false) return ""; $voteKeyMode = stGetSetting("voteKeyMode"); @@ -477,7 +478,7 @@ if (($nentries = stFetchSQLColumn($sql)) !== FALSE && $nentries > 0) { // Get voting results by mode - $sql = stGetCompoResultsSQL($voteKeyMode, $compo["id"]); + $sql = stGetCompoResultsSQL($voteKeyMode, $compo); // List results $prev = FALSE;