} else {
                $message = $this->Lang($res);
            }
        } else {
            $err = TRUE;
            $message = $this->Lang('err_list');
        }
        DisplayErrorPage($this, $smarty, $db, $params, $err, $message);
        return;
    }
}
if (!empty($params['message'])) {
    $smarty->assign('message', urldecode($params['message']));
}
$smarty->assign('hidden', $this->CreateInputHidden($id, 'bracket_id', $bracket_id) . $hidden);
$smarty->assign('start_form', $this->CreateFormStart($id, 'default', $returnid));
$smarty->assign('end_form', $this->CreateFormEnd());
$submit = null;
if ($bdata['contact']) {
    //check for match(es) scheduled & unscored
    if ($sch->UnRecorded($bracket_id)) {
        //check for valid address for results
        $funcs = new tmtComm($this);
        if ($funcs->ValidateAddress($bdata['contact'], $bdata['smsprefix'], $bdata['smspattern'])) {
            $submit = $this->CreateInputSubmitDefault($id, 'result', $this->Lang('submit2'));
        }
    }
}
unset($sch);
$smarty->assign('submit', $submit);
$this->ProcessDataTemplate($tpl, TRUE);
        $funcs->DeleteBracket($this, $vals);
    }
} elseif (isset($params['notify'])) {
    $vals = array_flip($params['selitems']);
    //convert strings
    $vals = array_flip($vals);
    if ($vals) {
        $vc = count($vals);
        $fillers = str_repeat('?,', $vc - 1) . '?';
        $pref = cms_db_prefix();
        $sql = 'SELECT match_id,bracket_id FROM ' . $pref . 'module_tmt_matches WHERE bracket_id IN (' . $fillers . ') AND flags=0 AND status<' . Tourney::MRES . ' AND playwhen IS NOT NULL AND ((teamA IS NOT NULL AND teamA>0) OR (teamB IS NOT NULL AND teamB>0))';
        $matches = $db->GetAssoc($sql, $vals);
        if ($matches) {
            $allmsg = '';
            $sql = 'UPDATE ' . $pref . 'module_tmt_matches SET status=' . Tourney::TOLD . ' WHERE match_id=?';
            $funcs = new tmtComm($this);
            foreach ($matches as $mid => $bid) {
                list($res, $errmsg) = $funcs->TellTeams((int) $bid, $mid, 1);
                //1 >> announcement template
                if ($res) {
                    $db->Execute($sql, array($mid));
                } elseif ($errmsg) {
                    if ($allmsg) {
                        $allmsg .= '<br />';
                    }
                    $allmsg .= $errmsg;
                }
            }
            if ($allmsg) {
                $this->Redirect($id, 'defaultadmin', '', array('tmt_message' => $this->PrettyMessage($allmsg, FALSE, FALSE, FALSE)));
            }
            $errmsg = $this->PrettyMessage('err_notice', FALSE);
            if ($errs) {
                $errmsg .= '<br />' . implode('<br />', $errs);
            }
            $newparms['tmt_message'] = $errmsg;
        }
    }
} elseif (isset($params['getscore'])) {
    $newparms = $this->GetEditParms($params, 'resultstab');
    if (!empty($params['rsel'])) {
        $ok = TRUE;
        $sql = 'UPDATE ' . cms_db_prefix() . 'module_tmt_matches SET status=' . Tourney::ASKED . ' WHERE match_id=?';
        $errs = array();
        $ids = array_keys($params['res_status']);
        //match id's
        $funcs = new tmtComm($this);
        foreach ($params['rsel'] as $mid) {
            list($res, $errmsg) = $funcs->TellTeams($params['bracket_id'], $mid, 3, TRUE);
            if ($res) {
                $db->Execute($sql, array($mid));
            } else {
                $ok = FALSE;
                if ($errmsg) {
                    $errs[] = $errmsg;
                } else {
                    $idx = array_search($mid, $ids);
                    $tA = (int) $params['res_teamA'][$idx];
                    $tB = (int) $params['res_teamB'][$idx];
                    if ($tA > 0 && $tB > 0) {
                        $errs[] = sprintf($this->Lang('or_fmt', $this->TeamName($tA), $this->TeamName($tB)));
                    } elseif ($tA > 0) {
     $body[] = $this->Lang('titlewhen') . ' ' . $finished;
     $body[] = '';
 }
 if ($params['comment']) {
     $body[] = $params['comment'];
     //no added line-breaks
     $body[] = '';
 }
 if ($params['sender']) {
     $body[] = $this->Lang('reporter', $params['sender']);
 }
 if ($save) {
     $body[] = '';
     $body[] = $this->Lang('processed');
 }
 $funcs = new tmtComm($this);
 list($res, $errmsg) = $funcs->TellOwner($bracket_id, $params['match'], $body);
 if ($res) {
     $msg = $this->Lang('sentok');
 } else {
     $msg = $this->Lang('notsent');
     if ($errmsg) {
         $msg .= '<br />' . $errmsg;
     }
 }
 if ($save) {
     $sql = 'UPDATE ' . $pref . 'module_tmt_matches SET playwhen=?, score=?,	status=? WHERE match_id=?';
     $db->Execute($sql, array($when, $score, $res, $params['match']));
     $t = $db->GenID($pref . 'module_tmt_history_seq');
     if ($params['sender']) {
         $by = $params['sender'];