Exemple #1
0
function setupGlobalVars($type, $opts = array())
{
    global $coach, $lng, $leagues, $divisions, $tours, $settings, $rules, $admin_menu;
    switch ($type) {
        case T_SETUP_GLOBAL_VARS__COMMON:
            $coach = isset($_SESSION['logged_in']) ? new Coach($_SESSION['coach_id']) : null;
            # Create global coach object.
            list($leagues, $divisions, $tours) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, is_object($coach) ? $coach->coach_id : false, $extraFields = array(T_NODE_TOURNAMENT => array('locked' => 'locked', 'type' => 'type', 'f_did' => 'f_did'), T_NODE_DIVISION => array('f_lid' => 'f_lid'), T_NODE_LEAGUE => array('tie_teams' => 'tie_teams')));
            setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS);
            $_LANGUAGE = is_object($coach) && isset($coach->settings['lang']) ? $coach->settings['lang'] : $settings['lang'];
            if (!is_object($lng)) {
                $lng = new Translations($_LANGUAGE);
            } else {
                $lng->setLanguage($_LANGUAGE);
            }
            break;
        case T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES:
            $admin_menu = is_object($coach) ? $coach->getAdminMenu() : array();
            break;
        case T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS:
            // Local league settings exist?
            $file = "localsettings/settings_ID.php";
            // Update selected node $_SESSION vars if node selector form submission made (will make HTMLOUT::getSelectedNodeLid(), below, catch the correct league straight as opposed to on second page reload).
            HTMLOUT::updateNodeSelectorLeagueVars();
            // Selected
            if (isset($opts['lid']) && is_numeric($opts['lid'])) {
                $id = $opts['lid'];
            } else {
                if ($_lid = HTMLOUT::getSelectedNodeLid()) {
                    $id = $_lid;
                } else {
                    if (is_object($coach) && isset($coach->settings['home_lid'])) {
                        $id = $coach->settings['home_lid'];
                    } else {
                        $id = isset($settings['default_visitor_league']) ? $settings['default_visitor_league'] : '';
                    }
                }
            }
            $settingsFile = str_replace("ID", $id, $file);
            if ($localsettings = file_exists($settingsFile) ? $settingsFile : false) {
                include $localsettings;
            } else {
                include str_replace("ID", 'none', $file);
                # Empty settings file.
            }
            break;
        case T_SETUP_GLOBAL_VARS__POST_COACH_LOGINOUT:
            setupGlobalVars(T_SETUP_GLOBAL_VARS__COMMON);
            setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES);
            break;
    }
}
Exemple #2
0
 public function mayManageObj($obj, $id)
 {
     $managee = new Coach($obj == T_OBJ_COACH ? $id : get_alt_col('teams', 'team_id', $id, 'owned_by_coach_id'));
     list($mangers_leagues) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, $this->coach_id);
     $MAY_MANAGE_LOCALLY = false;
     switch ($obj) {
         // Is this coach a commish in a league where the selected coach is a member?
         case T_OBJ_COACH:
             list($managees_leagues) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, $managee->coach_id);
             foreach ($managees_leagues as $lid => $desc) {
                 if (isset($mangers_leagues[$lid]) && $mangers_leagues[$lid]['ring'] == Coach::T_RING_LOCAL_ADMIN) {
                     $MAY_MANAGE_LOCALLY = true;
                     break;
                 }
             }
             break;
             // Is this coach a commish in the league the specified team is bounded to?
         // Is this coach a commish in the league the specified team is bounded to?
         case T_OBJ_TEAM:
             $f_lid = get_alt_col('teams', 'team_id', $id, 'f_lid');
             $MAY_MANAGE_LOCALLY = isset($mangers_leagues[$f_lid]) && $mangers_leagues[$f_lid]['ring'] == Coach::T_RING_LOCAL_ADMIN;
             break;
     }
     return $managee->ring <= $this->ring && ($MAY_MANAGE_LOCALLY || $this->ring == Coach::T_RING_GLOBAL_ADMIN);
 }
Exemple #3
0
<div class="boxCommon">
    <div class="boxTitle<?php 
echo T_HTMLBOX_ADMIN;
?>
">
        Display coach access levels
    </div>
    <div class="boxBody">
        <form method="POST">
        Coach name<br> <input type="text" name="cname" id="coach3" size="20" maxlength="50"><br><br>
        <?php 
if (is_object($c)) {
    echo "Access levels of '{$c->name}' are<br><br>\n";
    echo "<b>Global</b><br>" . $T_GLOBAL_RINGS[$c->ring] . "<br><br>";
    echo "<b>Local</b><br>";
    list($_leagues) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, $c->coach_id);
    if (empty($_leagues)) {
        echo "<i>None</i>";
    } else {
        echo "<table><tr style='font-style:italic;'><td>League</td><td>Access level</td></tr>\n";
        foreach ($_leagues as $lid => $desc) {
            echo "<tr><td>{$desc['lname']}</td><td>" . $T_LOCAL_RINGS[$desc['ring']] . "</td></tr>\n";
        }
        echo "</table>";
    }
}
?>
        <br><br>
        <input type="hidden" name="type" value="disp_access_levels">
        <input type="submit" name="button" value="Display coach's access levels">
        </form>
Exemple #4
0
    private function _newTeam($ALLOW_EDIT)
    {
        global $lng, $settings, $raceididx, $rules;
        global $leagues, $divisions;
        // Form posted? -> Create team.
        if (isset($_POST['type']) && $_POST['type'] == 'newteam' && $ALLOW_EDIT) {
            if (get_magic_quotes_gpc()) {
                $_POST['name'] = stripslashes($_POST['name']);
            }
            @(list($lid, $did) = explode(',', $_POST['lid_did']));
            setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
            // Load correct $rules for league.
            list($exitStatus, $tid) = Team::create(array('name' => $_POST['name'], 'owned_by_coach_id' => (int) $this->coach_id, 'f_race_id' => (int) $_POST['rid'], 'treasury' => $rules['initial_treasury'], 'apothecary' => 0, 'rerolls' => $rules['initial_rerolls'], 'ff_bought' => $rules['initial_fan_factor'], 'ass_coaches' => $rules['initial_ass_coaches'], 'cheerleaders' => $rules['initial_cheerleaders'], 'won_0' => 0, 'lost_0' => 0, 'draw_0' => 0, 'played_0' => 0, 'wt_0' => 0, 'gf_0' => 0, 'ga_0' => 0, 'imported' => 0, 'f_lid' => (int) $lid, 'f_did' => isset($did) ? (int) $did : Team::T_NO_DIVISION_TIE));
            status(!$exitStatus, $exitStatus ? Team::$T_CREATE_ERROR_MSGS[$exitStatus] : null);
        }
        // Show new team form.
        ?>
    <br><br>
    <div class='boxCommon'>
        <h3 class='boxTitle<?php 
        echo T_HTMLBOX_COACH;
        ?>
'><?php 
        echo $lng->getTrn('cc/new_team');
        ?>
</h3>
        <div class='boxBody'>
        
    <form method="POST">
    <?php 
        echo $lng->getTrn('common/name');
        ?>
<br>
    <input type="text" name="name" size="20" maxlength="50">
    <br><br>
    <?php 
        echo $lng->getTrn('common/race');
        ?>
<br>
    <select name="rid">
        <?php 
        // We need to sort the array manually because of the translation
        foreach ($raceididx as $rid => &$rname) {
            $rname = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $rname)));
        }
        unset($rname);
        // very important !
        asort($raceididx);
        // The, we display as usual
        foreach ($raceididx as $rid => $rname) {
            echo "<option value='{$rid}'>{$rname}</option>\n";
        }
        ?>
    </select>
    <br><br>
    <?php 
        echo $lng->getTrn('common/league') . '/' . $lng->getTrn('common/division');
        ?>
<br>
    <select name="lid_did">
        <?php 
        foreach ($leagues = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, $this->coach_id, array(T_NODE_LEAGUE => array('tie_teams' => 'tie_teams'))) as $lid => $lstruct) {
            if ($lstruct['desc']['tie_teams']) {
                echo "<OPTGROUP LABEL='" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "'>\n";
                foreach ($lstruct as $did => $dstruct) {
                    if ($did != 'desc') {
                        echo "<option value='{$lid},{$did}'>" . $lng->getTrn('common/division') . ": " . $dstruct['desc']['dname'] . "</option>";
                    }
                }
                echo "</OPTGROUP>\n";
            } else {
                echo "<option value='{$lid}'>" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "</option>";
            }
        }
        ?>
    </select>
    <br><br>    
    <input type='hidden' name='type' value='newteam'>
    <input type="submit" name="new_team" value="<?php 
        echo $lng->getTrn('common/create');
        ?>
" <?php 
        echo count($leagues) == 0 ? 'DISABLED' : '';
        ?>
>
    </form>
        </div>
    </div>
    <?php 
    }
Exemple #5
0
 private static function form()
 {
     /**
      * Creates an upload form.
      *
      * 
      **/
     global $coach;
     if (is_object($coach)) {
         # Tours the logged in coach can "see".
         list(, , $tours) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, $coach->coach_id, array(T_NODE_TOURNAMENT => array('type' => 'type', 'locked' => 'locked', 'f_did' => 'f_did')));
         $tourlist = "";
         $coach_lid = isset($_SESSION['NS_node_id']) && $_SESSION['NS_node_id'] > 0 ? $_SESSION['NS_node_id'] : 1;
         foreach ($tours as $trid => $t) {
             $lid = get_alt_col('divisions', 'did', $t['f_did'], 'f_lid');
             if ($t['type'] == TT_FFA && !$t['locked'] && $coach_lid == $lid && $t['tname'] != "Pandora's Box") {
                 $tourlist .= "<option value='{$trid}'>{$t['tname']}</option>\n";
             }
         }
         #            $tourlist = HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'ffatours', array(T_NODE_TOURNAMENT => array('type' => TT_FFA, 'locked' => 0)), array(), array('hide_empty'=>array(T_NODE_DIVISION,T_NODE_LEAGUE)));
         global $settings;
         $cy_reroll = "";
         if ($settings['leegmgr_cyanide']) {
             $cy_reroll = "\r\n                    Reroll winnings if roll is less than: \r\n                    <select name='reroll'>\r\n                        <option value='2'>2</option>\r\n                        <option value='3'>3</option>\r\n                        <option value='4'>4</option>\r\n                        <option value='5'>5</option>\r\n                        <option value='6'>6</option>\r\n                    </select><br>";
         }
         $form = "\r\n                <!-- The data encoding type, enctype, MUST be specified as below -->\r\n                <form enctype='multipart/form-data' action='handler.php?type=leegmgr' method='POST'>\r\n                    <!-- MAX_FILE_SIZE must precede the file input field -->\r\n                    <input type='hidden' name='MAX_FILE_SIZE' value='256000' />\r\n                    <!-- Name of input element determines name in {$_FILES} array -->\r\n                    Send this file <input name='userfile' type='file' /><br>\r\n                    Save in tournament\r\n                    <select name='ffatours'>\r\n                        <optgroup label='Existing FFA'>\r\n\r\n                            {$tourlist}\r\n\r\n                        </optgroup>\r\n                    </select>\r\n\r\n                    <br>{$cy_reroll}<br>\r\n                    <input type='submit' value='Send File' />\r\n                </form>\r\n            ";
         return "\r\n            <div class='boxCommon'>\r\n            <h3 class='boxTitle" . T_HTMLBOX_MATCH . "'>Upload match</h3>\r\n            <div class='boxBody'>\r\n            " . $form . "\r\n            </div>\r\n            </div>\r\n            ";
     } else {
         return 'You must login in order to upload a match report.';
     }
 }
Exemple #6
0
 public static function nodeList($node, $nameid, $filter = array(), $disCond = array(), $opts = array())
 {
     global $coach, $lng;
     // Inputs
     $selected_id = isset($opts['sel_id']) ? $opts['sel_id'] : null;
     $extra_tags = isset($opts['extra_tags']) ? $opts['extra_tags'] : array();
     $allow_all = isset($opts['allow_all']) && $opts['allow_all'];
     $hide_empty = isset($opts['hide_empty']) ? $opts['hide_empty'] : array();
     $empty_str = isset($opts['empty_str']) ? $opts['empty_str'] : array();
     # e.g. "%name (EMPTY)" where %name will be substituted like $DISSTR
     $init_option = isset($opts['init_option']) ? $opts['init_option'] : false;
     # Default empty strings
     foreach ($empty_str as $idx => $str) {
         if (empty($str)) {
             # If $emprty_str = array(T_NODE_* => ''); then we convert it to the below.
             $empty_str[$idx] = strtoupper($lng->getTrn('common/empty')) . ' &mdash; %name';
         }
     }
     // Preprocessing
     $additionalFields = array();
     # Init filters to empty if not set
     foreach (array(T_NODE_LEAGUE, T_NODE_DIVISION, T_NODE_TOURNAMENT) as $n) {
         if (!isset($filter[$n])) {
             $filter[$n] = array();
         }
     }
     # "OTHER" filters may contain non-node field (ie. membership fields): ring
     $OTHER_FILTER = isset($filter['OTHER']) ? $filter['OTHER'] : array();
     unset($filter['OTHER']);
     # Don't pass to allowedNodeAccess() - add to $filter again later...
     foreach ($filter as $n => $filters) {
         $_filter_keys = array_keys($filters);
         # Recombine for allowedNodeAccess() => the returned fields from allowedNodeAccess() the same names as the keys from $filters.
         $additionalFields[$n] = empty($_filter_keys) ? array() : array_combine($_filter_keys, $_filter_keys);
         # Don't rereference the field names, make them the same.
     }
     $DISSTR = isset($disCond['DISSTR']) ? $disCond['DISSTR'] : '';
     unset($disCond['DISSTR']);
     $_filter_keys = array_keys($disCond);
     $disCond2 = empty($_filter_keys) ? array() : array_combine($_filter_keys, $_filter_keys);
     # Don't rereference the field names, make them the same.
     $additionalFields[$node] = array_merge($additionalFields[$node], $disCond2);
     $leagues = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, is_object($coach) ? $coach->coach_id : false, $additionalFields);
     # This needs only to be added to the league node filter, since it's always evaluated independant of the $node value.
     $filter[T_NODE_LEAGUE] = array_merge($filter[T_NODE_LEAGUE], $OTHER_FILTER);
     #    print_r($leagues);'
     # Mark nodse to hide in their desc element
     foreach ($leagues as $lid => $divs) {
         # I.e. only the 'desc' element exists => no divs in league
         $leagues[$lid]['desc']['_empty'] = $empty = count($divs) == 1;
         $leagues[$lid]['desc']['_hide'] = $empty && in_array(T_NODE_LEAGUE, $hide_empty);
         foreach ($divs as $did => $tours) {
             if ($did == 'desc') {
                 continue;
             }
             # I.e. only the 'desc' element exists => no tours in division
             $leagues[$lid][$did]['desc']['_empty'] = $empty = count($tours) == 1;
             $leagues[$lid][$did]['desc']['_hide'] = $empty && in_array(T_NODE_DIVISION, $hide_empty);
         }
     }
     // Done preprocessing...
     $NL = '';
     $NL .= "<select name='{$nameid}' id='{$nameid}' " . implode(' ', $extra_tags) . ">\n";
     if ($init_option) {
         $NL .= $init_option;
     }
     switch ($node) {
         case T_NODE_TOURNAMENT:
             foreach ($leagues as $lid => $divs) {
                 if (!self::_nodeList_filter($filter[T_NODE_LEAGUE], $divs['desc']) || $divs['desc']['_hide']) {
                     continue;
                 }
                 $optname = self::quoteEsc($divs['desc']['lname']);
                 if ($divs['desc']['_empty'] && isset($empty_str[T_NODE_LEAGUE])) {
                     $optname = str_replace('%name', $optname, $empty_str[T_NODE_LEAGUE]);
                 }
                 $NL .= "<optgroup class='leagues' label='{$optname}'>\n";
                 foreach ($divs as $did => $tours) {
                     if (!is_numeric($did)) {
                         continue;
                     }
                     # skip "desc" entry for division
                     if (!self::_nodeList_filter($filter[T_NODE_DIVISION], $tours['desc']) || $tours['desc']['_hide']) {
                         continue;
                     }
                     $optname = self::quoteEsc($tours['desc']['dname']);
                     if ($tours['desc']['_empty'] && isset($empty_str[T_NODE_DIVISION])) {
                         $optname = str_replace('%name', $optname, $empty_str[T_NODE_DIVISION]);
                     }
                     $NL .= "<optgroup class='divisions' style='padding-left: 1em;' label='{$optname}'>\n";
                     foreach ($tours as $trid => $desc) {
                         if (!is_numeric($trid)) {
                             continue;
                         }
                         # skip "desc" entry for division
                         if (!self::_nodeList_filter($filter[T_NODE_TOURNAMENT], $desc['desc'])) {
                             continue;
                         }
                         $dis = false;
                         foreach ($disCond as $key => $val) {
                             if ($desc['desc'][$key] == $val) {
                                 $dis = true;
                                 break;
                             }
                         }
                         $name = self::quoteEsc($desc['desc']['tname']);
                         $NL .= "<option " . ($dis ? 'DISABLED' : '') . " style='background-color: white; margin-left: -1em;' value='{$trid}' " . ($selected_id == $trid ? 'SELECTED' : '') . ">" . ($dis ? str_replace('%name', $name, $DISSTR) : $name) . "</option>\n";
                     }
                     $NL .= "</optgroup>\n";
                 }
                 $NL .= "</optgroup>\n";
             }
             break;
         case T_NODE_DIVISION:
             foreach ($leagues as $lid => $divs) {
                 if (!self::_nodeList_filter($filter[T_NODE_LEAGUE], $divs['desc']) || $divs['desc']['_hide']) {
                     continue;
                 }
                 $optname = self::quoteEsc($divs['desc']['lname']);
                 if ($divs['desc']['_empty'] && isset($empty_str[T_NODE_LEAGUE])) {
                     $optname = str_replace('%name', $optname, $empty_str[T_NODE_LEAGUE]);
                 }
                 $NL .= "<optgroup class='leagues' label='{$optname}'>\n";
                 foreach ($divs as $did => $tours) {
                     if (!is_numeric($did)) {
                         continue;
                     }
                     # skip "desc" entry for division
                     if (!self::_nodeList_filter($filter[T_NODE_DIVISION], $tours['desc'])) {
                         continue;
                     }
                     $dis = false;
                     foreach ($disCond as $key => $val) {
                         if ($tours['desc'][$key] == $val) {
                             $dis = true;
                             break;
                         }
                     }
                     $name = self::quoteEsc($tours['desc']['dname']);
                     if ($dis) {
                         $name = str_replace('%name', $name, $DISSTR);
                     }
                     if ($tours['desc']['_empty'] && isset($empty_str[T_NODE_DIVISION])) {
                         $name = str_replace('%name', $name, $empty_str[T_NODE_DIVISION]);
                     }
                     $NL .= "<option " . ($dis ? 'DISABLED' : '') . " style='background-color: white;' value='{$did}' " . ($selected_id == $did ? 'SELECTED' : '') . ">{$name}</option>\n";
                 }
                 $NL .= "</optgroup>\n";
             }
             break;
         case T_NODE_LEAGUE:
             if ($allow_all) {
                 $NL .= "<option style='font-weight: bold;' value='" . T_NODE_ALL . "'>-" . $lng->getTrn('common/all') . "-</option>\n";
             }
             foreach ($leagues as $lid => $divs) {
                 if (!self::_nodeList_filter($filter[T_NODE_LEAGUE], $divs['desc'])) {
                     continue;
                 }
                 $dis = false;
                 foreach ($disCond as $key => $val) {
                     if ($divs['desc'][$key] == $val) {
                         $dis = true;
                         break;
                     }
                 }
                 $name = self::quoteEsc($divs['desc']['lname']);
                 if ($dis) {
                     $name = str_replace('%name', $name, $DISSTR);
                 }
                 if ($divs['desc']['_empty'] && isset($empty_str[T_NODE_LEAGUE])) {
                     $name = str_replace('%name', $name, $empty_str[T_NODE_LEAGUE]);
                 }
                 $NL .= "<option " . ($dis ? 'DISABLED' : '') . " value='{$lid}' " . ($selected_id == $lid ? 'SELECTED' : '') . ">{$name}</option>\n";
             }
             break;
     }
     $NL .= "</select>\n";
     return $NL;
 }
Exemple #7
0
    public static function tours()
    {
        global $rules, $settings, $lng, $coach;
        title($lng->getTrn('menu/matches_menu/tours'));
        $flist = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, is_object($coach) ? $coach->coach_id : false);
        $tourObjs = array();
        $flist_JShides = array();
        $divsToFoldUp = array();
        // Run through the tours to see which nodes should be hidden.
        $ENABLE_LEAG_HIDING = in_array('league', $settings['tourlist_hide_nodes']);
        $ENABLE_DIV_HIDING = in_array('division', $settings['tourlist_hide_nodes']);
        $ENABLE_TOUR_HIDING = in_array('tournament', $settings['tourlist_hide_nodes']);
        foreach ($flist as $lid => $divs) {
            $HIDE_LEAG = $ENABLE_LEAG_HIDING;
            foreach ($divs as $did => $tours) {
                if ($did == 'desc') {
                    continue;
                }
                $HIDE_DIV = $ENABLE_DIV_HIDING;
                $FOLDUP_DIV = $settings['tourlist_foldup_fin_divs'];
                foreach ($tours as $trid => $desc) {
                    if ($trid == 'desc') {
                        continue;
                    }
                    $tourObjs[$trid] = new Tour($trid);
                    if ($ENABLE_TOUR_HIDING && $tourObjs[$trid]->is_finished) {
                        $flist_JShides[] = "trid_{$trid}";
                    }
                    $HIDE_DIV &= $tourObjs[$trid]->is_finished;
                    $FOLDUP_DIV &= $tourObjs[$trid]->is_finished;
                }
                if ($HIDE_DIV) {
                    $flist_JShides[] = "did_{$did}";
                }
                if ($FOLDUP_DIV) {
                    $divsToFoldUp[] = $did;
                }
                $HIDE_LEAG &= $HIDE_DIV;
            }
            if ($HIDE_LEAG) {
                $flist_JShides[] = "lid_{$lid}";
            }
        }
        // Print show hidden button.
        ?>
    <script language="JavaScript" type="text/javascript">
        function showFullTourList()
        {
            var hidden=[<?php 
        echo array_strpack("'%s'", $flist_JShides, ',');
        ?>
];
            for (var h in hidden) {
                slideToggleFast(hidden[h]+'_head');
                slideToggleFast(hidden[h]+'_cont');
            }
            return;
        }
    </script>
    <?php 
        echo "<a href='javascript:void(0)' onClick='showFullTourList();'>" . $lng->getTrn('matches/tours/showhidden') . "</a><br>";
        // Print fixture list.
        foreach ($flist as $lid => $divs) {
            # Container
            echo "<div id='lid_{$lid}_cont' class='leaguesNCont' style='" . (in_array("lid_{$lid}", $flist_JShides) ? "display:none;" : '') . "'>";
            # Title
            echo "<div class='leagues'><b><a href='javascript:void(0);' onClick=\"slideToggleFast('lid_{$lid}');\">[+/-]</a>&nbsp;" . $flist[$lid]['desc']['lname'] . "</b></div>\n";
            # Body
            echo "<div id='lid_{$lid}'>";
            foreach ($divs as $did => $tours) {
                if ($did == 'desc') {
                    continue;
                }
                # Container
                echo "<div id='did_{$did}_cont' class='divisionsNCont' style='" . (in_array("did_{$did}", $flist_JShides) ? "display:none;" : '') . "'>";
                # Title
                echo "<div class='divisions'><b><a href='javascript:void(0);' onClick=\"slideToggleFast('did_{$did}');\">[+/-]</a>&nbsp;" . $flist[$lid][$did]['desc']['dname'] . "</b></div>";
                # Body
                echo "<div id='did_{$did}' " . (in_array($did, $divsToFoldUp) ? 'style="display:none;"' : '') . ">";
                foreach ($tours as $trid => $desc) {
                    if ($trid == 'desc') {
                        continue;
                    }
                    # Container
                    echo "<div id='trid_{$trid}_cont' class='toursNCont' style='" . (in_array("trid_{$trid}", $flist_JShides) ? "display:none;" : '') . "'>";
                    # Title
                    echo "<div class='tours'><a href='index.php?section=matches&amp;type=tourmatches&amp;trid={$trid}'>" . $flist[$lid][$did][$trid]['desc']['tname'] . "</a>";
                    $tr = $tourObjs[$trid];
                    # We already have loaded these - reuse them!
                    $suffix = '';
                    if ($tr->is_finished) {
                        $suffix .= '-&nbsp;&nbsp;<i>' . $lng->getTrn('common/finished') . '</i>&nbsp;&nbsp;';
                    }
                    if ($tr->locked) {
                        $suffix .= '-&nbsp;&nbsp;<i>' . $lng->getTrn('common/locked') . '</i>&nbsp;&nbsp;';
                    }
                    if (!empty($suffix)) {
                        echo '&nbsp;&nbsp;' . $suffix;
                    }
                    echo "</div>\n";
                    # tour title container
                    echo "</div>\n";
                    # tour container
                }
                echo "</div>\n";
                # div body container
                echo "</div>\n";
                # div container
            }
            echo "</div>\n";
            # league body container
            echo "</div>\n";
            # league container
        }
    }
    public static function newTeam($cid)
    {
        global $lng, $coach, $raceididx, $leagues, $rules, $divisions;
        self::handlePost($cid);
        // Show new team form.
        $easyconvert = new array_to_js();
        $races = self::getRaceArray();
        @$easyconvert->add_array($races, 'races');
        echo $easyconvert->output_all();
        // txt constants to show later
        $txtNoInduce = $lng->getTrn('noInduce', 'TeamCreator');
        $txtNoTeamName = $lng->getTrn('noTeamName', 'TeamCreator');
        $txtTooFewPlayers = $lng->getTrn('tooFewPlayers', 'TeamCreator');
        $txtRaceSelectTitle = $lng->getTrn('race', 'TeamCreator');
        $txtRaceSelectOption = $lng->getTrn('raceDefaultOption', 'TeamCreator');
        $txtTeamName = $lng->getTrn('teamName', 'TeamCreator');
        $txtNoRaceSelected = $lng->getTrn('noRaceSelected', 'TeamCreator');
        $txtCreateBtn = $lng->getTrn('createBtn', 'TeamCreator');
        // The page builds itself dynamically based on the selected race
        echo <<<EOQ
   <script type="text/javascript">

   function setIndex(elem, value) {
      document.getElementById(elem).selectedIndex = value;
   }

   function getValue(elemId) {
      try {
         var elem = document.getElementById(elemId);
         return elem.options[elem.selectedIndex].value;
      } catch (err) {
         return "";
      }
   }

   function getText(elemId) {
      try {
         if(document.all){
            return document.getElementById(elemId).innerText;
         } else {
            return document.getElementById(elemId).textContent;
         }
      } catch (err) {
         return "";
      }
   }

   function addCellToRow(rowObj, cellValue, colspan) {
      var cell = rowObj.insertCell(rowObj.cells.length);
      if (colspan > 1) {
         cell.colSpan=colspan;
         cell.align="right";
         cell.innerHTML = cellValue + "&nbsp;&nbsp;";;
        } else {
         cell.innerHTML = cellValue;
        }
      return cell;
   }

   function makeInput(type, id, value) {
      return "<input type=\\"" + type + "\\" id=\\"" + id + "\\" name=\\"" + id + "\\" value=\\"" + value+ "\\" />";
   }

   function setText(element, text) {
      if(document.all){
           document.getElementById(element).innerText = text;
      } else{
          document.getElementById(element).textContent = text;
      }
   }


   function updateQty(id, type, newQty) {
      var race = races[document.getElementById("rid").value];
      if (type == 'p') {
         var players = race['players'];
      } else {
         var players = race['others'];
      }
      var player = players[id];
      var divS = 'sub' + type + id;
      var newCost = player['cost'] * newQty;
      setText(divS, newCost);
      updateTotal();
   }

   function makeSelect(id, type, max) {
      var str = "<select id=\\"qty" + type + id + "\\" name=\\"qty" + type + id + "\\" onchange=\\"updateQty(" + id + ", '" + type + "', this.options[this.selectedIndex].value)\\">";
      for (var i = 0; i <= max; i++) {
         str += "<option value=\\"" + i + "\\">" + i + "</option>";
      }
      str += "</select>";
      return str;
   }

   function changeInduce(check) {
      var oldInduce = document.getElementById('oldInduce');
      if (check != new Boolean(oldInduce.checked)) {
         oldInduce.checked = check;
         var race = races[document.getElementById("rid").value];
         var pCounts = new Array();
         var oCounts = new Array();
         for (var i=0; i < race["player_count"]; i++) {
            pCounts[i] = getValue('qtyp' + i);
         }
         for (i=0; i < race["other_count"]; i++) {
            oCounts[i] = getValue('qtyo' + i);
         }
         changeRace(getValue("rid"));
         for (var i=0; i < race["player_count"]; i++) {
            if (pCounts[i] > 0) {
               try {
                  setIndex('qtyp' + i, pCounts[i]);
                  updateQty(i, 'p', pCounts[i]);
               } catch (err) {
               }
            }
         }
         for (i=0; i < race["other_count"]; i++) {
            if (oCounts[i] > 0) {
               try {
                  setIndex('qtyo' + i, oCounts[i]);
                  updateQty(i, 'o', oCounts[i]);
               } catch (err) {
               }
            }
         }
      }
   }

   function changeRace(raceId) {
      if (raceId < 0) return;
      var oFormObject = document.forms['form_team'];
      var race = races[raceId];
      var players = race["players"];
      var others = race["others"];
      var i;
      var rowIdx;
      var table = document.getElementById('teamTable');
      var induce = document.getElementById('induce').checked;
      while (table.rows.length > 1) {
         table.deleteRow(1);
      }
      setText("pcnt", "0");
      setText("total", "0");
      document.getElementById("raceid").value = race.rid;

      rowIdx = 0;
      for (i = 0; i < race["player_count"]; i++) {
         var player = players[i];
         if (!induce && player['ind']) {
            continue;
         }
         rowIdx++;
         var row = table.insertRow(rowIdx);
         addCellToRow(row, player["position"], 1);
         addCellToRow(row, player["ma"], 1);
         addCellToRow(row, player["st"], 1);
         addCellToRow(row, player["ag"], 1);
         addCellToRow(row, player["av"], 1);
         addCellToRow(row, player["skills"], 1);
         addCellToRow(row, player["N"], 1);
         addCellToRow(row, player["D"], 1);
         addCellToRow(row, player["cost"], 1);
         addCellToRow(row, makeInput('hidden', 'pid' + i, player["id"]) + makeSelect(i, 'p', player["max"]), 1);
         addCellToRow(row, "<div id=\\"subp" + i + "\\"></div>", 1);
      }
      for (i = 0; i < race["other_count"]; i++) {
         var other = others[i];
         if (!induce && other['ind']) {
            continue;
         }
         rowIdx++;
         var row = table.insertRow(rowIdx);
         addCellToRow(row, other["name"], 8);
         addCellToRow(row, other["cost"], 1);
         addCellToRow(row, makeInput('hidden', 'oid' + i, other["name"]) + makeSelect(i, 'o', other["max"]), 1);
         addCellToRow(row, "<div id=\\"subo" + i + "\\"></div>", 1);
      }
      try {
         if(induce) {
            document.getElementById("createBtnTxt").title="{$txtNoInduce}";
            document.getElementById("createBtn").disabled="disabled";
         } else {
            document.getElementById("createBtnTxt").title="";
            document.getElementById("createBtn").disabled="";
         }
      } catch (err) {
         // ignore - probably not logged in
      }
   }

   function updateTotal() {
      var race = races[getValue("rid")];
      var playerCount = race['player_count'];

      var pCount = 0;
      var total = 0;
      var subTot = 0;

      for (var i=0; i < playerCount; i++) {
         pCount += new Number(getValue('qtyp' + i));
         subTot = getText('subp' + i);
         if (!isNaN(subTot)) {
            total +=  new Number(subTot);
         }
      }
      setText("pcnt", pCount);
      for (var i=0; i < race['other_count']; i++) {
         subTot = getText('subo' + i);
         if (!isNaN(subTot)) {
            total +=  new Number(subTot);
         }
      }
      setText("total",total);
   }

   function createTeam() {
      var oForm = document.forms['form_team'];
      var spend = new Number(getText("total"));
      var pCount = new Number(getText("pcnt"));
      var tName = document.getElementById("tname").value;
      var submit = true;

      if (submit && tName.length == 0) {
         alert('{$txtNoTeamName}');
         submit = false;
      }

      if (submit && pCount < 11) {
         alert('{$txtTooFewPlayers}');
         submit = false;
      }

      if (submit) {
         oForm.submit();
      }

   }

   </script>
   <form method="POST" id="form_team">
   <input type="hidden" id="action" name="action" value="create" />
   <input type="hidden" id="raceid" name="raceid" value="" />
   <div class='boxWide'>
      <table class="common"><tr><td>
      <b>{$txtRaceSelectTitle}</b>: <select id="rid" name="rid" onchange="changeRace(this.options[this.selectedIndex].value)">
EOQ;
        echo "<option value='-1'>{$txtRaceSelectOption}</option>";
        $i = 0;
        foreach ($raceididx as $rname) {
            $translatedRaceName = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $rname)));
            echo "<option value='{$i}'>{$translatedRaceName}</option>";
            $i++;
        }
        echo <<<EOQ
       </select></td>
EOQ;
        if (isset($coach)) {
            $lgeDiv = $lng->getTrn('common/league') . '/' . $lng->getTrn('common/division');
            echo <<<EOQ
      <td align="right"><b>{$txtTeamName}</b>:</td><td><input type="text" id="tname" name="tname" size="20" maxlength="50"></td>
      <td align="right"><b>{$lgeDiv}</b>:</td><td><select name="lid_did" id="lid_did">
EOQ;
            foreach ($leagues = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, $coach->coach_id, array(T_NODE_LEAGUE => array('tie_teams' => 'tie_teams'))) as $lid => $lstruct) {
                if ($lstruct['desc']['tie_teams']) {
                    echo "<OPTGROUP LABEL='" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "'>\n";
                    foreach ($lstruct as $did => $dstruct) {
                        if ($did != 'desc') {
                            echo "<option value='{$lid},{$did}'>" . $lstruct['desc']['lname'] . ": " . $dstruct['desc']['dname'] . "</option>";
                        }
                    }
                    echo "</OPTGROUP>\n";
                } else {
                    echo "<option value='{$lid}'>" . $lstruct['desc']['lname'] . "</option>";
                }
            }
            echo <<<EOQ
      </select></td>
      <td><span id="createBtnTxt" title="{$txtNoRaceSelected}"><button id="createBtn" onclick="createTeam(); return false;" DISABLED>{$txtCreateBtn}</button></td>
EOQ;
        }
        $txtInducements = $lng->getTrn('inducementsCheck', 'TeamCreator');
        $txtPlayerCount = $lng->getTrn('playerCount', 'TeamCreator');
        $txtTotal = $lng->getTrn('total', 'TeamCreator');
        $txtPos = $lng->getTrn('common/pos');
        $txtSkills = $lng->getTrn('common/skills');
        $txtNorm = $lng->getTrn('normal', 'TeamCreator');
        $txtDoub = $lng->getTrn('double', 'TeamCreator');
        $txtDollar = $lng->getTrn('dollar', 'TeamCreator');
        $txtQuantity = $lng->getTrn('quantity', 'TeamCreator');
        $txtSubtotal = $lng->getTrn('subtotal', 'TeamCreator');
        echo <<<EOQ
       <td align="right" id="indTxt">{$txtInducements}:</td>
       <td><input type="checkbox" id="induce" onChange="changeInduce(this.checked)" /><input type="hidden" id="oldInduce" value="false" /></td>
       <td align="right"><b>{$txtPlayerCount}</b>:</td><td><div id="pcnt"></div></td>
       <td align="right"><b>{$txtTotal}</b>:</td><td><div id="total"></div></td>
       </tr></table>
   </div>
   <div class="boxWide">
   <table class="common" id="teamTable">
      <tr class="commonhead">
         <th>{$txtPos}</th>
         <th>MA</th>
         <th>ST</th>
         <th>AG</th>
         <th>Av</th>
         <th>{$txtSkills}</th>
         <th>{$txtNorm}</th>
         <th>{$txtDoub}</th>
         <th>{$txtDollar}</th>
         <th>{$txtQuantity}</th>
         <th>{$txtSubtotal}</th>
      </tr>
   </table>
   </div>
   </form>
EOQ;
    }
Exemple #9
0
                for (var i=0; i<rs.length; i++){
                     if (rs.options[i].value == tdata[trid]["rs"]){
                        rs.selectedIndex = i;
                        break;
                     }
                }
                var types = document.getElementById("tourtype").parentNode; // Must access radio objects in the way
                var TT_FFA = ' . TT_FFA . ';
                var is_FFA = (TT_FFA == tdata[trid]["type"]);
                types.tourtype[0].checked = is_FFA;
                types.tourtype[1].checked = !is_FFA;
                document.getElementById("locked").checked = tdata[trid]["locked"] == 0 ? false : true;
                document.getElementById("allow_sched").checked = tdata[trid]["allow_sched"] == 0 ? false : true;
            }
            </script>';
    list(, , $tdata) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, null, array(T_NODE_TOURNAMENT => array('rs' => 'rs', 'type' => 'type', 'locked' => 'locked', 'allow_sched' => 'allow_sched')));
    $easyconvert = new array_to_js();
    @$easyconvert->add_array($tdata, 'tdata');
    echo $easyconvert->output_all();
    echo HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'trid', array('OTHER' => array('ring' => Coach::T_RING_LOCAL_ADMIN)), array(), array('extra_tags' => array('onChange="adminModTour(this.options[this.selectedIndex].value);"'), 'empty_str' => array(T_NODE_DIVISION => '')));
    ?>
            <br><br>
            Name<br>
            <input type="text" id='name' name="name"><br><br>
            Ranking system &mdash; <?php 
    echo $lng->getTrn('admin/prefixes');
    ?>
<br>
            <select id='rs' name='rs'>
            <?php 
    global $hrs;