private function _actionBoxes($ALLOW_EDIT, $players) { /****************************** * Team management * --------------- * * Here we are able to view team stats and manage the team, depending on visitors privileges. * ******************************/ global $lng, $rules, $settings, $skillarray, $coach, $DEA, $CHR_CONV; global $leagues, $divisions; global $racesHasNecromancer, $racesNoApothecary; global $T_ALLOWED_PLAYER_NR; $team = $this; // Copy. Used instead of $this for readability. $JMP_ANC = isset($_POST['menu_tmanage']) || isset($_POST['menu_admintools']); # Jump condition MUST be set here due to _POST variables being changed later. ?> <a name="aanc"></a> <div class="boxTeamPage"> <div class="boxTitle<?php echo T_HTMLBOX_INFO; ?> "><a name='anc'><?php echo $lng->getTrn('profile/team/box_info/title'); ?> </a></div> <div class="boxBody"> <table width="100%"> <tr> <td><?php echo $lng->getTrn('common/coach'); ?> </td> <td><a href="<?php echo urlcompile(T_URL_PROFILE, T_OBJ_COACH, $team->owned_by_coach_id, false, false); ?> "><?php echo $team->f_cname; ?> </a></td> </tr> <tr> <td><?php echo $lng->getTrn('common/race'); ?> </td> <td><a href="<?php echo urlcompile(T_URL_PROFILE, T_OBJ_RACE, $team->f_race_id, false, false); ?> "><?php echo $lng->getTrn('race/' . strtolower(str_replace(' ', '', $team->f_rname))); ?> </a></td> </tr> <tr> <td><?php echo $lng->getTrn('common/league'); ?> </td> <td><?php if (isset($leagues[$team->f_lid])) { echo "<a href=\""; echo urlcompile(T_URL_STANDINGS, T_OBJ_TEAM, false, T_NODE_LEAGUE, $team->f_lid); echo "\">" . $leagues[$team->f_lid]['lname'] . "</a>"; } else { echo '<i>' . $lng->getTrn('common/none') . '</i>'; } ?> </td> </tr> <?php if ($team->f_did != self::T_NO_DIVISION_TIE) { ?> <tr> <td><?php echo $lng->getTrn('common/division'); ?> </td> <td><?php if (isset($divisions[$team->f_did])) { echo "<a href=\""; echo urlcompile(T_URL_STANDINGS, T_OBJ_TEAM, false, T_NODE_DIVISION, $team->f_did); echo "\">" . $divisions[$team->f_did]['dname'] . "</a>"; } else { echo '<i>' . $lng->getTrn('common/none') . '</i>'; } ?> </td> </tr> <?php } ?> <tr> <td><?php echo $lng->getTrn('common/ready'); ?> </td> <td><?php echo $team->rdy ? $lng->getTrn('common/yes') : $lng->getTrn('common/no'); ?> </td> </tr> <tr> <td>TV</td> <td><?php echo $team->tv / 1000 . 'k'; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('matches/report/treas'); ?> </td> <td><?php echo $team->treasury / 1000 . 'k'; ?> </td> </tr> <tr> <?php if (in_array($team->f_race_id, $racesHasNecromancer)) { ?> <td>Necromancer</td> <td><?php echo $lng->getTrn('common/yes'); ?> </td> <?php } if (!in_array($team->f_race_id, $racesNoApothecary)) { echo "<td>" . $lng->getTrn('common/apothecary') . "</td>\n"; echo "<td>" . ($team->apothecary ? $lng->getTrn('common/yes') : $lng->getTrn('common/no')) . "</td>\n"; } ?> </tr> <tr> <td><?php echo $lng->getTrn('common/reroll'); ?> </td> <td><?php echo $team->rerolls; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('matches/report/ff'); ?> </td> <td><?php echo $team->rg_ff; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('common/ass_coach'); ?> </td> <td><?php echo $team->ass_coaches; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('common/cheerleader'); ?> </td> <td><?php echo $team->cheerleaders; ?> </td> </tr> <tr> <td colspan=2><hr></td> </tr> <tr> <td><?php echo $lng->getTrn('common/played'); ?> </td> <td><?php echo $team->mv_played; ?> </td> </tr> <tr> <td>WIN%</td> <td><?php echo sprintf("%1.1f", $team->rg_win_pct) . '%'; ?> </td> </tr> <tr> <td>ELO</td> <td><?php echo $team->rg_elo ? sprintf("%1.2f", $team->rg_elo) : '<i>N/A</i>'; ?> </td> </tr> <tr> <td>W/L/D</td> <td><?php echo "{$team->mv_won}/{$team->mv_lost}/{$team->mv_draw}"; ?> </td> </tr> <tr> <td>W/L/D <?php echo $lng->getTrn('common/streaks'); ?> </td> <td><?php echo "{$team->rg_swon}/{$team->rg_slost}/{$team->rg_sdraw}"; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('common/wontours'); ?> </td> <td><?php echo $team->wt_cnt; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('profile/team/box_info/ltour'); ?> </td> <td><?php echo Tour::getTourUrl($team->getLatestTour()); ?> </td> </tr> <tr valign="top"> <td><?php echo $lng->getTrn('common/playedtours'); ?> </td> <td><small><?php $tours = $team->getToursPlayedIn(false); if (empty($tours)) { echo $lng->getTrn('common/none'); } else { $first = true; foreach ($tours as $tour) { if ($first) { $first = false; } else { echo ", "; } echo $tour->getUrl(); } } ?> </small></td> </tr> <?php if (Module::isRegistered('Prize')) { ?> <tr valign="top"> <td><?php echo $lng->getTrn('name', 'Prize'); ?> </td> <td><small><?php echo Module::run('Prize', array('getPrizesString', T_OBJ_TEAM, $team->team_id)); ?> </small></td> </tr> <?php } if (Module::isRegistered('FamousTeams')) { ?> <tr> <td><?php echo $lng->getTrn('isfamous', 'FamousTeams'); ?> </td> <td><?php echo Module::run('FamousTeams', array('isInFT', $team->team_id)) ? '<b><font color="green">Yes</font></b>' : 'No'; ?> </td> </tr> <?php } ?> </table> </div> </div> <?php if ($ALLOW_EDIT) { ?> <div class="boxTeamPage"> <div class="boxTitle<?php echo T_HTMLBOX_COACH; ?> "><?php echo $lng->getTrn('profile/team/box_tm/title'); ?> </div> <div class="boxBody"> <?php $base = 'profile/team'; $tmanage = array('hire_player' => $lng->getTrn($base . '/box_tm/hire_player'), 'hire_journeyman' => $lng->getTrn($base . '/box_tm/hire_journeyman'), 'fire_player' => $lng->getTrn($base . '/box_tm/fire_player'), 'unbuy_player' => $lng->getTrn($base . '/box_tm/unbuy_player'), 'rename_player' => $lng->getTrn($base . '/box_tm/rename_player'), 'renumber_player' => $lng->getTrn($base . '/box_tm/renumber_player'), 'rename_team' => $lng->getTrn($base . '/box_tm/rename_team'), 'buy_goods' => $lng->getTrn($base . '/box_tm/buy_goods'), 'drop_goods' => $lng->getTrn($base . '/box_tm/drop_goods'), 'ready_state' => $lng->getTrn($base . '/box_tm/ready_state'), 'retire' => $lng->getTrn($base . '/box_tm/retire'), 'delete' => $lng->getTrn($base . '/box_tm/delete')); # If one of these are selected from the menu, a JavaScript confirm prompt is displayed before submitting. # Note: Don't add "hire_player" here - players may be un-bought if not having played any games. $tmange_confirm = array('hire_journeyman', 'fire_player', 'buy_goods', 'drop_goods'); // Set default choice. if (!isset($_POST['menu_tmanage'])) { reset($tmanage); $_POST['menu_tmanage'] = key($tmanage); } // If action is already chosen, then make it the default selected. if (isset($_POST['type']) && array_key_exists($_POST['type'], $tmanage)) { $_POST['menu_tmanage'] = $_POST['type']; } ?> <form method="POST" name="menu_tmanage_form"> <select name="menu_tmanage" onchange="document.menu_tmanage_form.submit();"> <?php foreach ($tmanage as $opt => $desc) { echo "<option value='{$opt}'" . ($_POST['menu_tmanage'] == $opt ? 'SELECTED' : '') . ">{$desc}</option>"; } ?> </select> <!-- <input type="submit" name="tmanage" value="OK"> --> </form> <br><i><?php echo $lng->getTrn('common/desc'); ?> :</i><br><br> <form name="form_tmanage" method="POST" enctype="multipart/form-data"> <?php $DISABLE = false; switch ($_POST['menu_tmanage']) { /************** * Hire player **************/ case 'hire_player': echo $lng->getTrn('profile/team/box_tm/desc/hire_player'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name='player'> <?php $active_players = array_filter($players, create_function('$p', "return (\$p->is_sold || \$p->is_dead || \$p->is_mng) ? false : true;")); $DISABLE = true; foreach ($DEA[$team->f_rname]['players'] as $pos => $details) { // Show players on the select list if buyable, or if player is a potential journeyman AND team has not reached journeymen limit. if ($team->isPlayerBuyable($details['pos_id']) && $team->treasury >= $details['cost'] || ($details['qty'] == 16 || $details['qty'] == 12) && count($active_players) < $rules['journeymen_limit']) { echo "<option value='{$details['pos_id']}'>" . $details['cost'] / 1000 . "k | " . $lng->GetTrn('position/' . strtolower($lng->FilterPosition($pos))) . "</option>\n"; $DISABLE = false; } } echo "</select>\n"; ?> <br><br> <?php echo $lng->getTrn('common/number'); ?> :<br> <select name="number"> <?php foreach ($T_ALLOWED_PLAYER_NR as $i) { foreach ($players as $p) { if ($p->nr == $i && !$p->is_sold && !$p->is_dead) { continue 2; } } echo "<option value='{$i}'>{$i}</option>\n"; } ?> </select> <br><br> <?php echo $lng->GetTrn('common/journeyman'); ?> ? <input type="checkbox" name="as_journeyman" value="1"> <br><br> <?php echo $lng->getTrn('common/name'); ?> :<br> <input type="text" name="name"> <input type="hidden" name="type" value="hire_player"> <?php break; /************** * Hire journeymen **************/ /************** * Hire journeymen **************/ case 'hire_journeyman': echo $lng->getTrn('profile/team/box_tm/desc/hire_journeyman'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { $price = $DEA[$team->f_rname]['players'][$p->pos]['cost']; if (!$p->is_journeyman || $p->is_sold || $p->is_dead || $team->treasury < $price || !$team->isPlayerBuyable($p->f_pos_id) || $team->isFull()) { continue; } echo "<option value='{$p->player_id}'>{$p->name} | " . $price / 1000 . " k</option>\n"; $DISABLE = false; } ?> </select> <input type="hidden" name="type" value="hire_journeyman"> <?php break; /************** * Fire player **************/ /************** * Fire player **************/ case 'fire_player': echo $lng->getTrn('profile/team/box_tm/desc/fire_player') . ' ' . $rules['player_refund'] * 100 . "%.\n"; ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if ($p->is_dead || $p->is_sold) { continue; } echo "<option value='{$p->player_id}'>" . $p->value / 1000 * $rules['player_refund'] . "k refund | {$p->name}</option>\n"; $DISABLE = false; } ?> </select> <input type="hidden" name="type" value="fire_player"> <?php break; /*************** * Un-buy player **************/ /*************** * Un-buy player **************/ case 'unbuy_player': echo $lng->getTrn('profile/team/box_tm/desc/unbuy_player'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if ($p->is_unbuyable() && !$p->is_sold) { echo "<option value='{$p->player_id}'>{$p->name}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="unbuy_player"> <?php break; /************** * Rename player **************/ /************** * Rename player **************/ case 'rename_player': echo $lng->getTrn('profile/team/box_tm/desc/rename_player'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { unset($color); if ($p->is_dead) { $color = COLOR_HTML_DEAD; } elseif ($p->is_sold) { $color = COLOR_HTML_SOLD; } echo "<option value='{$p->player_id}' " . (isset($color) ? "style='background-color: {$color};'" : '') . ">{$p->name}</option>\n"; $DISABLE = false; } ?> </select> <br><br> <?php echo $lng->getTrn('common/name'); ?> :<br> <input type='text' name='name' maxlength=50 size=20> <input type="hidden" name="type" value="rename_player"> <?php break; /************** * Renumber player **************/ /************** * Renumber player **************/ case 'renumber_player': echo $lng->getTrn('profile/team/box_tm/desc/renumber_player'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { unset($color); if ($p->is_dead) { $color = COLOR_HTML_DEAD; } elseif ($p->is_sold) { $color = COLOR_HTML_SOLD; } echo "<option value='{$p->player_id}' " . (isset($color) ? "style='background-color: {$color};'" : '') . ">{$p->nr} {$p->name}</option>\n"; $DISABLE = false; } ?> </select> <br><br> <?php echo $lng->getTrn('common/number'); ?> :<br> <select name="number"> <?php foreach ($T_ALLOWED_PLAYER_NR as $i) { echo "<option value='{$i}'>{$i}</option>\n"; } ?> </select> <input type="hidden" name="type" value="renumber_player"> <?php break; /************** * Rename team **************/ /************** * Rename team **************/ case 'rename_team': echo $lng->getTrn('profile/team/box_tm/desc/rename_team'); ?> <hr><br> <?php echo $lng->getTrn('common/name'); ?> :<br> <input type='text' name='name' maxlength='50' size='20'> <input type="hidden" name="type" value="rename_team"> <?php break; /************** * Buy team goods **************/ /************** * Buy team goods **************/ case 'buy_goods': echo $lng->getTrn('profile/team/box_tm/desc/buy_goods'); $goods_temp = $team->getGoods(); if ($DEA[$team->f_rname]['other']['rr_cost'] != $goods_temp['rerolls']['cost']) { echo $lng->getTrn('profile/team/box_tm/desc/buy_goods_warn'); } ?> <hr><br> <?php echo $lng->getTrn('profile/team/box_tm/fdescs/thing'); ?> :<br> <select name="thing"> <?php $DISABLE = true; foreach ($team->getGoods() as $name => $details) { if ($name == 'ff_bought' && !$team->mayBuyFF()) { continue; } if (($team->{$name} < $details['max'] || $details['max'] == -1) && $team->treasury >= $details['cost']) { echo "<option value='{$name}'>" . $details['cost'] / 1000 . "k | {$details['item']}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="buy_goods"> <?php break; /************** * Let go (drop) of team goods **************/ /************** * Let go (drop) of team goods **************/ case 'drop_goods': echo $lng->getTrn('profile/team/box_tm/desc/drop_goods'); ?> <hr><br> <?php echo $lng->getTrn('profile/team/box_tm/fdescs/thing'); ?> :<br> <select name="thing"> <?php $DISABLE = true; foreach ($team->getGoods() as $name => $details) { if ($name == 'ff_bought' && !$team->mayBuyFF()) { continue; } if ($team->{$name} > 0) { echo "<option value='{$name}'>{$details['item']}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="drop_goods"> <?php break; /************** * Set ready state **************/ /************** * Set ready state **************/ case 'ready_state': echo $lng->getTrn('profile/team/box_tm/desc/ready_state'); ?> <hr><br> <?php echo $lng->getTrn('profile/team/box_tm/fdescs/teamready'); ?> <input type="checkbox" name="bool" value="1" <?php echo $team->rdy ? 'CHECKED' : ''; ?> > <input type="hidden" name="type" value="ready_state"> <?php break; /*************** * Retire **************/ /*************** * Retire **************/ case 'retire': echo $lng->getTrn('profile/team/box_tm/desc/retire'); ?> <hr><br> <?php echo $lng->getTrn('profile/team/box_tm/fdescs/retire'); ?> <input type="checkbox" name="bool" value="1"> <input type="hidden" name="type" value="retire"> <?php break; /*************** * Delete **************/ /*************** * Delete **************/ case 'delete': echo $lng->getTrn('profile/team/box_tm/desc/delete'); if (!$this->isDeletable()) { $DISABLE = true; } ?> <hr><br> <?php echo $lng->getTrn('profile/team/box_tm/fdescs/suredeleteteam'); ?> <input type="checkbox" name="bool" value="1" <?php echo $DISABLE ? 'DISABLED' : ''; ?> > <input type="hidden" name="type" value="delete"> <?php break; } ?> <br><br> <input type="submit" name="button" value="OK" <?php echo $DISABLE ? 'DISABLED' : ''; ?> <?php if (in_array($_POST['menu_tmanage'], $tmange_confirm)) { echo "onClick=\"if(!confirm('" . $lng->getTrn('common/confirm_box') . "')){return false;}\""; } ?> > </form> </div> </div> <?php if ($coach->isNodeCommish(T_NODE_LEAGUE, $team->f_lid)) { ?> <div class="boxTeamPage"> <div class="boxTitle<?php echo T_HTMLBOX_ADMIN; ?> "><?php echo $lng->getTrn('profile/team/box_admin/title'); ?> </div> <div class="boxBody"> <?php $base = 'profile/team'; $admin_tools = array('unhire_journeyman' => $lng->getTrn($base . '/box_admin/unhire_journeyman'), 'unsell_player' => $lng->getTrn($base . '/box_admin/unsell_player'), 'unbuy_goods' => $lng->getTrn($base . '/box_admin/unbuy_goods'), 'bank' => $lng->getTrn($base . '/box_admin/bank'), 'spp' => $lng->getTrn($base . '/box_admin/spp'), 'dval' => $lng->getTrn($base . '/box_admin/dval'), 'extra_skills' => $lng->getTrn($base . '/box_admin/extra_skills'), 'ach_skills' => $lng->getTrn($base . '/box_admin/ach_skills')); // Set default choice. if (!isset($_POST['menu_admintools'])) { reset($admin_tools); $_POST['menu_admintools'] = key($admin_tools); } // If action is already chosen, then make it the default selected. if (isset($_POST['type']) && array_key_exists($_POST['type'], $admin_tools)) { $_POST['menu_admintools'] = $_POST['type']; } ?> <form method="POST" name="menu_admintools_form"> <select name="menu_admintools" onchange="document.menu_admintools_form.submit();"> <?php foreach ($admin_tools as $opt => $desc) { echo "<option value='{$opt}'" . ($_POST['menu_admintools'] == $opt ? 'SELECTED' : '') . ">{$desc}</option>"; } ?> </select> <!-- <input type="submit" name="admintools" value="OK"> --> </form> <br><i><?php echo $lng->getTrn('common/desc'); ?> :</i><br><br> <form name='form_admintools' method='POST'> <?php $DISABLE = false; switch ($_POST['menu_admintools']) { /*************** * Un-hire journeymen **************/ case 'unhire_journeyman': echo $lng->getTrn('profile/team/box_admin/desc/unhire_journeyman'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if ($p->is_sold || $p->is_dead || $p->is_journeyman || $p->qty != 16) { continue; } echo "<option value='{$p->player_id}'>{$p->name}</option>\n"; $DISABLE = false; } ?> </select> <input type="hidden" name="type" value="unhire_journeyman"> <?php break; /*************** * Un-sell player **************/ /*************** * Un-sell player **************/ case 'unsell_player': echo $lng->getTrn('profile/team/box_admin/desc/unsell_player'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if ($p->is_sold) { echo "<option value='{$p->player_id}'>{$p->name}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="unsell_player"> <?php break; /*************** * Un-buy team goods **************/ /*************** * Un-buy team goods **************/ case 'unbuy_goods': echo $lng->getTrn('profile/team/box_admin/desc/unbuy_goods'); ?> <hr><br> <select name="thing"> <?php $DISABLE = true; foreach ($team->getGoods() as $name => $details) { if ($team->{$name} > 0) { # Only allow to un-buy those things which we already have some of. echo "<option value='{$name}'>{$details['item']}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="unbuy_goods"> <?php break; /*************** * Gold bank **************/ /*************** * Gold bank **************/ case 'bank': echo $lng->getTrn('profile/team/box_admin/desc/bank'); ?> <hr><br> Δ team treasury:<br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type='text' name="amount" maxlength=5 size=5>k <input type="hidden" name="type" value="bank"> <?php break; /*************** * Manage extra SPP **************/ /*************** * Manage extra SPP **************/ case 'spp': echo $lng->getTrn('profile/team/box_admin/desc/spp'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; objsort($players, array('+is_dead', '+name')); foreach ($players as $p) { if (!$p->is_sold) { echo "<option value='{$p->player_id}'" . ($p->is_dead ? ' style="background-color:' . COLOR_HTML_DEAD . ';"' : '') . ">{$p->name}</option>"; $DISABLE = false; } } objsort($players, array('+nr')); ?> </select> <br><br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type='text' name='amount' maxlength="5" size="5"> Δ SPP <input type="hidden" name="type" value="spp"> <?php break; /*************** * Manage extra player value **************/ /*************** * Manage extra player value **************/ case 'dval': echo $lng->getTrn('profile/team/box_admin/desc/dval'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; objsort($players, array('+is_dead', '+name')); foreach ($players as $p) { if (!$p->is_sold) { echo "<option value='{$p->player_id}'" . ($p->is_dead ? ' style="background-color:' . COLOR_HTML_DEAD . ';"' : '') . ">{$p->name} (current extra = " . $p->extra_val / 1000 . "k)</option>"; $DISABLE = false; } } objsort($players, array('+nr')); ?> </select> <br><br> Set extra value to<br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type='text' name='amount' maxlength="10" size="6">k <input type="hidden" name="type" value="dval"> <?php break; /*************** * Manage extra skills **************/ /*************** * Manage extra skills **************/ case 'extra_skills': echo $lng->getTrn('profile/team/box_admin/desc/extra_skills'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if (!$p->is_sold && !$p->is_dead) { echo "<option value='{$p->player_id}'>{$p->name}</option>"; $DISABLE = false; } } ?> </select> <br><br> Skill:<br> <select name="skill"> <?php foreach ($skillarray as $cat => $skills) { echo "<OPTGROUP LABEL='{$cat}'>"; foreach ($skills as $id => $skill) { echo "<option value='{$id}'>{$skill}</option>"; } echo "</OPTGROUP>"; } ?> </select> <br><br> Action (add/remove)<br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type="hidden" name="type" value="extra_skills"> <?php break; /*************** * Remove achived skills **************/ /*************** * Remove achived skills **************/ case 'ach_skills': echo $lng->getTrn('profile/team/box_admin/desc/ach_skills'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if (!$p->is_dead && !$p->is_sold) { echo "<option value='{$p->player_id}'>{$p->name}</option>\n"; $DISABLE = false; } } ?> </select> <br><br> Skill<br> <select name="skill"> <?php foreach ($skillarray as $cat => $skills) { echo "<OPTGROUP LABEL='{$cat}'>"; foreach ($skills as $id => $skill) { echo "<option value='{$id}'>{$skill}</option>"; } echo "</OPTGROUP>"; } echo "<optgroup label='Characteristic increases'>\n"; foreach ($CHR_CONV as $key => $name) { echo "<option value='ach_{$key}'>+ " . ucfirst($name) . "</option>\n"; } echo "</optgroup>\n"; ?> </select> <input type="hidden" name="type" value="ach_skills"> <?php break; } ?> <br><br> <input type="submit" name="button" value="OK" <?php echo $DISABLE ? 'DISABLED' : ''; ?> > </form> </div> </div> <?php } } ?> <br> <div class="row"></div> <br> <?php if (!$settings['hide_ES_extensions']) { ?> <div class="row"> <div class="boxWide"> <div class="boxTitle<?php echo T_HTMLBOX_STATS; ?> "><a href='javascript:void(0);' onClick="slideToggleFast('ES');"><b>[+/-]</b></a> <?php echo $lng->getTrn('common/extrastats'); ?> </div> <div class="boxBody" id="ES" style='display:none;'> <?php HTMLOUT::generateEStable($this); ?> </div> </div> </div> <?php } // If an team action was chosen, jump to actions HTML anchor. if ($JMP_ANC) { ?> <script language="JavaScript" type="text/javascript"> window.location = "#aanc"; </script> <?php } }
public static function main($argv) { global $lng; title($lng->getTrn('name', 'Gallery')); list($sel_lid, $HTML_LeagueSelector) = HTMLOUT::simpleLeagueSelector(); if (isset($_POST['type'])) { echo "<center><a href='handler.php?type=gallery'>" . $lng->getTrn('common/back') . "</a></center>\n"; switch ($_POST['type']) { case 'team': $t = new Team((int) $_POST['tid']); echo "<b>" . $lng->getTrn('playersof', 'Gallery') . " {$t->name}</b><br><hr><br>\n"; foreach ($t->getPlayers() as $p) { $img = new ImageSubSys(IMGTYPE_PLAYER, $p->player_id); $pic = $img->getPath(); echo "<div style='float:left; padding:10px;'>{$p->name} (#{$p->nr})<br><a href='" . urlcompile(T_URL_PROFILE, T_OBJ_PLAYER, $p->player_id, false, false) . "'><img HEIGHT=150 src='{$pic}' alt='pic'></a></div>"; } break; case 'stad': echo "<b>" . $lng->getTrn('stads', 'Gallery') . "</b><br><hr><br>\n"; $teams = get_rows('teams', array('team_id', 'name'), array("f_lid = {$sel_lid}")); objsort($teams, array('+name')); foreach ($teams as $t) { $img = new ImageSubSys(IMGTYPE_TEAMSTADIUM, $t->team_id); $pic = $img->getPath(); echo "<div style='float:left; padding:10px;'>{$t->name}<br><a href='{$pic}'><img HEIGHT=150 src='{$pic}' alt='pic'></a></div>"; } break; case 'coach': echo "<b>" . $lng->getTrn('coaches', 'Gallery') . "</b><br><hr><br>\n"; $q = "SELECT coach_id, name FROM coaches,memberships WHERE cid = coach_id AND lid = {$sel_lid} GROUP BY cid, lid ORDER BY name ASC"; $result = mysql_query($q); while ($c = mysql_fetch_object($result)) { $img = new ImageSubSys(IMGTYPE_COACH, $c->coach_id); $pic = $img->getPath(); echo "<div style='float:left; padding:10px;'>{$c->name}<br><a href='{$pic}'><img HEIGHT=150 src='{$pic}' alt='pic'></a></div>"; } break; } return; } echo $HTML_LeagueSelector; echo "<br><br>\n"; echo $lng->getTrn('note', 'Gallery'); ?> <ul> <li> <?php $teams = get_rows('teams', array('team_id', 'name'), array("f_lid = {$sel_lid}")); objsort($teams, array('+name')); echo $lng->getTrn('players', 'Gallery') . "\n <form method='POST' style='display:inline; margin:0px;'><select name='tid' onChange='this.form.submit();'>\n <option value='0'>— " . $lng->getTrn('none', 'Gallery') . " —</option>" . implode("\n", array_map(create_function('$o', 'return "<option value=\'$o->team_id\'>$o->name</option>";'), $teams)) . "</select><input type='hidden' name='type' value='team'></form>\n "; ?> </li> <li><?php echo inlineform(array('type' => 'stad'), 'stadForm', $lng->getTrn('stads', 'Gallery')); ?> </li> <li><?php echo inlineform(array('type' => 'coach'), 'coachesForm', $lng->getTrn('coaches', 'Gallery')); ?> </li> </ul> <?php }
public static function sort_table($title, $lnk, array $objs, array $fields, array $std_sort, $sort = array(), $extra = array()) { /* extra fields: tableWidth => CSS style width value dashed => array( 'condField' => field name, // When an object has this field's (condField) = fieldVal, then a "-" is put in the place of all values. 'fieldVal' => field value, 'noDashFields' => array('field 1', 'field 2') // ...unless the field name is one of those specified in the array 'noDashFields'. ); remove => array( 'condField' => field name, // When an object has this field's (condField) = fieldVal, then the entry/row is not printed in the html table. 'fieldVal' => field value, ); GETsuffix => suffix to paste into "dir" and "sort" GET strings. color => true/false. Boolean telling wheter or not we should look into each object for the field "HTMLfcolor" and "HTMLbcolor", and use these color codes to color the obj's row. Note: the object must contain the two previously stated fields, or else black-on-white is used as default. doNr => true/false. Boolean telling wheter or not to print the "Nr." column. limit => int. Stop printing rows when this row number is reached. anchor => string. Will create table sorting links, that include this identifier as an anchor. noHelp => true/false. Will enable/disable help link [?]. noSRdisp => true/false. Will force not to show the table sort rule used/parsed. page => current page being viewed pages => total number of pages */ global $settings, $lng; if (array_key_exists('remove', $extra)) { $objs = array_filter($objs, create_function('$obj', 'return ($obj->' . $extra['remove']['condField'] . ' != ' . $extra['remove']['fieldVal'] . ');')); } $MASTER_SORT = array_merge($sort, $std_sort); if (!empty($MASTER_SORT)) { objsort($objs, $MASTER_SORT); } $no_print_fields = array(); $DONR = !array_key_exists('doNr', $extra) || $extra['doNr'] ? true : false; $LIMIT = array_key_exists('limit', $extra) ? $extra['limit'] : -1; $ANCHOR = array_key_exists('anchor', $extra) ? $extra['anchor'] : false; $NOSRDISP = array_key_exists('noSRdisp', $extra) ? $extra['noSRdisp'] : false; $GETSUFX = array_key_exists('GETsuffix', $extra) ? $extra['GETsuffix'] : ''; $PAGES = array_key_exists('pages', $extra) ? $extra['pages'] : false; $PAGE = array_key_exists('page', $extra) ? $extra['page'] : 1; $PAGELENGTH = array_key_exists('pagelength', $extra) ? $extra['pagelength'] : 0; if ($DONR) { $fields = array_merge(array('nr' => array('desc' => '#')), $fields); array_push($no_print_fields, 'nr'); } $CP = count($fields); ?> <table class="common" <?php echo array_key_exists('tableWidth', $extra) ? "style='width: {$extra['tableWidth']};'" : ''; ?> > <tr class="commonhead"> <td colspan="<?php echo $CP; ?> "><b> <?php echo $title; ?> <?php if (!array_key_exists('noHelp', $extra) || !$extra['noHelp']) { ?> <a TARGET="_blank" href="html/table_desc.html">[?]</a><?php } ?> </b></td> </tr> <tr> <?php foreach ($fields as $f => $attr) { echo "<td><i>{$attr['desc']}</i></td>"; } ?> </tr> <tr> <?php foreach ($fields as $f => $attr) { if (in_array($f, $no_print_fields) || array_key_exists('nosort', $attr) && $attr['nosort']) { echo "<td></td>"; continue; } $sort = 'sort' . $GETSUFX; $dir = 'dir' . $GETSUFX; $anc = ''; if ($ANCHOR) { $anc = "#{$ANCHOR}"; } echo "<td><b><a href='{$lnk}&page=1&{$sort}={$f}&{$dir}=a{$anc}' title='Sort ascending'>+</a>/<a href='{$lnk}&page=1&{$sort}={$f}&{$dir}=d{$anc}' title='Sort descending'>-</a></b></td>"; } ?> </tr> <tr><td colspan="<?php echo $CP; ?> "><hr></td></tr> <?php $i = 1 + ($PAGE && $PAGELENGTH ? ($PAGE - 1) * $PAGELENGTH : 0); foreach ($objs as $o) { $DASH = array_key_exists('dashed', $extra) && $o->{$extra['dashed']['condField']} == $extra['dashed']['fieldVal'] ? true : false; if (array_key_exists('color', $extra)) { $td = "<td style='background-color: " . (isset($o->HTMLbcolor) ? $o->HTMLbcolor : 'white') . "; color: " . (isset($o->HTMLfcolor) ? $o->HTMLfcolor : 'black') . ";'>"; } else { $td = '<td>'; } echo "<tr>"; if ($DONR) { echo $td . $i . "</td>"; } foreach ($fields as $f => $a) { // Field => attributes if (!in_array($f, $no_print_fields)) { if ($DASH && !in_array($f, $extra['dashed']['noDashFields'])) { echo $td . "-</td>"; continue; } $cpy = $o->{$f}; // Don't change the objects themselves! Make copies! if (array_key_exists('kilo', $a) && $a['kilo']) { $cpy /= 1000; } $cpy = (string) $cpy; if (is_numeric($cpy) && !ctype_digit($cpy[0] == '-' ? substr($cpy, 1) : $cpy)) { $cpy = sprintf("%1.2f", $cpy); } if (array_key_exists('suffix', $a) && $a['suffix']) { $cpy .= $a['suffix']; } if (array_key_exists('color', $a) && $a['color']) { $cpy = "<font color='{$a['color']}'>" . $cpy . "</font>"; } if (array_key_exists('href', $a) && $a['href']) { $href = isset($o->href) ? $o->href : $a['href']; $cpy = "<a href='{$href['link']}" . (isset($href['field']) ? "&{$href['field']}=" . $o->{$href['value']} : '') . "'>" . $cpy . "</a>"; } if (isset($o->{"{$f}_color"})) { echo "<td style='background-color: " . $o->{"{$f}_color"} . "; color: black;'>" . $cpy . "</td>"; } else { echo $td . $cpy . "</td>"; } } } echo "</tr>\n"; if ($i++ == $LIMIT) { break; } } if (!$NOSRDISP) { ?> <tr> <td colspan="<?php echo $CP; ?> "> <hr> </td> </tr> <tr> <td align="right" colspan="<?php echo $CP; ?> "> <?php if ($PAGES) { ?> <div style='float:left;'><?php echo $lng->getTrn('common/page') . " "; $primary_sort = isset($_GET["sort{$GETSUFX}"]) ? "&sort{$GETSUFX}=" . $_GET["sort{$GETSUFX}"] . "&dir{$GETSUFX}=" . $_GET["dir{$GETSUFX}"] : ''; $pageslist = array_strpack('<a href=\\"' . $lnk . '&page=%s' . $primary_sort . '\\">%s</a>', range(1, $PAGES)); $pageslist[$PAGE - 1] = "<b>{$PAGE}</b>"; echo implode(', ', $pageslist); ?> </div> <?php } ?> <div style='float:right;'><i><?php echo $lng->getTrn('common/sortedagainst'); ?> : <?php echo implode(', ', rule_dict($MASTER_SORT)); ?> </i></div> </td> </tr> <?php } echo "</table>\n"; }
public static function getMainBoardMessages($n, $lid = false, $get_tnews = true, $get_summaries = true) { global $settings; $board = array(); // First we add all commissioner messages to the board structure. foreach (Message::getMessages($n, $lid) as $m) { $o = (object) array(); // Specific fields: $o->msg_id = $m->msg_id; $o->author_id = $m->f_coach_id; // General fields: $o->cssidx = T_HTMLBOX_ADMIN; // CSS box index $o->type = T_TEXT_MSG; $o->author = get_alt_col('coaches', 'coach_id', $m->f_coach_id, 'name'); $o->title = $m->title; $o->message = $m->message; $o->date = $m->date_posted; $o->pinned = $m->pinned; array_push($board, $o); } // Now we add all game summaries. if ($get_summaries) { foreach (MatchSummary::getSummaries($n, $lid) as $r) { $o = (object) array(); $m = new Match($r->match_id); // Specific fields: $o->date_mod = $m->date_modified; $o->match_id = $m->match_id; // General fields: $o->cssidx = T_HTMLBOX_MATCH; // CSS box index $o->type = T_TEXT_MATCH_SUMMARY; $o->author = get_alt_col('coaches', 'coach_id', $m->submitter_id, 'name'); $o->title = "Match: {$m->team1_name} {$m->team1_score}—{$m->team2_score} {$m->team2_name}"; $o->message = $m->getText(); $o->date = $m->date_played; $o->pinned = 0; // Not allowed for other types than board messages array_push($board, $o); } } // And finally team news. if ($get_tnews) { foreach (TeamNews::getNews(false, $n, $lid) as $t) { $o = (object) array(); // Specific fields: # none // General fields: $o->cssidx = T_HTMLBOX_INFO; // CSS box index $o->type = T_TEXT_TNEWS; $o->author = get_alt_col('teams', 'team_id', $t->f_id, 'name'); $o->title = "Team news: {$o->author}"; $o->message = $t->txt; $o->date = $t->date; $o->pinned = 0; // Not allowed for other types than board messages array_push($board, $o); } } // Last touch on the board. if (!empty($board)) { objsort($board, array('-pinned', '-date')); if ($n) { $board = array_slice($board, 0, $n); } } return $board; }
/** * Generates the newsfeed and writes it to disc. * */ public function generateNewsRssFeed() { $dom = new DOMDocument(); $dom->formatOutput = true; $el_root = $dom->appendChild($dom->createElement('rss')); $el_root->setAttribute('version', '2.0'); $el_channel = $el_root->appendChild($dom->createElement('channel')); $el_channel->appendChild($dom->createElement('title', $this->title)); $el_channel->appendChild($dom->createElement('link', $this->link)); $el_channel->appendChild($dom->createElement('description', $this->desc)); if ($this->lang != '') { $el_channel->appendChild($dom->createElement('language', $this->lang)); } $el_channel->appendChild($dom->createElement('docs', $this->docs)); $el_channel->appendChild($dom->createElement('lastBuildDate', date(DATE_RSS))); $el_channel->appendChild($dom->createElement('generator', 'OBBLM ' . OBBLM_VERSION)); $entries = array(); foreach ($this->type as $t) { $obj = (object) null; switch ($t) { case T_TEXT_MSG: foreach (Message::getMessages(RSS_SIZE) as $item) { $entries[] = (object) array('title' => "Announcement by " . get_alt_col('coaches', 'coach_id', $item->f_coach_id, 'name') . ": {$item->title}", 'desc' => $item->message, 'date' => $item->date); } break; case 'HOF': if (Module::isRegistered('HOF')) { foreach (Module::run('HOF', array('getHOF', false, RSS_SIZE)) as $item) { $item = $item['hof']; $entries[] = (object) array('title' => "HOF entry for " . get_alt_col('players', 'player_id', $item->pid, 'name') . ": {$item->title}", 'desc' => $item->about, 'date' => $item->date); } } break; case 'Wanted': if (Module::isRegistered('Wanted')) { foreach (Module::run('Wanted', array('getWanted', false, RSS_SIZE)) as $item) { $item = $item['wanted']; $entries[] = (object) array('title' => "Wanted entry for " . get_alt_col('players', 'player_id', $item->pid, 'name') . ": {$item->bounty}", 'desc' => $item->why, 'date' => $item->date); } } break; case T_TEXT_MATCH_SUMMARY: foreach (MatchSummary::getSummaries(RSS_SIZE) as $item) { $m = new Match($item->match_id); $entries[] = (object) array('title' => "Match: {$m->team1_name} ({$m->team1_score}) vs. {$m->team2_name} ({$m->team2_score})", 'desc' => $m->getText(), 'date' => $m->date_played); } break; case T_TEXT_TNEWS: foreach (TeamNews::getNews(false, RSS_SIZE) as $item) { $entries[] = (object) array('title' => "Team news by " . get_alt_col('teams', 'team_id', $item->f_id, 'name'), 'desc' => $item->txt, 'date' => $item->date); } break; } } objsort($entries, array('-date')); foreach (array_slice($entries, 0, RSS_SIZE) as $item) { $el_item = $dom->createElement('item'); $el_item->appendChild($dom->createElement('title', htmlspecialchars($item->title, ENT_NOQUOTES, "UTF-8"))); $el_item->appendChild($dom->createElement('description', htmlspecialchars($item->desc, ENT_NOQUOTES, "UTF-8"))); $el_item->appendChild($dom->createElement('link', $this->link)); # $el_item->appendChild($dom->createElement('pubDate', $item->date)); $el_item->appendChild($dom->createElement('pubDate', date('r', strtotime($item->date)))); $el_item->appendChild($dom->createElement('guid', $this->link . 'index.php?' . date('U', strtotime($item->date)))); # RSS 2.0 dirty workaround. $el_channel->appendChild($el_item); } // Write the file $handle = fopen("rss.xml", "w"); fwrite($handle, $dom->saveXML()); fclose($handle); return $dom->saveXML(); }
private function _actionBoxes($ALLOW_EDIT, $players) { /****************************** * Team management * --------------- * * Here we are able to view team stats and manage the team, depending on visitors privileges. * ******************************/ global $lng, $rules, $settings, $skillarray, $coach, $DEA, $CHR_CONV; global $leagues, $divisions; global $racesHasNecromancer, $racesNoApothecary; global $T_ALLOWED_PLAYER_NR; $team = $this; // Copy. Used instead of $this for readability. $JMP_ANC = isset($_POST['menu_tmanage']) || isset($_POST['menu_admintools']); # Jump condition MUST be set here due to _POST variables being changed later. ?> <a name="aanc"></a> <div class="boxTeamPage"> <div class="boxTitle<?php echo T_HTMLBOX_INFO; ?> "><?php echo $lng->getTrn('profile/team/box_info/title'); ?> </div> <div class="boxBody"> <table width="100%"> <tr> <td><?php echo $lng->getTrn('common/coach'); ?> </td> <td><a href="<?php echo urlcompile(T_URL_PROFILE, T_OBJ_COACH, $team->owned_by_coach_id, false, false); ?> "><?php echo $team->f_cname; ?> </a></td> </tr> <tr> <td><?php echo $lng->getTrn('common/race'); ?> </td> <td><a href="<?php echo urlcompile(T_URL_PROFILE, T_OBJ_RACE, $team->f_race_id, false, false); ?> "><?php echo $lng->getTrn('race/' . strtolower(str_replace(' ', '', $team->f_rname))); ?> </a></td> </tr> <tr> <td><?php echo $lng->getTrn('common/league'); ?> </td> <td><?php if (isset($leagues[$team->f_lid])) { echo "<a href=\""; echo urlcompile(T_URL_STANDINGS, T_OBJ_TEAM, false, T_NODE_LEAGUE, $team->f_lid); echo "\">" . $leagues[$team->f_lid]['lname'] . "</a>"; } else { echo '<i>' . $lng->getTrn('common/none') . '</i>'; } ?> </td> </tr> <?php if ($team->f_did != self::T_NO_DIVISION_TIE) { ?> <tr> <td><?php echo $lng->getTrn('common/division'); ?> </td> <td><?php if (isset($divisions[$team->f_did])) { echo "<a href=\""; echo urlcompile(T_URL_STANDINGS, T_OBJ_TEAM, false, T_NODE_DIVISION, $team->f_did); echo "\">" . $divisions[$team->f_did]['dname'] . "</a>"; } else { echo '<i>' . $lng->getTrn('common/none') . '</i>'; } ?> </td> </tr> <?php } ?> <tr> <td><?php echo $lng->getTrn('common/ready'); ?> </td> <td><?php echo $team->rdy ? $lng->getTrn('common/yes') : $lng->getTrn('common/no'); ?> </td> </tr> <tr> <td>TV</td> <td><?php echo $team->tv / 1000 . 'k'; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('matches/report/treas'); ?> </td> <td><?php echo $team->treasury / 1000 . 'k'; ?> </td> </tr> <tr> <?php if (in_array($team->f_race_id, $racesHasNecromancer)) { ?> <td>Necromancer</td> <td><?php echo $lng->getTrn('common/yes'); ?> </td> <?php } if (!in_array($team->f_race_id, $racesNoApothecary)) { echo "<td>" . $lng->getTrn('common/apothecary') . "</td>\n"; echo "<td>" . ($team->apothecary ? $lng->getTrn('common/yes') : $lng->getTrn('common/no')) . "</td>\n"; } ?> </tr> <tr> <td><?php echo $lng->getTrn('common/reroll'); ?> </td> <td><?php echo $team->rerolls; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('matches/report/ff'); ?> </td> <td><?php echo $team->rg_ff; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('common/ass_coach'); ?> </td> <td><?php echo $team->ass_coaches; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('common/cheerleader'); ?> </td> <td><?php echo $team->cheerleaders; ?> </td> </tr> <tr> <td colspan=2><hr></td> </tr> <tr> <td><?php echo $lng->getTrn('common/played'); ?> </td> <td><?php echo $team->mv_played; ?> </td> </tr> <tr> <td>WIN%</td> <td><?php echo sprintf("%1.1f", $team->rg_win_pct) . '%'; ?> </td> </tr> <tr> <td>ELO</td> <td><?php echo $team->rg_elo ? sprintf("%1.2f", $team->rg_elo) : '<i>N/A</i>'; ?> </td> </tr> <tr> <td>W/L/D</td> <td><?php echo "{$team->mv_won}/{$team->mv_lost}/{$team->mv_draw}"; ?> </td> </tr> <tr> <td>W/L/D <?php echo $lng->getTrn('common/streaks'); ?> </td> <td><?php echo "{$team->rg_swon}/{$team->rg_slost}/{$team->rg_sdraw}"; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('common/wontours'); ?> </td> <td><?php echo $team->wt_cnt; ?> </td> </tr> <tr> <td><?php echo $lng->getTrn('profile/team/box_info/ltour'); ?> </td> <td><?php echo Tour::getTourUrl($team->getLatestTour()); ?> </td> </tr> <tr valign="top"> <td><?php echo $lng->getTrn('common/playedtours'); ?> </td> <td><small><?php $tours = $team->getToursPlayedIn(false); if (empty($tours)) { echo $lng->getTrn('common/none'); } else { $first = true; foreach ($tours as $tour) { if ($first) { $first = false; } else { echo ", "; } echo $tour->getUrl(); } } ?> </small></td> </tr> <?php if (Module::isRegistered('Prize')) { ?> <tr valign="top"> <td><?php echo $lng->getTrn('name', 'Prize'); ?> </td> <td><small><?php echo Module::run('Prize', array('getPrizesString', T_OBJ_TEAM, $team->team_id)); ?> </small></td> </tr> <?php } if (Module::isRegistered('FamousTeams')) { ?> <tr> <td><?php echo $lng->getTrn('isfamous', 'FamousTeams'); ?> </td> <td><?php echo Module::run('FamousTeams', array('isInFT', $team->team_id)) ? '<b><font color="green">Yes</font></b>' : 'No'; ?> </td> </tr> <?php } ?> </table> </div> </div> <?php if ($ALLOW_EDIT) { $this->_teamManagementBox($players, $team); if ($coach->isNodeCommish(T_NODE_LEAGUE, $team->f_lid)) { ?> <div class="boxTeamPage"> <div class="boxTitle<?php echo T_HTMLBOX_ADMIN; ?> "><?php echo $lng->getTrn('profile/team/box_admin/title'); ?> </div> <div class="boxBody"> <?php $base = 'profile/team'; $admin_tools = array('unhire_journeyman' => $lng->getTrn($base . '/box_admin/unhire_journeyman'), 'unsell_player' => $lng->getTrn($base . '/box_admin/unsell_player'), 'unbuy_goods' => $lng->getTrn($base . '/box_admin/unbuy_goods'), 'bank' => $lng->getTrn($base . '/box_admin/bank'), 'spp' => $lng->getTrn($base . '/box_admin/spp'), 'dval' => $lng->getTrn($base . '/box_admin/dval'), 'extra_skills' => $lng->getTrn($base . '/box_admin/extra_skills'), 'ach_skills' => $lng->getTrn($base . '/box_admin/ach_skills'), 'ff' => $lng->getTrn($base . '/box_admin/ff')); // Set default choice. if (!isset($_POST['menu_admintools'])) { reset($admin_tools); $_POST['menu_admintools'] = key($admin_tools); } // If action is already chosen, then make it the default selected. if (isset($_POST['type']) && array_key_exists($_POST['type'], $admin_tools)) { $_POST['menu_admintools'] = $_POST['type']; } ?> <form method="POST" name="menu_admintools_form"> <select name="menu_admintools" onchange="document.menu_admintools_form.submit();"> <?php foreach ($admin_tools as $opt => $desc) { echo "<option value='{$opt}'" . ($_POST['menu_admintools'] == $opt ? 'SELECTED' : '') . ">{$desc}</option>"; } ?> </select> <!-- <input type="submit" name="admintools" value="OK"> --> </form> <br><i><?php echo $lng->getTrn('common/desc'); ?> :</i><br><br> <form name='form_admintools' method='POST'> <?php $DISABLE = false; switch ($_POST['menu_admintools']) { /*************** * Un-hire journeymen **************/ case 'unhire_journeyman': echo $lng->getTrn('profile/team/box_admin/desc/unhire_journeyman'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if ($p->is_sold || $p->is_dead || $p->is_journeyman || $p->qty != 16) { continue; } echo "<option value='{$p->player_id}'>{$p->nr} {$p->name}</option>\n"; $DISABLE = false; } ?> </select> <input type="hidden" name="type" value="unhire_journeyman"> <?php break; /*************** * Un-sell player **************/ /*************** * Un-sell player **************/ case 'unsell_player': echo $lng->getTrn('profile/team/box_admin/desc/unsell_player'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if ($p->is_sold) { echo "<option value='{$p->player_id}'>{$p->nr} {$p->name}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="unsell_player"> <?php break; /*************** * Un-buy team goods **************/ /*************** * Un-buy team goods **************/ case 'unbuy_goods': echo $lng->getTrn('profile/team/box_admin/desc/unbuy_goods'); ?> <hr><br> <select name="thing"> <?php $DISABLE = true; foreach ($team->getGoods() as $name => $details) { if ($team->{$name} > 0) { # Only allow to un-buy those things which we already have some of. echo "<option value='{$name}'>{$details['item']}</option>\n"; $DISABLE = false; } } ?> </select> <input type="hidden" name="type" value="unbuy_goods"> <?php break; /*************** * Gold bank **************/ /*************** * Gold bank **************/ case 'bank': echo $lng->getTrn('profile/team/box_admin/desc/bank'); ?> <hr><br> Δ team treasury:<br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type='text' name="amount" maxlength=5 size=5>k <input type="hidden" name="type" value="bank"> <?php break; /*************** * Manage Fan Factor ***************/ /*************** * Manage Fan Factor ***************/ case 'ff': echo $lng->getTrn('profile/team/box_admin/desc/ff'); ?> <hr><br> Bought ff + Match ff = Total<br> <input type='text' name="amount" value="<?php echo $team->ff_bought . '" maxlength=2 size=1 style="text-align: right">+' . ($team->rg_ff - $team->ff_bought) . '=' . $team->rg_ff; ?> <input type="hidden" name="type" value="ff"> <?php break; /*************** * Manage extra SPP **************/ /*************** * Manage extra SPP **************/ case 'spp': echo $lng->getTrn('profile/team/box_admin/desc/spp'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; objsort($players, array('+is_dead', '+name')); foreach ($players as $p) { if (!$p->is_sold) { echo "<option value='{$p->player_id}'" . ($p->is_dead ? ' style="background-color:' . COLOR_HTML_DEAD . ';"' : '') . ">{$p->nr} {$p->name}</option>"; $DISABLE = false; } } objsort($players, array('+nr')); ?> </select> <br><br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type='text' name='amount' maxlength="5" size="5"> Δ SPP <input type="hidden" name="type" value="spp"> <?php break; /*************** * Manage extra player value **************/ /*************** * Manage extra player value **************/ case 'dval': echo $lng->getTrn('profile/team/box_admin/desc/dval'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; objsort($players, array('+is_dead', '+name')); foreach ($players as $p) { if (!$p->is_sold) { echo "<option value='{$p->player_id}'" . ($p->is_dead ? ' style="background-color:' . COLOR_HTML_DEAD . ';"' : '') . ">{$p->nr} {$p->name} (current extra = " . $p->extra_val / 1000 . "k)</option>"; $DISABLE = false; } } objsort($players, array('+nr')); ?> </select> <br><br> Set extra value to<br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type='text' name='amount' maxlength="10" size="6">k <input type="hidden" name="type" value="dval"> <?php break; /*************** * Manage extra skills **************/ /*************** * Manage extra skills **************/ case 'extra_skills': echo $lng->getTrn('profile/team/box_admin/desc/extra_skills'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if (!$p->is_sold && !$p->is_dead) { echo "<option value='{$p->player_id}'>{$p->nr} {$p->name}</option>"; $DISABLE = false; } } ?> </select> <br><br> Skill:<br> <select name="skill"> <?php foreach ($skillarray as $cat => $skills) { echo "<OPTGROUP LABEL='{$cat}'>"; foreach ($skills as $id => $skill) { echo "<option value='{$id}'>{$skill}</option>"; } echo "</OPTGROUP>"; } ?> </select> <br><br> Action (add/remove)<br> <input type="radio" CHECKED name="sign" value="+">+ <input type="radio" name="sign" value="-">- <input type="hidden" name="type" value="extra_skills"> <?php break; /*************** * Remove achived skills **************/ /*************** * Remove achived skills **************/ case 'ach_skills': echo $lng->getTrn('profile/team/box_admin/desc/ach_skills'); ?> <hr><br> <?php echo $lng->getTrn('common/player'); ?> :<br> <select name="player"> <?php $DISABLE = true; foreach ($players as $p) { if (!$p->is_dead && !$p->is_sold) { echo "<option value='{$p->player_id}'>{$p->nr} {$p->name}</option>\n"; $DISABLE = false; } } ?> </select> <br><br> Skill<br> <select name="skill"> <?php foreach ($skillarray as $cat => $skills) { echo "<OPTGROUP LABEL='{$cat}'>"; foreach ($skills as $id => $skill) { echo "<option value='{$id}'>{$skill}</option>"; } echo "</OPTGROUP>"; } echo "<optgroup label='Characteristic increases'>\n"; foreach ($CHR_CONV as $key => $name) { echo "<option value='ach_{$key}'>+ " . ucfirst($name) . "</option>\n"; } echo "</optgroup>\n"; ?> </select> <input type="hidden" name="type" value="ach_skills"> <?php break; } ?> <br><br> <input type="submit" name="button" value="OK" <?php echo $DISABLE ? 'DISABLED' : ''; ?> > </form> </div> </div> <?php } } ?> <br> <div class="row"></div> <br> <?php if (!$settings['hide_ES_extensions']) { ?> <div class="row"> <div class="boxWide"> <div class="boxTitle<?php echo T_HTMLBOX_STATS; ?> "><a href='javascript:void(0);' onClick="slideToggleFast('ES');"><b>[+/-]</b></a> <?php echo $lng->getTrn('common/extrastats'); ?> </div> <div class="boxBody" id="ES" style='display:none;'> <?php HTMLOUT::generateEStable($this); ?> </div> </div> </div> <?php } // If an team action was chosen, jump to actions HTML anchor. if ($JMP_ANC) { ?> <script language="JavaScript" type="text/javascript"> window.location = "#aanc"; </script> <?php } }
private static function getMemMatches($node = false, $node_id = false) { /* Creates an array of matches for those matches which: - Most TDs (sum of both teams) - most cp - most int - Most killed - Most CAS - Largest score-wise victory - Largest match income - Largest gate - Most fans - Largest TV difference in which underdog won */ $m = array('td' => array(), 'cp' => array(), 'intcpt' => array(), 'ki' => array(), 'bh+ki+si' => array(), 'svic' => array(), 'inc' => array(), 'gate' => array(), 'mfans' => array(), 'tvdiff' => array()); /* Queries for finding the matches holding records. */ // For all-time. /* $ach = "SELECT f_match_id AS 'match_id', SUM(REPLACE_BY_ACH) as 'sumA' FROM match_data WHERE f_match_id > 0 GROUP BY f_match_id HAVING sumA > 0 AND sumA = ( SELECT MAX(sumB) FROM (SELECT SUM(REPLACE_BY_ACH) AS 'sumB' FROM match_data WHERE f_match_id > 0 GROUP BY f_match_id) AS tmpTable )"; $str1 = 'ABS(CONVERT(team1_score,SIGNED) - CONVERT(team2_score,SIGNED))'; $str2 = '(SELECT MAX(IF(income1>income2, income1, income2)) FROM matches)'; $svic = "SELECT match_id, $str1 FROM matches WHERE $str1 != 0 AND $str1 = (SELECT MAX($str1) AS 'mdiff' FROM matches HAVING mdiff IS NOT NULL)"; $inc = "SELECT match_id, income1, income2 FROM matches WHERE (income1 != 0 OR income2 != 0) AND IF(income1>income2, income1 = $str2, income2 = $str2)"; $gate = "SELECT match_id, gate FROM matches WHERE gate = (SELECT MAX(gate) FROM matches)"; $mfans = "SELECT match_id, fans FROM matches WHERE fans = (SELECT MAX(fans) FROM matches)"; $str3 = '((tv1 > tv2 AND team1_score < team2_score) OR (tv1 < tv2 AND team1_score > team2_score))'; $str4 = 'ABS(CONVERT(tv1,SIGNED) - CONVERT(tv2,SIGNED))'; $tvdiff = "SELECT match_id, $str4 AS tvdiff FROM matches WHERE $str3 AND $str4 = (SELECT MAX($str4) FROM matches WHERE $str3)"; */ // Node filter $ref = array(STATS_TOUR => "f_tour_id", STATS_DIVISION => "f_did", STATS_LEAGUE => "f_lid"); $tables = $node ? ',tours,divisions' : ''; # For matches references. $tables_wKey = $node ? "{$tables} WHERE" : ''; $where1 = "matches.match_id > 0 AND "; $where1 .= $node ? 'matches.f_tour_id = tours.tour_id AND tours.f_did = divisions.did AND ' . $ref[$node] . " = {$node_id} AND " : ''; # For matches table. $where2 = $node ? $ref[$node] . " = {$node_id} AND " : ''; # For match_data table. $where1_noAnd = $node ? substr($where1, 0, -4) : ''; $where2_noAnd = $node ? substr($where2, 0, -4) : ''; // Queries $ach = "SELECT f_match_id AS 'match_id', SUM(REPLACE_BY_ACH) as 'sumA' FROM match_data WHERE {$where2} f_match_id > 0 GROUP BY f_match_id HAVING sumA > 0 AND sumA = (\n SELECT MAX(sumB) FROM (SELECT SUM(REPLACE_BY_ACH) AS 'sumB' FROM match_data WHERE {$where2} f_match_id > 0 GROUP BY f_match_id) AS tmpTable\n )"; $str1 = 'ABS(CONVERT(team1_score,SIGNED) - CONVERT(team2_score,SIGNED))'; $str2 = "(SELECT MAX(IF(income1>income2, income1, income2)) FROM matches {$tables_wKey} {$where1_noAnd})"; $svic = "SELECT match_id, {$str1} FROM matches {$tables} WHERE {$where1} {$str1} != 0 AND {$str1} = (SELECT MAX({$str1}) AS 'mdiff' FROM matches {$tables_wKey} {$where1_noAnd} HAVING mdiff IS NOT NULL)"; $inc = "SELECT match_id, income1, income2 FROM matches {$tables} WHERE {$where1} (income1 != 0 OR income2 != 0) AND IF(income1>income2, income1 = {$str2}, income2 = {$str2})"; $gate = "SELECT match_id, gate FROM matches {$tables} WHERE {$where1} gate = (SELECT MAX(gate) FROM matches {$tables_wKey} {$where1_noAnd})"; $mfans = "SELECT match_id, fans FROM matches {$tables} WHERE {$where1} fans = (SELECT MAX(fans) FROM matches {$tables_wKey} {$where1_noAnd})"; $str3 = '((tv1 > tv2 AND team1_score < team2_score) OR (tv1 < tv2 AND team1_score > team2_score))'; $str4 = 'ABS(CONVERT(tv1,SIGNED) - CONVERT(tv2,SIGNED))'; $tvdiff = "SELECT match_id, {$str4} AS tvdiff FROM matches {$tables} WHERE {$where1} {$str3} AND {$str4} = (SELECT MAX({$str4}) FROM matches {$tables} WHERE {$where1} {$str3})"; /* Create an array to loop through containing the queries to throw at mysql. */ $qryarr = array(); foreach (array_keys(array_slice($m, 0, 5)) as $k) { $qryarr[$k] = preg_replace('/REPLACE_BY_ACH/', $k, $ach); } $qryarr['svic'] = $svic; $qryarr['inc'] = $inc; $qryarr['gate'] = $gate; $qryarr['mfans'] = $mfans; $qryarr['tvdiff'] = $tvdiff; /* Store match objects for record holding matches. */ foreach ($qryarr as $k => $query) { $mObjs = array(); if (($result = mysql_query($query)) && mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { array_push($mObjs, new Match($row['match_id'])); } } elseif (mysql_errno() != 0) { die("<b>Query:</b><br>\n{$query}<br>\n<br>\n<b>Error:</b><br>\n" . mysql_error() . "<br>\n"); } objsort($mObjs, array('+date_played')); $m[$k] = count($mObjs) > MAX_MEM_MATCHES ? array() : $mObjs; } /* Rename CAS key */ $m['cas'] = $m['bh+ki+si']; unset($m['bh+ki+si']); /* Return, baby. */ return $m; }