Mercurial > hg > fapweb
changeset 1061:7298b2898a6d
Merged.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Feb 2016 16:20:56 +0200 |
parents | 280de0770798 (current diff) 6db0ab61dadf (diff) |
children | 7135c7b18bb9 85e268f6a822 |
files | |
diffstat | 4 files changed, 127 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Wed Feb 10 16:18:46 2016 +0200 +++ b/admajax.php Wed Feb 10 16:20:56 2016 +0200 @@ -227,6 +227,17 @@ } +function stGetCompoVoting($compo, $outer) +{ + return + ($outer ? "<span id=\"covoting".$compo["id"]."\">" : ""). + stGetFormCheckBoxInput( + "votingbutton", $compo["id"], "co", $compo["voting"], "Voting ".($compo["voting"] ? "IS ACTIVE" : "disabled"), + "class=\"votingactive\" onChange=\"updateCompoVoting(".$compo["id"].")\"", ""). + ($outer ? "</span>" : ""); +} + + function stPrintEntryItemData($item, $row, $tr, $prefix, $compo, $mode) { global $entryFlagsList, $previewTypeList, $compoModeData; @@ -396,7 +407,12 @@ { $nkeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys WHERE active=1"); $totalKeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys"); - return "Info: <b>".$nkeys."</b> of <b>".$totalKeys."</b> votekeys are activated."; + + $nvoters = stFetchSQLColumn("SELECT COUNT(DISTINCT(key_id)) FROM votes"); + + return + "Info: <b>".$nkeys."</b> of <b>".$totalKeys."</b> votekeys are activated. ". + "Also, <b>".$nvoters."</b> keys have been used for voting."; } @@ -878,7 +894,7 @@ } } if ($ncompos > 0) - echo "<li>VOTING COMPOS: <b>".$nentries."</b> compo entries in <b>".$ncompos."</b> compos.</li>\n"; + echo "<li>VOTING COMPOS: <b>".$nentries."</b> entries in <b>".$ncompos."</b> compos.</li>\n"; $nentries = $ncompos = 0; foreach (stExecSQL("SELECT * FROM compos WHERE ctype <> ".COMPO_NORMAL) as $compo) @@ -1211,13 +1227,14 @@ stGetShowModeButton(SMODE_DISABLED, "Off/disabled", $showMode)."\n". stGetShowModeButton(SMODE_ROTATE, "Slide rotation", $showMode)."\n". stGetShowModeButton(SMODE_COMPO, "Compo mode", $showMode)."\n". - "<a href=\"show.php\" target=\"_blank\">Open info window</a>\n". - stGetFormButtonElement("showForceReload", "", "", "Showscreen reload", "showScreenCmd('reload')")."\n". - "</div>\n". - "<div id=\"ctrlSystemControls\">\n". - stGetFormButtonInput("syscheck", "", "", "Perform system check", "performSystemCheck()")."\n". - stGetFormButtonInput("generate", "", "", "Add missing show positions", "generateEntryPositions(0, 1)")."\n". - stGetFormButtonInput("regenerate", "", "", "ReGenerate ALL show positions", "generateEntryPositions(0, 0)")."\n". + stGetFormButtonInput("openShowScreen", "", "", "Showscreen window", "window.open('show.php')")."\n". + stGetFormButtonInput("reloadShowScreen", "", "", "Showscreen reload", "showScreenCmd('reload')")."\n". + //"</div>\n". + //"<div id=\"ctrlSystemControls\">\n". + stGetFormButtonInput("systemCheck", "", "", "System check", "performSystemCheck()")."\n". + stGetFormButtonInput("generateShowPositions", "", "", "Add show positions", "generateEntryPositions(0, 1)")."\n". + // XXX: disable this button for now + // stGetFormButtonInput("regenerate", "", "", "RESET show positions", "generateEntryPositions(0, 0)")."\n". "</div>\n"; echo @@ -1434,7 +1451,16 @@ } } - // List of votekeys + // Some information + echo + "<div class=\"tabHeadersSub\">\n". + " <a href=\"print.php?type=votekeys\" target=\"_blank\">Show printable key list</a>\n". + " <a href=\"print.php?type=results&flags=".(RFLAG_NORMAL)."\" target=\"_blank\">Printable results</a>\n". + " <a href=\"print.php?type=results&flags=".(RFLAG_DISQUALIFIED)."\" target=\"_blank\">Printable full results</a> (shows also disqualified entries)\n". + " <a href=\"print.php?type=results&flags=".(RFLAG_DISQUALIFIED | RFLAG_HIDDEN_COMPOS)."\" target=\"_blank\">Printable FULL results</a> (shows also hidden and empty compos)\n". + " <div id=\"vkeyInfo\">".stGetVoteKeyInfo()."</div>\n". + "</div>\n"; + echo "<div class=\"info\"><b>Voting mode: "; @@ -1442,14 +1468,10 @@ echo $voteModeData[$setVoteKeyMode][0]."</b>. ".$voteModeData[$setVoteKeyMode][1]; else echo "VOTE MODE NOT SET! CHECK CONFIGURATION!</b>"; - - echo - "</div>\n". - "<div class=\"tabHeadersSub\">\n". - "<a href=\"print.php?type=votekeys\" target=\"_blank\">Show printable key list</a>\n". - "<div id=\"vkeyInfo\">".stGetVoteKeyInfo()."</div>\n". - "</div>\n"; + echo "</div>\n"; + + // List of votekeys switch ($setVoteKeyMode) { case VOTE_FREELY: @@ -1498,13 +1520,10 @@ case "compos": echo - "<div class=\"ctrlModeControls\">\n". - " <a href=\"print.php?type=results&flags=".(RFLAG_NORMAL)."\" target=\"_blank\">Printable results</a>\n". - " <a href=\"print.php?type=results&flags=".(RFLAG_DISQUALIFIED)."\" target=\"_blank\">Printable full results</a> (shows also disqualified entries)\n". - " <a href=\"print.php?type=results&flags=".(RFLAG_DISQUALIFIED | RFLAG_HIDDEN_COMPOS)."\" target=\"_blank\">Printable FULL results</a> (shows also hidden and empty compos)\n". - "</div>\n". "<form method=\"post\" action=\"\" onsubmit=\"return addCompo()\">\n". + "<b>Name:<b>". " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."<br />\n". + "<b>Description:</b>". " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."<br />\n". " ".stGetFormSubmitInput("nccompo", "Add compo")."\n". " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n". @@ -1605,6 +1624,12 @@ } break; + case "compovoting": + $id = intval(stGetRequestItem("id", 0)); + if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) + echo stGetCompoVoting($compo, FALSE); + break; + case "entries": $id = intval(stGetRequestItem("id", 0)); if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) @@ -1618,7 +1643,8 @@ { echo stGetFormButtonInput("generate", "", "", " Add missing show positions ", "generateEntryPositions(".$id.", 1)")."\n". - stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n"; + stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n". + stGetCompoVoting($compo, TRUE)."\n"; } stPrintEntryItemData(array( @@ -1741,8 +1767,8 @@ if ($type == "compo" && stValidateRequestCompoData(FALSE, 0)) { $sql = stPrepareSQL( - "INSERT INTO compos (name,description,notes,visible,voting,show_authors,preview_type) VALUES (%S,%Q,%Q,0,0,0,0)", - "name", "description", "notes"); + "INSERT INTO compos (name,description,visible,voting,show_authors,preview_type) VALUES (%S,%Q,0,0,0,0)", + "name", "description"); stExecSQLCond($sql, "OK, compo added."); } @@ -1822,6 +1848,15 @@ stExecSQLCond($sql, "OK, compo updated."); } else + if ($type == "compovoting" && + stChkRequestItem("voting", $compovoting, $qres, + array(CHK_TYPE, VT_BOOL, "Invalid data.") + )) + { + $sql = stPrepareSQL("UPDATE compos SET voting=%b WHERE id=%d", $compovoting, $id); + stExecSQLCond($sql, "OK, compo updated."); + } + else if ($type == "compo") { // Check if compo ID exists
--- a/admin.js Wed Feb 10 16:18:46 2016 +0200 +++ b/admin.js Wed Feb 10 16:20:56 2016 +0200 @@ -60,7 +60,7 @@ if (tabContent && tabHead) { tabContent.style.display = (tab == id) ? "block" : "none"; - tabHead.style.borderTop = (tab == id) ? "4px solid white" : "none"; + tabHead.className = (tab == id) ? "active" : "inactive"; if (tab == id) { // Set active tab and refresh contents @@ -361,7 +361,7 @@ // function addCompo() { - var args = jsMakePostArgs({"name":1, "description":1, "notes":1}, "nc", ""); + var args = jsMakePostArgs({"name":1, "description":1}, "nc", ""); var msuccess = function(txt) { @@ -385,6 +385,17 @@ } +function updateCompoVoting(id) +{ + var msuccess = function(txt) + { + jsRefreshItems("covoting"+id, "compovoting", "&id="+id); + } + + jsSendPOSTRequest("action=update&type=compovoting&id="+id+"&voting="+jsGetValue("covotingbutton"+id, 3), msuccess); +} + + function updateCompo(id) { var args = jsMakePostArgs({"name":1, "description":1, "notes":1, "visible":3, "voting":3, "show_authors":3, "cpath":1, "preview_type":4}, "co", id, true);
--- a/faptool.php Wed Feb 10 16:18:46 2016 +0200 +++ b/faptool.php Wed Feb 10 16:20:56 2016 +0200 @@ -221,7 +221,7 @@ wtPurgeDir($path); // Create temporary directory for unpacking - wtMakeDir($path, 0700); + wtMakeDir($path, 0755); // Save current working directory and chdir to target $cwd = getcwd(); @@ -508,6 +508,34 @@ return FALSE; } + // Make information file contents + $sbinfo = [ + "FAP Entry Information", + "=====================", + "Compo : ".$compo["name"]." (ID #".$compo["id"].")", + "Entry : '".$entry["name"]."' by ".$entry["author"]." (ID #".$entry["id"].")", + "Show # : ".($entry["show_id"] > 0 ? $entry["show_id"] : "NOT SET!"), + ]; + + if (strlen($entry["info"]) > 0) + { + $sbinfo[] = ""; + $sbinfo[] = "INFO:"; + foreach (preg_split("/\r\n|\n|\r/", $entry["info"]) as $sline) + $sbinfo[] = $sline; + } + + if (strlen($entry["notes"]) > 0) + { + $sbinfo[] = ""; + $sbinfo[] = "INTERNAL NOTES:"; + foreach (preg_split("/\r\n|\n|\r/", $entry["notes"]) as $sline) + $sbinfo[] = $sline; + } + + $sbinfo[] = ""; + + // Create the destination directory if (wtMakeDir(stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"])), 0755) === false) return FALSE; @@ -518,23 +546,37 @@ else $dstFileBase = wtCropFilename($entry["show_id"]."-".($useOrig ? $efile["origname"] : $efile["filename"]), $cropNames); + $dstPath = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], stReplaceFileExt($dstFileBase, ""))); // Handle based on class/type and whether we are just copying or not - if (!$copyOnly && $edata["class"] == EFILE_ARCHIVE) + if ($copyOnly) + { + $dstFilename = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], $dstFileBase)); + if (copy($filename, $dstFilename) === false) + { + echo "ERROR: Failed to copy '".$filename."' to '".$dstFilename."'\n"; + return FALSE; + } + } + else + if ($edata["class"] == EFILE_ARCHIVE) { // Entry is an archive file, so unpack it - $dstPath = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], stReplaceFileExt($dstFileBase, ""))); if (wtUnpackArchiveTo($edata["id"], $filename, $dstPath) === false) return FALSE; // Crop the filenames from the unpacked archive, if we need to if ($cropNames !== false) wtCropFilenamesRec($dstPath, $cropNames); + } else { // We have a single file (or copyOnly mode) - $dstFilename = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], $dstFileBase)); + if (wtMakeDir($dstPath, 0755) === false) + return FALSE; + + $dstFilename = stMakePath(FALSE, FALSE, array($dstPath, wtCropFilename($efile["origname"], $cropNames))); if (copy($filename, $dstFilename) === false) { echo "ERROR: Failed to copy '".$filename."' to '".$dstFilename."'\n"; @@ -542,6 +584,13 @@ } } + $dstFilename = stMakePath(FALSE, FALSE, array($dstPath, "fapinfo.txt")); + if (@file_put_contents($dstFilename, implode("\r\n", $sbinfo)) === FALSE) + { + echo "ERROR: Failed to output '".$dstFilename."'\n"; + return FALSE; + } + return TRUE; }