function draftPlayer($userID, $leagueID, $playerID, $position, $transactionID, $passedInStatus) { $season = getSeason(); debug("passed in status {$passedInStatus}"); if (!okToTransact($transactionID)) { return getReturnCode(0, "This transaction has already been completed. Please do not use the refresh button."); } // If PassedPick, skip validation and just insert 'em if ($playerID == "PassedPick") { $status = "P"; $overallPick = getSingleton("fch_draft", "max(overallPick)", " where leagueID = {$leagueID}") + 1; } else { /////////// IS NOT PASSED PICK $status = $passedInStatus; $check = selectCount("fch_draft", " where leagueID = {$leagueID} and playerID = \"{$playerID}\""); $r = array(); if ($check > 0) { // 0 is available $r["status"] = 0; $r["msg"] = "Error: Player has already been drafted."; return $r; } $rosterCount = selectCount("fch_draft", " Where userID = {$userID} and position = \"{$position}\" and leagueID = {$leagueID}"); $limit = getPositionLimit($position, "b", $leagueID) + getPositionLimit($position, "a", $leagueID); debug("Roster Slot calc: {$rosterCount} >= {$limit}"); if ($rosterCount >= $limit) { debug("no slots, returning failure"); $r["status"] = 0; $r["msg"] = "You have already drafted a full complient at this position."; return $r; } debug("passed validation, inserting"); $overallPick = getSingleton("fch_draft", "max(overallPick)", " where leagueID = {$leagueID}") + 1; $passedPick = getSingleton("fch_draft", "overallPick", " WHERE leagueID = {$leagueID} and userID = {$userID} and status = \"P\" ORDER BY overallPick DESC Limit 0,1"); if ($passedPick != "") { $overallPick = $passedPick; debug("Replacing Passed Pick at Overall pick # {$passedPick}"); $replace = " We have replaced your previously passed pick at overall pick # {$overallPick}."; executeGenericSQL("DELETE FROM fch_draft WHERE leagueID = {$leagueID} and userID = {$userID} and status = \"P\" and overallPick = {$overallPick}"); } else { $withdrawnPick = getSingleton("fch_draft", "overallPick", " WHERE leagueID = {$leagueID} and userID = {$userID} and status = \"W\" ORDER BY overallPick DESC Limit 0,1"); if ($withdrawnPick != "") { $overallPick = $withdrawnPick; debug("Replaceing Withdrawn Pick at Overall pick # {$withdrawnPick}"); $replace = " We have replaced your previously withdrawn pick at overall pick # {$overallPick}."; $delete = "DELETE FROM fch_draft WHERE leagueID = {$leagueID} and userID = {$userID} and status = \"W\" and overallPick = {$overallPick}"; debug("DELETE " + $delete); executeGenericSQL($delete); } } } $sql = <<<SQL \tINSERT INTO fanta66_joomla.fch_draft ( \t\tid , \t\tleagueID , \t\tuserID , \t\tplayerID, \t\tposition, \t\tdateStamp, \t\toverallPick, \t\tstatus \t\t) \t\tVALUES ( \t\t\tNULL , {$leagueID}, {$userID}, "{$playerID}", "{$position}", DATE_ADD(CURRENT_TIMESTAMP, INTERVAL +3 HOUR), {$overallPick}, "{$status}" \t\t); \t\t SQL; debug($sql); $rosterID = executeGenericInsertSQL($sql); $r["status"] = 1; $r["msg"] = "Your transaction was successful. {$replace}"; $r["id"] = $rosterID; setTransactionComplete($transactionID); return $r; }
if ($_POST["allowRegAfterDeadlineCheckbox"] == "on") { $r = executeGenericSQL("UPDATE fch_leagues SET allowRegAfterDeadline = TRUE WHERE {$leagueID} = id and season = \"{$season}\""); } else { $r = executeGenericSQL("UPDATE fch_leagues SET allowRegAfterDeadline = FALSE WHERE {$leagueID} = id and season = \"{$season}\""); } setTransactionComplete($_POST["transactionID"]); debug("Return Code {$r}"); if ($r != -1) { echo displayResults(getReturnCode(1, "Successfully updated league configuration.")); } else { echo displayResults(getReturnCode(0, "There has been an error. Please try again or contact us.")); } } } if ($_POST["action"] == "removeGM") { if (!okToTransact($_POST["transactionID"])) { echo displayResults(getReturnCode(0, "This transaction has already been completed. Please do not use the refresh button.")); } else { $gmToDelete = intval($_POST["gmToDelete"]); debug("Removing {$gmToDelete} from league {$leagueID}"); $r = executeGenericSQL("UPDATE fch_league_membership SET status = \"removed\" WHERE userID = {$gmToDelete} and {$leagueID} = leagueID and season = \"{$season}\""); if ($r != -1) { $r = executeGenericSQL("UPDATE fch_rosters SET releaseDate = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL +3 HOUR) where userID = {$gmToDelete} and leagueID = {$leagueID} and releaseDate is NULL and season = \"{$season}\" "); if ($r != -1) { echo displayResults(getReturnCode(1, "Successfully removed this GM.")); } } else { echo displayResults(getReturnCode(0, "There has been an error releasing this GM's players.")); } } setTransactionComplete($_POST["transactionID"]);