forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CL_club.php
203 lines (162 loc) · 4.53 KB
/
CL_club.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?
//************************************************************************
// Leonardo XC Server, https://github.com/leonardoxc/leonardoxc
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// 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 2 of the License.
//
// $Id: CL_club.php,v 1.6 2010/03/14 20:56:09 manolis Exp $
//
//************************************************************************
/*
A "NAC /club / group" is a list of pilots
Group types: regarding membership
1) a pilot must be added/deleted manually to the group
Procedure : Pilots can
a) request addition from the group admin
b) add themsleves automatically to open groups
c) be addded by the admin with no request and no way of declining
d) be addded by the admin with no request BUT with the option of declining / accepting
2) - a pilot can be added automatically to the group by any /all of the following
a) nationallity
b) membership to another group
c) submitting a flight which is any /all of the following
1) in a given county
2) in a given area
3) in a given takeoff
4) in a given date - period
EVENTS / LEAGUES / CATEGORIES / COMPETITIONS
An event may be linked to
1) Time : Year, Months , Dates, Periods,
2) Groups/ clubs
A group/club can have many events (or categories)
An event may include/exclude flights based on
1) Takeoff or area
2) Glider Category
3) Pilot experience
4) Date ( ie weekends)
5) Male / Female
6) Age
7) lat / lon of takeoff
8) various metrics of the flight like :
1) Free distance
2) Free Triangle
3) FAI triangle
4) OLC turnpoints
5) Out and return
7) duration
9) Brand of Glider
The include/exclude can be
1) automatic with no way tha pilot can decide
2) The club admin decides
3) the pilot decides
An event may have its own scoring formula
Inputs to the formula will be
1) Takeoff or area
2) Glider Category
3) Pilot experience
4) Date ( ie weekends)
5) Male / Female
6) Age
7) lat / lon of takeoff
8) various metrics of the flight like :
1) Free distance
2) Free Triangle
3) FAI triangle
4) OLC turnpoints
5) Out and return
6) Height
7) duration
8) Mean speed
9) Max speed
10) turnpoints reached
11) distance form last turnpoint
12) Time
OR use the stantard Leonardo scoring and layout
*/
class club {
var $ID;
var $name;
var $intName;
var $description;
var $intDescription;
var $countryCode;
var $location;
var $intLocation;
var $link;
var $cat;
var $formula;
var $fomulaParameters;
var $valuesArray;
var $gotValues;
function club($id="") {
if ($id!="") {
$this->ID=$id;
}
$this->valuesArray=array("ID","name","intName","description","intDescription",
"countryCode","location","intLocation","link","cat","formula","fomulaParameters");
$this->gotValues=0;
}
function getAttribute($attrName,$forceIntl=-1) {
global $db, $currentlang,$nativeLanguage,$CONFIG_forceIntl;
if (!$this->gotValues) $this->getFromDB();
if ($forceIntl==-1) $forceIntl=$CONFIG_forceIntl ;
$intName="int".strtoupper( substr($attrName,0,1) ).substr($attrName,1);
if ( countryHasLang($this->countryCode,$currentlang) && !$forceIntl ) {
$name=$attrName;
if (!$this->{$name}) $name=$intName;
} else {
$name=$intName;
if (!$this->{$name}) $name=$attrName;
}
return $this->{$name};
}
function getFromDB() {
global $db,$clubsTable;
$res= $db->sql_query("SELECT * FROM $clubsTable WHERE ID=".$this->ID );
if($res <= 0){
echo "Error getting club from DB<BR>";
return;
}
$clubInfo = $db->sql_fetchrow($res);
foreach ($this->valuesArray as $valStr) {
$this->$valStr=$clubInfo["$valStr"];
}
$this->gotValues=1;
}
function putToDB($update=0) {
global $db,$clubsTable;
if ($update) {
$query="REPLACE INTO ";
$fl_id_1="ID,";
$fl_id_2=$this->ID.", ";
}else {
$query="INSERT INTO ";
$fl_id_1="";
$fl_id_2="";
}
$query.=" $clubsTable ( ";
foreach ($this->valuesArray as $valStr) {
$query.= $valStr.",";
}
$query=substr($query,0,-1);
$query.= " ) VALUES ( ";
foreach ($this->valuesArray as $valStr) {
$query.= "'".prep_for_DB($this->$valStr)."',";
}
$query=substr($query,0,-1);
$query.= " ) ";
// echo $query;
$res= $db->sql_query($query);
if($res <= 0){
echo "Error putting club to DB<BR>";
return 0;
}
$this->gotValues=1;
return 1;
}
}
?>