Beispiel #1
0
 public static function report_ES($mid, $DIS)
 {
     global $lng, $ES_fields;
     $ES_grps = array();
     foreach ($ES_fields as $f) {
         if (!in_array($f['group'], $ES_grps)) {
             $ES_grps[] = $f['group'];
         }
     }
     $players = self::report_ES_loadPlayers($mid);
     // Update entries if requested.
     if (!$DIS && isset($_POST['ES_submitted'])) {
         $query = "SELECT tour_id AS 'trid', did, f_lid AS 'lid' FROM matches, tours, divisions WHERE match_id = {$mid} AND f_tour_id = tour_id AND f_did = did";
         $result = mysql_query($query);
         $NR = mysql_fetch_assoc($result);
         # Node Relations.
         $m = new Match($mid);
         global $p;
         # Dirty trick to make $p accessible within create_function() below.
         $status = true;
         foreach ($players as $teamPlayers) {
             foreach ($teamPlayers as $p) {
                 $status &= Match::ESentry(array('f_pid' => $p['pid'], 'f_tid' => $p['f_tid'], 'f_cid' => $p['f_cid'], 'f_rid' => $p['f_rid'], 'f_mid' => $mid, 'f_trid' => $NR['trid'], 'f_did' => $NR['did'], 'f_lid' => $NR['lid']), array_combine(array_keys($ES_fields), array_map(create_function('$f', 'global $p; return (int) $_POST["${f}_$p[pid]"];'), array_keys($ES_fields))));
             }
         }
         status($status);
         $m->finalizeMatchSubmit();
         // Run MySQL triggers
         $players = self::report_ES_loadPlayers($mid);
         # Reload!
     }
     // Create form
     title('ES submission');
     echo "<center><a href='index.php?section=matches&amp;type=report&amp;mid={$mid}'>" . $lng->getTrn('common/back') . "</a></center>\n";
     HTMLOUT::helpBox('<b>Field explanations</b><br><table>' . implode("\n", array_map(create_function('$f,$def', 'return "<tr><td>$f</td><td>$def[desc]</td></tr>";'), array_keys($ES_fields), array_values($ES_fields))) . '</table>', '<b>' . $lng->getTrn('common/needhelp') . '</b>');
     echo "<form method='POST'>\n";
     foreach ($players as $teamPlayers) {
         echo "<br>\n";
         echo "<table style='font-size: small;'>\n";
         $COLSPAN = count($teamPlayers) + 1;
         # +1 for field desc.
         $tid = $teamPlayers[0]['f_tid'];
         echo "<tr><td colspan='{$COLSPAN}'><b><a name='thead{$tid}'>" . get_alt_col('teams', 'team_id', $tid, 'name') . "</a></b></td></tr>";
         echo "<tr><td colspan='{$COLSPAN}'>Player number references:</td></tr>";
         echo implode('', array_map(create_function('$p', 'return "<tr><td colspan=\'' . $COLSPAN . '\'>#$p[nr] $p[name]</td></tr>";'), $teamPlayers));
         echo "<tr><td colspan='{$COLSPAN}'>GOTO anchor " . implode(', ', array_map(create_function('$anc', 'return "<a href=\'#' . $tid . '$anc\'>$anc</a>";'), $ES_grps)) . "</td></tr>";
         $grp = null;
         foreach ($ES_fields as $f => $def) {
             if ($def['group'] != $grp) {
                 $grp = $def['group'];
                 echo "<tr><td colspan='{$COLSPAN}'>&nbsp;</td></tr>";
                 echo "<tr style='font-style: italic;'><td><a name='{$tid}{$grp}'>{$grp}</a>&nbsp;|&nbsp;<a href='#thead{$tid}'>GOTO team head</a></td>" . implode('', array_map(create_function('$p', 'return "<td>#$p[nr]</td>";'), $teamPlayers)) . "</tr>";
                 echo "<tr><td colspan='{$COLSPAN}'><hr></td></tr>";
             }
             echo "<tr><td>{$f}</td>" . implode('', array_map(create_function('$p', 'return "<td><input ' . ($DIS ? 'DISABLED' : '') . ' size=\'2\' maxlength=\'4\' name=\'' . $f . '_$p[pid]\' value=\'".(($p[\'' . $f . '\']) ? (int) $p[\'' . $f . '\'] : 0)."\'></td>";'), $teamPlayers)) . "</tr>\n";
         }
         echo "</table>\n";
     }
     echo "<br><br><input type='submit' name='submit' value='" . $lng->getTrn('common/submit') . "'>\n";
     echo "<input type='hidden' name='ES_submitted' value='1'>\n";
     echo "</form>\n";
 }
Beispiel #2
0
    public static function conferenceAdmin()
    {
        global $lng, $tours, $coach;
        title($lng->getTrn('name', 'Conference'));
        self::handleActions();
        $tour_id = 0;
        if (isset($_POST['tour_id'])) {
            $tour_id = $_POST['tour_id'];
        }
        $firstTour = self::tournamentSelector($tour_id);
        // no tournament - they need to select something to see more.
        if ($tour_id == 0) {
            $tour_id = $firstTour;
        }
        // double check this coach is allowed to administer this tournament
        if (!$coach->isNodeCommish(T_NODE_TOURNAMENT, $tour_id)) {
            echo "<div class='boxWide'>";
            HTMLOUT::helpBox($lng->getTrn('not-admin', 'Conference'));
            echo "</div>";
            return;
        }
        $tour = new Tour($tour_id);
        $addConfTitle = $lng->getTrn('addConf', 'Conference');
        echo <<<EOQ
\t<div class='boxWide'>
\t\t<h3 class='boxTitle4'>{$tour->name}</h3>
\t\t<br />
\t\t<form name="add_conf" method="POST" action="handler.php?type=conference">
\t\t\t<input name='action' type='hidden' value='add_conf' />
\t\t\t<input name='tour_id' type='hidden' value='{$tour_id}' />
\t\t\t<input name='conf_name' type='hidden' value='{$tour_id}' />
\t\t\t<input id='conf_name' type="text" name="conf_name" size="30" maxlength="50">
\t\t\t<input type="submit" value="{$addConfTitle}">
\t\t</form>
\t</div>
    <script language="javascript">
    \tfunction removeTeam(conf_id, team_id) {
\t\t\tdocument.forms["remove_team"].conf_id.value=conf_id;
\t\t\tdocument.forms["remove_team"].team_id.value=team_id;
\t\t\tdocument.forms["remove_team"].submit();
\t\t}
    \tfunction removeConf(conf_id) {
\t\t\tdocument.forms["remove_conf"].conf_id.value=conf_id;
\t\t\tdocument.forms["remove_conf"].submit();
\t\t}
    </script>
\t<form name="remove_team" method="POST" action="handler.php?type=conference">
\t\t<input name='action' type='hidden' value='remove_team' />
\t\t<input name='tour_id' type='hidden' value='{$tour_id}' />
\t\t<input name='conf_id' id='conf_id' type='hidden' value='0' />
\t\t<input name='team_id' id='team_id' type='hidden' value='0' />
\t</form>
\t<form name="remove_conf" method="POST" action="handler.php?type=conference">
\t\t<input name='action' type='hidden' value='remove_conf' />
\t\t<input name='tour_id' type='hidden' value='{$tour_id}' />
\t\t<input name='conf_id' id='conf_id' type='hidden' value='0' />
\t</form>
\t<table class="boxTable">
EOQ;
        $confs = self::getConferencesForTour($tour->tour_id);
        $idx = 0;
        foreach ($confs as $conf) {
            $conf->loadTeams();
            if ($idx % 2 == 0) {
                echo "<tr valign='top'>";
            }
            echo <<<EOQ
\t\t<td>
\t\t<div class='boxCommon' style='margin-top: 0px; width=325px'>
\t\t\t<h4 class='boxTitleConf'>{$conf->name} <a onclick="return removeConf({$conf->conf_id});"><img src="images/remove.png" height="16" width="16" title="remove {$conf->name}" alt="remove {$conf->name}"/></a></h4>
\t\t\t<div style='white-space:nowrap; margin: 0px; padding: 5px; padding-top: 0px; line-height:175%; border 0px;'>
EOQ;
            self::findTeam($tour->tour_id, $conf->conf_id);
            foreach ($conf->teams as $team) {
                $link = "<a href='" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $team->team_id, false, false) . "'>{$team->name}</a>";
                echo <<<EOQ
\t\t\t\t<br />{$link} <a onclick="return removeTeam({$conf->conf_id},{$team->team_id});"><img src="images/remove.png" height="12" width="12" title="remove {$team->name} from {$conf->name}" alt="remove {$team->name} from {$conf->name}"/></a>
EOQ;
            }
            echo <<<EOQ
\t\t\t</div>
\t\t</div>
\t\t</td>
EOQ;
            if ($idx % 2 == 1) {
                echo "</tr>";
            }
            $idx++;
        }
        echo <<<EOQ
\t</table>
EOQ;
    }
Beispiel #3
0
 public static function handleActions()
 {
     global $lng, $coach;
     if (isset($_POST['action'])) {
         if (is_object($coach) && $coach->isNodeCommish(T_NODE_LEAGUE, $_POST['lid'])) {
             $l_pref = new LeaguePref($_POST['lid'], "", $_POST['p_tour'], $_POST['league_name'], $_POST['forum_url'], $_POST['welcome'], $_POST['rules'], $_POST['existing']);
             if ($l_pref->validate()) {
                 if ($l_pref->save()) {
                     echo "<div class='boxWide'>";
                     HTMLOUT::helpBox($lng->getTrn('saved', 'LeaguePref'), '');
                     echo "</div>";
                 } else {
                     echo "<div class='boxWide'>";
                     HTMLOUT::helpBox($lng->getTrn('failedSave', 'LeaguePref'), '', 'errorBox');
                     echo "</div>";
                 }
             } else {
                 echo "<div class='boxWide'>";
                 HTMLOUT::helpBox($lng->getTrn('failedValidate', 'LeaguePref'), '', 'errorBox');
                 echo "</div>";
             }
         } else {
             echo "<div class='boxWide'>";
             HTMLOUT::helpBox($lng->getTrn('failedSecurity', 'LeaguePref'), '', 'errorBox');
             echo "</div>";
         }
     }
 }