-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
96 lines (75 loc) · 3.12 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/*
Martial Arts Tournament System (MATS)
Copyright (C) 2015 David Ball (davidmichaelball @ gmail . com) and Ruth Schulz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
require_once('../../tournament_settings.php');
require '../libs/Smarty.class.php';
$smarty = new Smarty;
require 'loginlogout.php';
require_once('DB/DataObject.php');
require 'configDB.php';
require 'utility.php';
$smarty->assign('current_menu', "Main");
if(isset($_POST["Submit"])) {
// make them all inactive first
$tournament = DB_DataObject::factory('tournaments');
$tournament->find();
while ($tournament->fetch()) {
$tournament->active = 0;
$tournament->update();
}
//activate the selected one
$tournament = DB_DataObject::factory('tournaments');
$tournament->tournament_id = $_POST["Active"];
$tournament->find();
$tournament->fetch();
$tournament->active = true;
$tournament->update();
$smarty->clear_cache('registration.tpl');
}
if ($user_access == "admin") {
$tournament = DB_DataObject::factory('tournaments');
$tournament->find();
while ($tournament->fetch()) {
$competitor = DB_DataObject::factory('competitors');
$competitor->tournament_id = $tournament->tournament_id;
$competitor->competitor_count = 0;
$competitor_count = $competitor->find();
$smarty->append('tournaments', array(
'ID' => $tournament->tournament_id,
'NAME' => $tournament->name,
'LOCATION' => $tournament->location,
'DATE_FROM' => $tournament->date_from,
'DATE_TO' => $tournament->date_to,
'ACTIVE' => $tournament->active,
'SCHEDULE_HTML' => stripslashes($tournament->schedule_html),
'COMPETITOR_COUNT' => $competitor_count,
'TOURNAMENT_FORM_PDF' => $tournament->tournament_form_pdf,
'LOGO_NAME' => $tournament->logo_name
));
}
} else {
$competitor = DB_DataObject::factory('competitors');
$competitor->tournament_id = $active_tournament->tournament_id;
$competitor->competitor_count = 0;
$competitor_count = $competitor->find();
$smarty->assign('competitor_count', $competitor_count);
$competitor = DB_DataObject::factory('competitors');
$competitor->tournament_id = $active_tournament->tournament_id;
$competitor->whereAdd("competitors.competitor_count > 0");
$competitor_count = $competitor->find();
$smarty->assign('team_competitor_count', $competitor_count);
}
$smarty->display('index.tpl');
?>