/** * @see ISimulatorObserver::onBeforeMatchStarts() */ public function onBeforeMatchStarts(SimulationMatch $match) { // compute sold tickets if (($this->_websoccer->getConfig('sim_income_trough_friendly') || $match->type !== 'Freundschaft') && !$match->isAtForeignStadium) { SimulationAudienceCalculator::computeAndSaveAudience($this->_websoccer, $this->_db, $match); } // update user ids $clubTable = $this->_websoccer->getConfig('db_prefix') . '_verein'; $updateColumns = array(); $result = $this->_db->querySelect('user_id', $clubTable, 'id = %d AND user_id > 0', $match->homeTeam->id); $homeUser = $result->fetch_array(); $result->free(); if ($homeUser) { $updateColumns['home_user_id'] = $homeUser['user_id']; } $result = $this->_db->querySelect('user_id', $clubTable, 'id = %d AND user_id > 0', $match->guestTeam->id); $guestUser = $result->fetch_array(); $result->free(); if ($guestUser) { $updateColumns['gast_user_id'] = $guestUser['user_id']; } if (count($updateColumns)) { $this->_db->queryUpdate($updateColumns, $this->_websoccer->getConfig('db_prefix') . '_spiel', 'id = %d', $match->id); } }
$columns["M.home_w" . $subNo . "_minute"] = "home_sub_" . $subNo . "_minute"; $columns["M.home_w" . $subNo . "_condition"] = "home_sub_" . $subNo . "_condition"; $columns["M.gast_w" . $subNo . "_raus"] = "guest_sub_" . $subNo . "_out"; $columns["M.gast_w" . $subNo . "_rein"] = "guest_sub_" . $subNo . "_in"; $columns["M.gast_w" . $subNo . "_minute"] = "guest_sub_" . $subNo . "_minute"; $columns["M.gast_w" . $subNo . "_condition"] = "guest_sub_" . $subNo . "_condition"; } $result = $db->querySelect($columns, $fromTable, "M.id = %d", $matchId); $matchinfo = $result->fetch_array(); $result->free(); // init default simulation strategry in order to include dependend constants. Yeah, refactor this once having to much time... $dummyVar = new DefaultSimulationStrategy($website); $matchModel = SimulationStateHelper::loadMatchState($website, $db, $matchinfo); // compute audience if ($website->getRequestParameter("computetickets")) { SimulationAudienceCalculator::computeAndSaveAudience($website, $db, $matchModel); } if ($matchinfo["type"] == "Pokalspiel") { SimulationCupMatchHelper::checkIfExtensionIsRequired($website, $db, $matchModel); } // complete match $observer = new DataUpdateSimulatorObserver($website, $db); $observer->onMatchCompleted($matchModel); // show success message echo createSuccessMessage($i18n->getMessage("match_manage_complete_success"), ""); } echo "<h3><a href=\"" . $website->getInternalUrl("team", "id=" . $match["match_home_id"]) . "\" target=\"_blank\">" . escapeOutput($match["match_home_name"]) . "</a> - <a href=\"" . $website->getInternalUrl("team", "id=" . $match["match_guest_id"]) . "\" target=\"_blank\">" . escapeOutput($match["match_guest_name"]) . "</a></h3>"; echo "<div class=\"well\">" . $i18n->getMessage("match_manage_complete_intro") . "</div>"; echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\" class=\"form-horizontal\">"; echo "<input type=\"hidden\" name=\"site\" value=\"{$site}\"/>"; echo "<input type=\"hidden\" name=\"action\" value=\"complete\"/>";