/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); $team = TeamsDataService::getTeamById($this->_websoccer, $this->_db, $clubId); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception("nice try"); } $this->_db->queryUpdate(array("captain_id" => $parameters["id"]), $this->_websoccer->getConfig("db_prefix") . "_verein", "id = %d", $clubId); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("myteam_player_select_as_captain_success"), "")); // check if captain has been changed and show disappointment if ($team["captain_id"] && $team["captain_id"] != $parameters["id"]) { $oldPlayer = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $team["captain_id"]); // maybe player has moved to new team, then just ignore it if ($oldPlayer["team_id"] == $clubId) { $newSatisfaction = round($oldPlayer["player_strength_satisfaction"] * 0.6); $this->_db->queryUpdate(array("w_zufriedenheit" => $newSatisfaction), $this->_websoccer->getConfig("db_prefix") . "_spieler", "id = %d", $oldPlayer["player_id"]); $playername = strlen($oldPlayer["player_pseudonym"]) ? $oldPlayer["player_pseudonym"] : $oldPlayer["player_firstname"] . " " . $oldPlayer["player_lastname"]; $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $this->_i18n->getMessage("myteam_player_select_as_captain_warning_old_captain", $playername), "")); } } return null; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("enable_player_resignation")) { return; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception("nice try"); } // check violation of minimum team size $teamSize = $this->getTeamSize($clubId); if ($teamSize <= $this->_websoccer->getConfig("transfermarket_min_teamsize")) { throw new Exception($this->_i18n->getMessage("sell_player_teamsize_too_small", $teamSize)); } // check and withdraw compensation if ($this->_websoccer->getConfig("player_resignation_compensation_matches") > 0) { $compensation = $this->_websoccer->getConfig("player_resignation_compensation_matches") * $player["player_contract_salary"]; $team = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $clubId); if ($team["team_budget"] <= $compensation) { throw new Exception($this->_i18n->getMessage("fireplayer_tooexpensive")); } BankAccountDataService::debitAmount($this->_websoccer, $this->_db, $clubId, $compensation, "fireplayer_compensation_subject", $player["player_firstname"] . " " . $player["player_lastname"]); } $this->updatePlayer($player["player_id"]); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("fireplayer_success"), "")); return null; }
public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("transferoffers_enabled")) { return; } $clubId = $this->_websoccer->getUser()->getClubId($this->_websoccer, $this->_db); // get offer information $result = $this->_db->querySelect("*", $this->_websoccer->getConfig("db_prefix") . "_transfer_offer", "id = %d AND receiver_club_id = %d", array($parameters["id"], $clubId)); $offer = $result->fetch_array(); $result->free(); if (!$offer) { throw new Exception($this->_i18n->getMessage("transferoffers_offer_cancellation_notfound")); } $this->_db->queryUpdate(array("rejected_date" => $this->_websoccer->getNowAsTimestamp(), "rejected_message" => $parameters["comment"], "rejected_allow_alternative" => $parameters["allow_alternative"] ? 1 : 0), $this->_websoccer->getConfig("db_prefix") . "_transfer_offer", "id = %d", $offer["id"]); // get player name for notification $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $offer["player_id"]); if ($player["player_pseudonym"]) { $playerName = $player["player_pseudonym"]; } else { $playerName = $player["player_firstname"] . " " . $player["player_lastname"]; } // create notification NotificationsDataService::createNotification($this->_websoccer, $this->_db, $offer["sender_user_id"], "transferoffer_notification_rejected", array("playername" => $playerName, "receivername" => $this->_websoccer->getUser()->username), "transferoffer", "transferoffers#sent"); // show success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("transferoffers_offer_reject_success"), "")); return null; }
public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("transfermarket_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception("nice try"); } // check if player is already on market if ($player["player_transfermarket"]) { throw new Exception($this->_i18n->getMessage("sell_player_already_on_list")); } // check if player is borrowed or lendable. User should not come to this point, so message is not important. if ($player["lending_fee"] > 0) { throw new Exception($this->_i18n->getMessage("lending_err_alreadyoffered")); } // check violation of minimum team size $teamSize = TeamsDataService::getTeamSize($this->_websoccer, $this->_db, $clubId); if ($teamSize <= $this->_websoccer->getConfig("transfermarket_min_teamsize")) { throw new Exception($this->_i18n->getMessage("sell_player_teamsize_too_small", $teamSize)); } $minBidBoundary = round($player["player_marketvalue"] / 2); if ($parameters["min_bid"] < $minBidBoundary) { throw new Exception($this->_i18n->getMessage("sell_player_min_bid_too_low")); } $this->updatePlayer($player["player_id"], $parameters["min_bid"]); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("sell_player_success"), "")); return "transfermarket"; }
public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("lending_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if user has team if ($clubId == null) { throw new Exception($this->_i18n->getMessage("feature_requires_team")); } // check if it is already own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId == $player["team_id"]) { throw new Exception($this->_i18n->getMessage("lending_hire_err_ownplayer")); } // check if player is borrowed by any user if ($player["lending_owner_id"] > 0) { throw new Exception($this->_i18n->getMessage("lending_hire_err_borrowed_player")); } // check if player is offered for lending if ($player["lending_fee"] == 0) { throw new Exception($this->_i18n->getMessage("lending_hire_err_notoffered")); } // check if player is on transfermarket if ($player["player_transfermarket"] > 0) { throw new Exception($this->_i18n->getMessage("lending_err_on_transfermarket")); } // check min and max duration if ($parameters["matches"] < $this->_websoccer->getConfig("lending_matches_min") || $parameters["matches"] > $this->_websoccer->getConfig("lending_matches_max")) { throw new Exception(sprintf($this->_i18n->getMessage("lending_hire_err_illegalduration"), $this->_websoccer->getConfig("lending_matches_min"), $this->_websoccer->getConfig("lending_matches_max"))); } // check player's contract length if ($parameters["matches"] >= $player["player_contract_matches"]) { throw new Exception($this->_i18n->getMessage("lending_hire_err_contractendingtoosoon", $player["player_contract_matches"])); } // check if team can pay fee and salary $fee = $parameters["matches"] * $player["lending_fee"]; // team should have the money for at least 5 matches to pay him $minBudget = $fee + 5 * $player["player_contract_salary"]; $team = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $clubId); if ($team["team_budget"] < $minBudget) { throw new Exception($this->_i18n->getMessage("lending_hire_err_budget_too_low")); } // deduct and credit fee BankAccountDataService::debitAmount($this->_websoccer, $this->_db, $clubId, $fee, "lending_fee_subject", $player["team_name"]); BankAccountDataService::creditAmount($this->_websoccer, $this->_db, $player["team_id"], $fee, "lending_fee_subject", $team["team_name"]); $this->updatePlayer($player["player_id"], $player["team_id"], $clubId, $parameters["matches"]); // create notification for owner $playerName = strlen($player["player_pseudonym"]) ? $player["player_pseudonym"] : $player["player_firstname"] . " " . $player["player_lastname"]; if ($player["team_user_id"]) { NotificationsDataService::createNotification($this->_websoccer, $this->_db, $player["team_user_id"], "lending_notification_lent", array("player" => $playerName, "matches" => $parameters["matches"], "newteam" => $team["team_name"]), "lending_lent", "player", "id=" . $player["player_id"]); } // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("lending_hire_success"), "")); return "myteam"; }
public function renderView() { $playerId = (int) $this->_websoccer->getRequestParameter("id"); if ($playerId < 1) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } $this->_player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); return $this->_player["transfer_end"] > $this->_websoccer->getNowAsTimestamp(); }
public function executeAction($parameters) { $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception("nice try"); } // if player is not happy at club, he does not want to extend at all $satisfaction = $player["player_strength_satisfaction"]; if ($satisfaction < MINIMUM_SATISFACTION_FOR_EXTENSION) { throw new Exception($this->_i18n->getMessage("extend-contract_player_is_unhappy")); } // check if player is already on market if ($player["player_transfermarket"]) { throw new Exception($this->_i18n->getMessage("sell_player_already_on_list")); } // no salary decrease if ($parameters["salary"] < $player["player_contract_salary"]) { throw new Exception($this->_i18n->getMessage("extend-contract_lower_than_current_salary")); } $averageSalary = $this->getAverageSalary($player["player_strength"]); // if salary is already higher than average, then just expect 10% more if ($player["player_contract_salary"] > $averageSalary) { $salaryFactor = 1.1; } else { // make minimum salary dependent on happiness $salaryFactor = (200 - $satisfaction) / 100; } $salaryFactor = max(1.1, $salaryFactor); $minSalary = round($player["player_contract_salary"] * $salaryFactor); // the salary should be at least 90% of the average, except if this would douple the salary if ($averageSalary < $parameters["salary"] * 2) { $minSalaryOfAverage = round(0.9 * $averageSalary); $minSalary = max($minSalary, $minSalaryOfAverage); } if ($parameters["salary"] < $minSalary) { // decrease satisfaction $this->decreaseSatisfaction($player["player_id"], $player["player_strength_satisfaction"]); throw new Exception($this->_i18n->getMessage("extend-contract_salary_too_low")); } // check if club can pay this salary TeamsDataService::validateWhetherTeamHasEnoughBudgetForSalaryBid($this->_websoccer, $this->_db, $this->_i18n, $clubId, $parameters["salary"]); // check goal bonus $minGoalBonus = $player["player_contract_goalbonus"] * 1.3; if ($parameters["goal_bonus"] < $minGoalBonus) { throw new Exception($this->_i18n->getMessage("extend-contract_goalbonus_too_low")); } $this->updatePlayer($player["player_id"], $player["player_strength_satisfaction"], $parameters["salary"], $parameters["goal_bonus"], $parameters["matches"]); // reset inactivity UserInactivityDataService::resetContractExtensionField($this->_websoccer, $this->_db, $user->id); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("extend-contract_success"), "")); return null; }
public function __construct($db, $i18n, $websoccer) { $this->_db = $db; $this->_i18n = $i18n; $this->_websoccer = $websoccer; $playerId = (int) $this->_websoccer->getRequestParameter("id"); if ($playerId < 1) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } $this->_player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); }
public function getTemplateParameters() { $playerId = (int) $this->_websoccer->getRequestParameter("id"); if ($playerId < 1) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); if (!isset($player["player_id"])) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } return array("player" => $player); }
public function getTemplateParameters() { $playerId = (int) $this->_websoccer->getRequestParameter("id"); if ($playerId < 1) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); if (!isset($player["player_id"])) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } $grades = $this->_getGrades($playerId); $transfers = TransfermarketDataService::getCompletedTransfersOfPlayer($this->_websoccer, $this->_db, $playerId); return array("player" => $player, "grades" => $grades, "completedtransfers" => $transfers); }
private function checkExchangePlayer($playerId, $userId, $teamBudget) { $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); $playerName = strlen($player["player_pseudonym"]) ? $player["player_pseudonym"] : $player["player_firstname"] . " " . $player["player_lastname"]; // Check if player is moved to tranfermarket if ($player["player_transfermarket"]) { throw new Exception($this->_i18n->getMessage("transferoffer_accept_err_exchangeplayer_on_transfermarket", $playerName)); } // Check if player is still playing for the user (might have changed) if ($player["team_user_id"] != $userId) { throw new Exception($this->_i18n->getMessage("transferoffer_accept_err_exchangeplayer_notinteam", $playerName)); } // check if user can afford player $minBudget = 40 * $player["player_contract_salary"]; if ($teamBudget < $minBudget) { throw new Exception($this->_i18n->getMessage("transferoffer_accept_err_exchangeplayer_salarytoohigh", $playerName)); } }
public function executeAction($parameters) { $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception("nice try"); } $columns["unsellable"] = 1; $fromTable = $this->_websoccer->getConfig("db_prefix") . "_spieler"; $whereCondition = "id = %d"; $parameters = $parameters["id"]; $this->_db->queryUpdate($columns, $fromTable, $whereCondition, $parameters); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("myteam_unsellable_player_success"), "")); return null; }
public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("lending_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception($this->_i18n->getMessage("lending_err_notownplayer")); } // check if player is borrowed by user if ($player["lending_owner_id"] > 0) { throw new Exception($this->_i18n->getMessage("lending_err_borrowed_player")); } // check if player is already offered for lending if ($player["lending_fee"] > 0) { throw new Exception($this->_i18n->getMessage("lending_err_alreadyoffered")); } // check if player is on transfermarket if ($player["player_transfermarket"] > 0) { throw new Exception($this->_i18n->getMessage("lending_err_on_transfermarket")); } // check violation of minimum team size $teamSize = TeamsDataService::getTeamSize($this->_websoccer, $this->_db, $clubId); if ($teamSize <= $this->_websoccer->getConfig("transfermarket_min_teamsize")) { throw new Exception($this->_i18n->getMessage("lending_err_teamsize_too_small", $teamSize)); } // remaining contract is too short $minBidBoundary = round($player["player_marketvalue"] / 2); if ($player["player_contract_matches"] <= $this->_websoccer->getConfig("lending_matches_min")) { throw new Exception($this->_i18n->getMessage("lending_err_contract_too_short")); } $this->updatePlayer($player["player_id"], $parameters["fee"]); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("lend_player_success"), "")); return "myteam"; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("transfermarket_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception("nice try"); } // check if there is already a bid $highestBid = TransfermarketDataService::getHighestBidForPlayer($this->_websoccer, $this->_db, $parameters["id"], $player["transfer_start"], $player["transfer_end"]); if ($highestBid) { throw new Exception($this->_i18n->getMessage("transfermarket_remove_err_bidexists")); } $this->_db->queryUpdate(array('transfermarkt' => '0', 'transfer_start' => 0, 'transfer_ende' => 0), $this->_websoccer->getConfig('db_prefix') . '_spieler', 'id = %d', $parameters['id']); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("transfermarket_remove_success"), "")); return "myteam"; }
public function executeAction($parameters) { $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player. Might be already lent in the meanwhile. Or someone tries to cheat. $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception($this->_i18n->getMessage("lending_err_notownplayer")); } // check if he is already lent. // Then the player is lent to the user itself and he tries to cheat, hence message is not that important. if ($player["lending_owner_id"] > 0) { throw new Exception($this->_i18n->getMessage("lending_err_borrowed_player")); } $columns = array("lending_fee" => 0); $fromTable = $this->_websoccer->getConfig("db_prefix") . "_spieler"; $whereCondition = "id = %d"; $parameters = $parameters["id"]; $this->_db->queryUpdate($columns, $fromTable, $whereCondition, $parameters); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("lending_lendable_unmark_success"), "")); return null; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig('transfermarket_enabled')) { return; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); $playerId = $parameters['id']; // check if user has a club if ($clubId < 1) { throw new Exception($this->_i18n->getMessage('error_action_required_team')); } // check if it is not own player $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); if ($user->id == $player['team_user_id']) { throw new Exception($this->_i18n->getMessage('transfer_bid_on_own_player')); } // check if player is still on transfer list if (!$player['player_transfermarket']) { throw new Exception($this->_i18n->getMessage('transfer_bid_player_not_on_list')); } // check that auction is not over $now = $this->_websoccer->getNowAsTimestamp(); if ($now > $player['transfer_end']) { throw new Exception($this->_i18n->getMessage('transfer_bid_auction_ended')); } // player must accept the new salary $minSalary = $player['player_contract_salary'] * 1.1; if ($parameters['contract_salary'] < $minSalary) { throw new Exception($this->_i18n->getMessage('transfer_bid_salary_too_less')); } // check goal bonus $minGoalBonus = $player['player_contract_goalbonus'] * 1.1; if ($parameters['contract_goal_bonus'] < $minGoalBonus) { throw new Exception($this->_i18n->getMessage('transfer_bid_goalbonus_too_less')); } // check if user has been already traded too often with the other user if ($player['team_id'] > 0) { $noOfTransactions = TransfermarketDataService::getTransactionsBetweenUsers($this->_websoccer, $this->_db, $player['team_user_id'], $user->id); $maxTransactions = $this->_websoccer->getConfig('transfermarket_max_transactions_between_users'); if ($noOfTransactions >= $maxTransactions) { throw new Exception($this->_i18n->getMessage('transfer_bid_too_many_transactions_with_user', $noOfTransactions)); } } // get existing highest bid $highestBid = TransfermarketDataService::getHighestBidForPlayer($this->_websoccer, $this->_db, $parameters['id'], $player['transfer_start'], $player['transfer_end']); // with transfer-fee: check if own bid amount is higher than existing bid if ($player['team_id'] > 0) { $minBid = $player['transfer_min_bid'] - 1; if (isset($highestBid['amount'])) { $minBid = $highestBid['amount']; } if ($parameters['amount'] <= $minBid) { throw new Exception($this->_i18n->getMessage('transfer_bid_amount_must_be_higher', $minBid)); } // without transfer fee: compare contract conditions } else { if (isset($highestBid['contract_matches'])) { // we compare the total income of the whole offered contract duraction $ownBidValue = $parameters['handmoney'] + $parameters['contract_matches'] * $parameters['contract_salary']; $opponentSalary = $highestBid['hand_money'] + $highestBid['contract_matches'] * $highestBid['contract_salary']; // consider goal bonus only for midfield and striker, assuming player scores 10 goals if ($player['player_position'] == 'midfield' || $player['player_position'] == 'striker') { $ownBidValue += 10 * $parameters['contract_goal_bonus']; $opponentSalary += 10 * $highestBid['contract_goalbonus']; } if ($ownBidValue <= $opponentSalary) { throw new Exception($this->_i18n->getMessage('transfer_bid_contract_conditions_too_low')); } } } // check if budget is enough (hand money/fee + assume that the team consists of 20 players with same salary, then it should survive for 2 matches) TeamsDataService::validateWhetherTeamHasEnoughBudgetForSalaryBid($this->_websoccer, $this->_db, $this->_i18n, $clubId, $parameters['contract_salary']); // check if budget is enough for all current highest bids of user. $team = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $clubId); $result = $this->_db->querySelect('SUM(abloese) + SUM(handgeld) AS bidsamount', $this->_websoccer->getConfig('db_prefix') . '_transfer_angebot', 'user_id = %d AND ishighest = \'1\'', $user->id); $bids = $result->fetch_array(); $result->free(); if (isset($bids['bidsamount']) && $parameters['handmoney'] + $parameters['amount'] + $bids['bidsamount'] >= $team['team_budget']) { throw new Exception($this->_i18n->getMessage('transfer_bid_budget_for_all_bids_too_less')); } // save bid $this->saveBid($playerId, $user->id, $clubId, $parameters); // mark previous highest bid as outbidden if (isset($highestBid['bid_id'])) { $this->_db->queryUpdate(array('ishighest' => '0'), $this->_websoccer->getConfig('db_prefix') . '_transfer_angebot', 'id = %d', $highestBid['bid_id']); } // notify outbidden user if (isset($highestBid['user_id']) && $highestBid['user_id']) { $playerName = strlen($player['player_pseudonym']) ? $player['player_pseudonym'] : $player['player_firstname'] . ' ' . $player['player_lastname']; NotificationsDataService::createNotification($this->_websoccer, $this->_db, $highestBid['user_id'], 'transfer_bid_notification_outbidden', array('player' => $playerName), 'transfermarket', 'transfer-bid', 'id=' . $playerId); } // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage('transfer_bid_success'), '')); return null; }
/** * Executes a transfer according to direct transfer offer. Deletes all offers for this player on success. * * @param WebSoccer $websoccer application context. * @param DbConnection $db DB connection. * @param unknown $offerId id of direct transfer offer. */ public static function executeTransferFromOffer(WebSoccer $websoccer, DbConnection $db, $offerId) { // offer data $result = $db->querySelect("*", $websoccer->getConfig("db_prefix") . "_transfer_offer", "id = %d", $offerId); $offer = $result->fetch_array(); $result->free(); if (!$offer) { return; } $currentTeam = TeamsDataService::getTeamSummaryById($websoccer, $db, $offer["receiver_club_id"]); $targetTeam = TeamsDataService::getTeamSummaryById($websoccer, $db, $offer["sender_club_id"]); // move player (and create transfer log) self::_transferPlayer($websoccer, $db, $offer["player_id"], $offer["sender_club_id"], $offer["sender_user_id"], $currentTeam["user_id"], $offer["receiver_club_id"], $offer["offer_amount"], $offer["offer_player1"], $offer["offer_player2"]); // credit amount BankAccountDataService::creditAmount($websoccer, $db, $offer["receiver_club_id"], $offer["offer_amount"], "directtransfer_subject", $targetTeam["team_name"]); // debit amount BankAccountDataService::debitAmount($websoccer, $db, $offer["sender_club_id"], $offer["offer_amount"], "directtransfer_subject", $currentTeam["team_name"]); // move exchange players if ($offer["offer_player1"]) { self::_transferPlayer($websoccer, $db, $offer["offer_player1"], $offer["receiver_club_id"], $currentTeam["user_id"], $targetTeam["user_id"], $offer["sender_club_id"], 0, $offer["player_id"]); } if ($offer["offer_player2"]) { self::_transferPlayer($websoccer, $db, $offer["offer_player2"], $offer["receiver_club_id"], $currentTeam["user_id"], $targetTeam["user_id"], $offer["sender_club_id"], 0, $offer["player_id"]); } // delete offer and other offers for this player $db->queryDelete($websoccer->getConfig("db_prefix") . "_transfer_offer", "player_id = %d", $offer["player_id"]); // get player name for notification $player = PlayersDataService::getPlayerById($websoccer, $db, $offer["player_id"]); if ($player["player_pseudonym"]) { $playerName = $player["player_pseudonym"]; } else { $playerName = $player["player_firstname"] . " " . $player["player_lastname"]; } // notify and award users NotificationsDataService::createNotification($websoccer, $db, $currentTeam["user_id"], "transferoffer_notification_executed", array("playername" => $playerName), NOTIFICATION_TYPE, "player", "id=" . $offer["player_id"], $currentTeam["team_id"]); NotificationsDataService::createNotification($websoccer, $db, $offer["sender_user_id"], "transferoffer_notification_executed", array("playername" => $playerName), NOTIFICATION_TYPE, "player", "id=" . $offer["player_id"], $targetTeam['team_id']); TransfermarketDataService::awardUserForTrades($websoccer, $db, $currentTeam["user_id"]); TransfermarketDataService::awardUserForTrades($websoccer, $db, $offer["sender_user_id"]); }
private function checkExchangePlayer($playerId) { $player = PlayersDataService::getPlayerById($this->_websoccer, $this->_db, $playerId); $playerName = strlen($player["player_pseudonym"]) ? $player["player_pseudonym"] : $player["player_firstname"] . " " . $player["player_lastname"]; // Check if selected players are not on transfer market and belong to own team if ($player["player_transfermarket"] || $player["team_user_id"] != $this->_websoccer->getUser()->id) { throw new Exception($this->_i18n->getMessage("transferoffer_err_exchangeplayer_on_transfermarket", $playerName)); } // Players must not be included in any other open transfer offer $result = $this->_db->querySelect("COUNT(*) AS hits", $this->_websoccer->getConfig("db_prefix") . "_transfer_offer", "rejected_date = 0 AND (offer_player1 = %d OR offer_player2 = %d)", array($playerId, $playerId, $playerId)); $count = $result->fetch_array(); $result->free(); if ($count["hits"]) { throw new Exception($this->_i18n->getMessage("transferoffer_err_exchangeplayer_involved_in_other_offers", $playerName)); } // check transfer stop of player try { $this->checkPlayersTransferStop($playerId); } catch (Exception $e) { // replace error message throw new Exception($this->_i18n->getMessage("transferoffer_err_exchangeplayer_transferstop", $playerName)); } }
$columns[$formField] = $_POST["pl" . $playerId . "_" . $formField]; } // update player record $db->queryUpdate($columns, $updateTable, "spiel_id = %d AND spieler_id = %d", array($matchId, $playerId)); } } echo createSuccessMessage($i18n->getMessage("alert_save_success"), ""); } elseif ($action == "create") { if ($admin["r_demo"]) { throw new Exception($i18n->getMessage("validationerror_no_changes_as_demo")); } $teamId = (int) $_POST["team_id"]; $playerId = (int) $_POST["playerid"]; $position = $_POST["position"]; if ($teamId && $playerId && strlen($position)) { $player = PlayersDataService::getPlayerById($website, $db, $playerId); $playerName = strlen($player["player_pseudonym"]) ? $player["player_pseudonym"] : $player["player_firstname"] . " " . $player["player_lastname"]; $db->queryInsert(array("spiel_id" => $matchId, "spieler_id" => $playerId, "team_id" => $teamId, "position_main" => $position, "note" => 3.0, "name" => $playerName), $website->getConfig("db_prefix") . "_spiel_berechnung"); } } elseif ($action == "generate") { if ($admin["r_demo"]) { throw new Exception($i18n->getMessage("validationerror_no_changes_as_demo")); } // init default simulation strategry in order to include dependend constants. Yeah, refactor this once having to much time... $dummyVar = new DefaultSimulationStrategy($website); $match = MatchesDataService::getMatchById($website, $db, $matchId, FALSE, FALSE); $teamPrefix = in_array($_GET["team"], array("home", "guest")) ? $_GET["team"] : "home"; $team = new SimulationTeam($match["match_" . $teamPrefix . "_id"]); $team->isNationalTeam = $match["match_" . $teamPrefix . "_nationalteam"]; // get formation $formationcolumns = array("offensive" => "offensive", "longpasses" => "longpasses", "counterattacks" => "counterattacks", "setup" => $teamPrefix . "_formation_setup");