forked from tom2tom/CMSMS-Tourney-Module
/
action.schedule.php
49 lines (45 loc) · 1.35 KB
/
action.schedule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
This file is part of CMS Made Simple module: Tourney.
Copyright (C) 2014-2015 Tom Phane <tpgww@onepost.net>
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';
}
else
$newparms['tmt_message'] = $this->PrettyMessage($res,FALSE);
$this->Redirect($id,'addedit_comp',$returnid,$newparms);
}
$this->Redirect($id, 'defaultadmin', '',
array('tmt_message'=>$this->PrettyMessage('err_missing',FALSE)));
?>