-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.php
executable file
·156 lines (128 loc) · 4.24 KB
/
setup.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
<?php
/*
Plugin Name: Fitness Log
Plugin URI: http://www.ericbonney.com
Description: Fitness training log plugin, designed mostly for triathlon training
Version: .1a
Author: Eric A. Bonney
Author URI: http://www.ericbonney.com
*/
/* Copyright 2009 Eric A. Bonney ([email protected])
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, or
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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Create the tables.
// Table to hold just the main swim, bike, run workouts.
$table = $wpdb->prefix . "flmain";
if( $wpdb->get_var("SHOW TABLES LIKE '$table'") != $table )
{
$structure = "CREATE TABLE $table (
plan_type VARCHAR(1) NOT NULL,
sbr_type VARCHAR(1) NOT NULL,
duration TIME NOT NULL,
seconds INT NOT NULL,
distance FLOAT(6,2) NOT NULL,
pace FLOAT(4,2),
workout_date DATE NOT NULL,
time_of_day TIME DEFAULT '00:00:00',
min_hr INT,
avg_hr INT,
max_hr INT,
notes VARCHAR(500),
user_id BIGINT NOT NULL,
cals_burned INT,
avg_rpms FLOAT(4,2),
PRIMARY KEY(plan_type, sbr_type, workout_date, user_id)
);";
if( $wpdb->query($structure) === false )
add_option("wpfitnesslog_error", $wpdb->last_query);
$wpdb->flush();
}
// Table to hold the overall notes for the day.
$table = $wpdb->prefix . "flblog";
if( $wpdb->get_var("SHOW TABLES LIKE '$table'") != $table )
{
$structure = "CREATE TABLE $table (
blog_date DATE NOT NULL,
user_id BIGINT NOT NULL,
notes VARCHAR(5000),
PRIMARY KEY(user_id, blog_date)
);";
if( $wpdb->query($structure) === false )
add_option("wpfitnesslog_error", $wpdb->last_query);
$wpdb->flush();
}
// Table to hold the actual strenth training workouts performed on a given day.
$table = $wpdb->prefix . "flstrength";
if( $wpdb->get_var("SHOW TABLES LIKE '$table'") != $table )
{
$structure = "CREATE TABLE $table (
exercises_id INT NOT NULL AUTO_INCREMENT,
workout_date DATE NOT NULL,
time_of_day TIME NOT NULL,
duration TIME NOT NULL,
user_id BIGINT NOT NULL,
notes VARCHAR (256),
PRIMARY KEY(exercises_id, workout_date, time_of_day, user_id)
);";
if( $wpdb->query($structure) === false )
add_option("wpfitnesslog_error", $wpdb->last_query);
$wpdb->flush();
}
// Table to hold the different types of strength training exercises possible
$table = $wpdb->prefix . "flexercise_type";
if( $wpdb->get_var("SHOW TABLES LIKE '$table'") != $table )
{
$structure = "CREATE TABLE $table (
exercise_type_id INT NOT NULL AUTO_INCREMENT,
category VARCHAR(25) NOT NULL,
user_id BIGINT NOT NULL,
excercise VARCHAR(25) NOT NULL,
PRIMARY KEY(exercise_type_id, user_id)
);";
if( $wpdb->query($structure) === false )
add_option("wpfitnesslog_error", $wpdb->last_query);
$wpdb->flush();
}
// Table to hold the exercise done in each strength training workout.
$table = $wpdb->prefix . "flexercises";
if( $wpdb->get_var("SHOW TABLES LIKE '$table'") != $table )
{
$structure = "CREATE TABLE $table (
exercises_id INT NOT NULL,
exercise_type_id INT NOT NULL,
sets INT DEFAULT 0,
reps INT DEFAULT 0,
weight INT DEFAULT 0,
user_id BIGINT NOT NULL,
PRIMARY KEY(exercises_id, exercise_type_id, user_id)
);";
if( $wpdb->query($structure) === false )
add_option("wpfitnesslog_error", $wpdb->last_query);
$wpdb->flush();
}
// Table to hold other activities done.
$table = $wpdb->prefix . "ftotheractivities";
if( $wpdb->get_var("SHOW TABLES LIKE '$table'") != $table )
{
$structure = "CREATE TABLE $table (
workout_date DATE NOT NULL,
time_of_day TIME NOT NULL,
activity VARCHAR(30) NOT NULL,
duration TIME,
user_id BIGINT NOT NULL,
PRIMARY KEY(workout_date, time_of_day, user_id)
);";
if( $wpdb->query($structure) === false )
add_option("wpfitnesslog_error", $wpdb->last_query);
}
?>