Copyright (C) 2014-2015 Tom Phane <*****@*****.**>
Refer to licence and other details at the top of file Tourney.module.php
More info at http://dev.cmsmadesimple.org/projects/tourney
*/
if (!$this->CheckAccess('admod')) {
    $this->Redirect($id, 'defaultadmin', '', array('tmt_message' => $this->PrettyMessage('lackpermission', FALSE)));
}
$bid = $params['bracket_id'];
$pref = cms_db_prefix();
$sql = 'SELECT type FROM ' . $pref . 'module_tmt_brackets WHERE bracket_id=?';
$type = $db->GetOne($sql, array($bid));
if ($type !== FALSE) {
    $sch = new tmtSchedule();
    switch (intval($type)) {
        case Tourney::DETYPE:
            $res = $sch->InitDEMatches($this, $bid);
            break;
        case Tourney::RRTYPE:
            $res = $sch->NextRRMatches($this, $bid);
            break;
        default:
            //case Tourney::KOTYPE:
            $res = $sch->InitKOMatches($this, $bid);
            break;
    }
    unset($sch);
    $newparms = $this->GetEditParms($params, 'matchestab');
    if ($res === TRUE) {
        $sql = 'UPDATE ' . $pref . 'module_tmt_brackets SET chartbuild=1 WHERE bracket_id=?';
        $db->Execute($sql, array($bid));
        $newparms['matchview'] = 'plan';