@@ -148,6 +148,12 @@ discard block |
||
148 | 148 | return $statement->fetchAll(PDO::FETCH_CLASS, $returnClass); |
149 | 149 | } |
150 | 150 | |
151 | + /** |
|
152 | + * @param string $returnClass |
|
153 | + * @param string $table |
|
154 | + * @param string[] $columns |
|
155 | + * @param string[] $where |
|
156 | + */ |
|
151 | 157 | public function selectSingle($returnClass, $table, $columns, $where = null) |
152 | 158 | { |
153 | 159 | $statement = $this->selectStatement($table, $columns, $where); |
@@ -215,6 +221,8 @@ discard block |
||
215 | 221 | |
216 | 222 | /** |
217 | 223 | * Use with caution: it is often better to archive items to prevent creating null references. |
224 | + * @param string $table |
|
225 | + * @param string[] $where |
|
218 | 226 | */ |
219 | 227 | public function delete($table, $where) |
220 | 228 | { |
@@ -253,6 +261,9 @@ discard block |
||
253 | 261 | return $table; |
254 | 262 | } |
255 | 263 | |
264 | + /** |
|
265 | + * @param string $table |
|
266 | + */ |
|
256 | 267 | private function tableExists($table) |
257 | 268 | { |
258 | 269 | // todo: implement table check |
@@ -31,37 +31,37 @@ discard block |
||
31 | 31 | $this->disconnect(); |
32 | 32 | } |
33 | 33 | |
34 | - /** |
|
35 | - * Initiate connection to database if not already connected |
|
36 | - * returns bool. |
|
37 | - */ |
|
38 | - public function connect() |
|
39 | - { |
|
40 | - if (!self::$con) { |
|
41 | - $this->db_connection = new PDO("mysql:host=$this->db_host;dbname=$this->db_name", $this->db_user, $this->db_pass); |
|
42 | - // set the PDO error mode to exception |
|
43 | - $this->db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
44 | - } else { |
|
45 | - return true; |
|
46 | - } |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Initiate connection to database if not already connected. |
|
51 | - */ |
|
52 | - public function disconnect() |
|
53 | - { |
|
54 | - if (self::$con) { |
|
55 | - $this->db_connection = null; |
|
56 | - self::$con = false; |
|
57 | - |
|
58 | - return true; |
|
59 | - } else { |
|
60 | - return false; |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - /* SAMPLE EXPECTED DATA |
|
34 | + /** |
|
35 | + * Initiate connection to database if not already connected |
|
36 | + * returns bool. |
|
37 | + */ |
|
38 | + public function connect() |
|
39 | + { |
|
40 | + if (!self::$con) { |
|
41 | + $this->db_connection = new PDO("mysql:host=$this->db_host;dbname=$this->db_name", $this->db_user, $this->db_pass); |
|
42 | + // set the PDO error mode to exception |
|
43 | + $this->db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
44 | + } else { |
|
45 | + return true; |
|
46 | + } |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Initiate connection to database if not already connected. |
|
51 | + */ |
|
52 | + public function disconnect() |
|
53 | + { |
|
54 | + if (self::$con) { |
|
55 | + $this->db_connection = null; |
|
56 | + self::$con = false; |
|
57 | + |
|
58 | + return true; |
|
59 | + } else { |
|
60 | + return false; |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + /* SAMPLE EXPECTED DATA |
|
65 | 65 | |
66 | 66 | $columns = array( |
67 | 67 | "col1", |
@@ -81,65 +81,65 @@ discard block |
||
81 | 81 | |
82 | 82 | **Does not acceot INNER JOIN at the moment** |
83 | 83 | */ |
84 | - public function selectStatement($table, $columns, $where = null, $order = null) |
|
85 | - { |
|
86 | - $table = $this->addPrefix($table); |
|
87 | - |
|
88 | - if (!$this->tableExists($table)) { |
|
89 | - return false; |
|
90 | - } |
|
91 | - |
|
92 | - $sql = 'SELECT '; |
|
93 | - |
|
94 | - $first = true; |
|
95 | - foreach ($columns as $column) { |
|
96 | - if ($first) { |
|
97 | - $first = false; |
|
98 | - $sql .= $column; |
|
99 | - } else { |
|
100 | - $sql .= ', '; |
|
101 | - $sql .= $column; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - $sql .= ' FROM '; |
|
106 | - $sql .= $table; |
|
107 | - |
|
108 | - if ($where) { |
|
109 | - $sql .= ' WHERE '; |
|
110 | - |
|
111 | - $first = true; |
|
112 | - foreach ($where as $condition) { |
|
113 | - if ($first) { |
|
114 | - $first = false; |
|
115 | - $sql .= $condition; |
|
116 | - } else { |
|
117 | - $sql .= ' AND '; |
|
118 | - $sql .= $condition; |
|
119 | - } |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - if ($order) { |
|
124 | - $sql .= ' ORDER BY '; |
|
125 | - |
|
126 | - $first = true; |
|
127 | - foreach ($order as $condition) { |
|
128 | - if ($first) { |
|
129 | - $first = false; |
|
130 | - $sql .= $condition; |
|
131 | - } else { |
|
132 | - $sql .= ', '; |
|
133 | - $sql .= $condition; |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - $statement = $this->db_connection->prepare($sql); |
|
139 | - $statement->execute(); |
|
140 | - |
|
141 | - return $statement; |
|
142 | - } |
|
84 | + public function selectStatement($table, $columns, $where = null, $order = null) |
|
85 | + { |
|
86 | + $table = $this->addPrefix($table); |
|
87 | + |
|
88 | + if (!$this->tableExists($table)) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + |
|
92 | + $sql = 'SELECT '; |
|
93 | + |
|
94 | + $first = true; |
|
95 | + foreach ($columns as $column) { |
|
96 | + if ($first) { |
|
97 | + $first = false; |
|
98 | + $sql .= $column; |
|
99 | + } else { |
|
100 | + $sql .= ', '; |
|
101 | + $sql .= $column; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + $sql .= ' FROM '; |
|
106 | + $sql .= $table; |
|
107 | + |
|
108 | + if ($where) { |
|
109 | + $sql .= ' WHERE '; |
|
110 | + |
|
111 | + $first = true; |
|
112 | + foreach ($where as $condition) { |
|
113 | + if ($first) { |
|
114 | + $first = false; |
|
115 | + $sql .= $condition; |
|
116 | + } else { |
|
117 | + $sql .= ' AND '; |
|
118 | + $sql .= $condition; |
|
119 | + } |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + if ($order) { |
|
124 | + $sql .= ' ORDER BY '; |
|
125 | + |
|
126 | + $first = true; |
|
127 | + foreach ($order as $condition) { |
|
128 | + if ($first) { |
|
129 | + $first = false; |
|
130 | + $sql .= $condition; |
|
131 | + } else { |
|
132 | + $sql .= ', '; |
|
133 | + $sql .= $condition; |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + $statement = $this->db_connection->prepare($sql); |
|
139 | + $statement->execute(); |
|
140 | + |
|
141 | + return $statement; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | public function select($returnClass, $table, $columns, $where = null, $order = null) |
145 | 145 | { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return $statement->fetchObject($returnClass); |
156 | 156 | } |
157 | 157 | |
158 | - /* SAMPLE EXPECTED DATA |
|
158 | + /* SAMPLE EXPECTED DATA |
|
159 | 159 | $data = [ |
160 | 160 | ['field' => "name", 'type' => "string", 'value' => "bob"], |
161 | 161 | ['field' => "age", 'type' => "int", 'value' => "57"], |
@@ -166,72 +166,72 @@ discard block |
||
166 | 166 | TRANSITION TO MYSQLI OR OTHER ANOTHER DRIVER |
167 | 167 | EASILY IN THE FUTURE |
168 | 168 | */ |
169 | - public function insert($table, $data) |
|
170 | - { |
|
171 | - $table = $this->addPrefix($table); |
|
172 | - |
|
173 | - if (!$this->tableExists($table)) { |
|
174 | - return false; |
|
175 | - } |
|
176 | - |
|
177 | - $first = true; |
|
178 | - |
|
179 | - foreach ($data as $item) { |
|
180 | - if ($first) { |
|
181 | - $first = false; |
|
182 | - $fields .= $item['field']; |
|
183 | - $valuesPlaceholder .= ':'.$item['field']; |
|
184 | - } else { |
|
185 | - $fields .= ', '.$item['field']; |
|
186 | - $valuesPlaceholder .= ', :'.$item['field']; |
|
187 | - } |
|
188 | - |
|
189 | - if ($item['type'] == 's' || $item['type'] == 'string') { |
|
190 | - $types .= 's'; |
|
191 | - } elseif ($item['type'] == 'i' || $item['type'] == 'int' || $item['type'] == 'integer') { |
|
192 | - $types .= 'i'; |
|
193 | - } elseif ($item['type'] == 'bit' || $item['type'] == 'bool' || $item['type'] == 'boolean') { |
|
194 | - $types .= 'i'; |
|
195 | - } elseif ($item['type'] == 'd' || $item['type'] == 'double') { |
|
196 | - $types .= 'd'; |
|
197 | - } elseif ($item['type'] == 'b' || $item['type'] == 'blob') { |
|
198 | - $types .= 'b'; |
|
199 | - } else { |
|
200 | - return false; |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - $statement = $this->db_connection->prepare('INSERT INTO '.$table.' ('.$fields.') VALUES ('.$valuesPlaceholder.')'); |
|
205 | - foreach ($data as $item) { |
|
206 | - $statement->bindParam(':'.$item['field'], $item['value']); |
|
207 | - } |
|
208 | - |
|
209 | - if ($statement->execute()) { |
|
210 | - return true; |
|
211 | - } else { |
|
212 | - return false; |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Use with caution: it is often better to archive items to prevent creating null references. |
|
218 | - */ |
|
219 | - public function delete($table, $where) |
|
220 | - { |
|
221 | - $table = $this->addPrefix($table); |
|
222 | - |
|
223 | - if (!$this->tableExists($table)) { |
|
224 | - return false; |
|
225 | - } |
|
226 | - |
|
227 | - $sql = 'DELETE FROM '; |
|
228 | - $sql .= $table; |
|
229 | - $sql .= ' WHERE '; |
|
230 | - foreach ($where as $condition) { |
|
231 | - $sql .= $condition; |
|
232 | - } |
|
233 | - |
|
234 | - $statement = $this->db_connection->prepare($sql); |
|
169 | + public function insert($table, $data) |
|
170 | + { |
|
171 | + $table = $this->addPrefix($table); |
|
172 | + |
|
173 | + if (!$this->tableExists($table)) { |
|
174 | + return false; |
|
175 | + } |
|
176 | + |
|
177 | + $first = true; |
|
178 | + |
|
179 | + foreach ($data as $item) { |
|
180 | + if ($first) { |
|
181 | + $first = false; |
|
182 | + $fields .= $item['field']; |
|
183 | + $valuesPlaceholder .= ':'.$item['field']; |
|
184 | + } else { |
|
185 | + $fields .= ', '.$item['field']; |
|
186 | + $valuesPlaceholder .= ', :'.$item['field']; |
|
187 | + } |
|
188 | + |
|
189 | + if ($item['type'] == 's' || $item['type'] == 'string') { |
|
190 | + $types .= 's'; |
|
191 | + } elseif ($item['type'] == 'i' || $item['type'] == 'int' || $item['type'] == 'integer') { |
|
192 | + $types .= 'i'; |
|
193 | + } elseif ($item['type'] == 'bit' || $item['type'] == 'bool' || $item['type'] == 'boolean') { |
|
194 | + $types .= 'i'; |
|
195 | + } elseif ($item['type'] == 'd' || $item['type'] == 'double') { |
|
196 | + $types .= 'd'; |
|
197 | + } elseif ($item['type'] == 'b' || $item['type'] == 'blob') { |
|
198 | + $types .= 'b'; |
|
199 | + } else { |
|
200 | + return false; |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + $statement = $this->db_connection->prepare('INSERT INTO '.$table.' ('.$fields.') VALUES ('.$valuesPlaceholder.')'); |
|
205 | + foreach ($data as $item) { |
|
206 | + $statement->bindParam(':'.$item['field'], $item['value']); |
|
207 | + } |
|
208 | + |
|
209 | + if ($statement->execute()) { |
|
210 | + return true; |
|
211 | + } else { |
|
212 | + return false; |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Use with caution: it is often better to archive items to prevent creating null references. |
|
218 | + */ |
|
219 | + public function delete($table, $where) |
|
220 | + { |
|
221 | + $table = $this->addPrefix($table); |
|
222 | + |
|
223 | + if (!$this->tableExists($table)) { |
|
224 | + return false; |
|
225 | + } |
|
226 | + |
|
227 | + $sql = 'DELETE FROM '; |
|
228 | + $sql .= $table; |
|
229 | + $sql .= ' WHERE '; |
|
230 | + foreach ($where as $condition) { |
|
231 | + $sql .= $condition; |
|
232 | + } |
|
233 | + |
|
234 | + $statement = $this->db_connection->prepare($sql); |
|
235 | 235 | |
236 | 236 | // todo: restructure where clause and bind parameters |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } else { |
241 | 241 | return false; |
242 | 242 | } |
243 | - } |
|
243 | + } |
|
244 | 244 | |
245 | 245 | public function update() |
246 | 246 | { |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | public function count($table, $column, $where = null) |
273 | 273 | { |
274 | 274 | $columns = [ |
275 | - 'COUNT('.$column.') AS count', |
|
276 | - ]; |
|
275 | + 'COUNT('.$column.') AS count', |
|
276 | + ]; |
|
277 | 277 | $statement = $this->selectStatement($table, $columns, $where); |
278 | 278 | |
279 | 279 | return $statement->fetchObject()->count; |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | if ($first) { |
181 | 181 | $first = false; |
182 | 182 | $fields .= $item['field']; |
183 | - $valuesPlaceholder .= ':'.$item['field']; |
|
183 | + $valuesPlaceholder .= ':' . $item['field']; |
|
184 | 184 | } else { |
185 | - $fields .= ', '.$item['field']; |
|
186 | - $valuesPlaceholder .= ', :'.$item['field']; |
|
185 | + $fields .= ', ' . $item['field']; |
|
186 | + $valuesPlaceholder .= ', :' . $item['field']; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | if ($item['type'] == 's' || $item['type'] == 'string') { |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - $statement = $this->db_connection->prepare('INSERT INTO '.$table.' ('.$fields.') VALUES ('.$valuesPlaceholder.')'); |
|
204 | + $statement = $this->db_connection->prepare('INSERT INTO ' . $table . ' (' . $fields . ') VALUES (' . $valuesPlaceholder . ')'); |
|
205 | 205 | foreach ($data as $item) { |
206 | - $statement->bindParam(':'.$item['field'], $item['value']); |
|
206 | + $statement->bindParam(':' . $item['field'], $item['value']); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | if ($statement->execute()) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | private function addPrefix($table) |
250 | 250 | { |
251 | - $table = $this->db_prefix.$table; |
|
251 | + $table = $this->db_prefix . $table; |
|
252 | 252 | |
253 | 253 | return $table; |
254 | 254 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | public function count($table, $column, $where = null) |
273 | 273 | { |
274 | 274 | $columns = [ |
275 | - 'COUNT('.$column.') AS count', |
|
275 | + 'COUNT(' . $column . ') AS count', |
|
276 | 276 | ]; |
277 | 277 | $statement = $this->selectStatement($table, $columns, $where); |
278 | 278 |
@@ -196,7 +196,7 @@ |
||
196 | 196 | /** |
197 | 197 | * Determine if the user is marked as available for an event. |
198 | 198 | * |
199 | - * @return bool if user is available |
|
199 | + * @return null|boolean if user is available |
|
200 | 200 | */ |
201 | 201 | public function isAvailableForEvent(Event $event) |
202 | 202 | { |
@@ -19,31 +19,31 @@ discard block |
||
19 | 19 | class User extends BaseUser |
20 | 20 | { |
21 | 21 | /** |
22 | - * Set the value of [password] column. |
|
23 | - * |
|
24 | - * @param string $v new value |
|
25 | - * |
|
26 | - * @return $this|\User The current object (for fluent API support) |
|
27 | - */ |
|
28 | - public function setPassword($v) |
|
29 | - { |
|
30 | - if ($v !== null) { |
|
31 | - $v = (string) $v; |
|
32 | - } |
|
33 | - |
|
34 | - if (!password_verify($v, $this->password)) { |
|
35 | - $bcrypt_options = [ |
|
22 | + * Set the value of [password] column. |
|
23 | + * |
|
24 | + * @param string $v new value |
|
25 | + * |
|
26 | + * @return $this|\User The current object (for fluent API support) |
|
27 | + */ |
|
28 | + public function setPassword($v) |
|
29 | + { |
|
30 | + if ($v !== null) { |
|
31 | + $v = (string) $v; |
|
32 | + } |
|
33 | + |
|
34 | + if (!password_verify($v, $this->password)) { |
|
35 | + $bcrypt_options = [ |
|
36 | 36 | 'cost' => 12, |
37 | - ]; |
|
38 | - $this->password = password_hash($v, PASSWORD_BCRYPT, $bcrypt_options); |
|
37 | + ]; |
|
38 | + $this->password = password_hash($v, PASSWORD_BCRYPT, $bcrypt_options); |
|
39 | 39 | |
40 | - $this->modifiedColumns[UserTableMap::COL_PASSWORD] = true; |
|
41 | - } |
|
40 | + $this->modifiedColumns[UserTableMap::COL_PASSWORD] = true; |
|
41 | + } |
|
42 | 42 | |
43 | - return $this; |
|
44 | - } |
|
43 | + return $this; |
|
44 | + } |
|
45 | 45 | |
46 | - // setPassword() |
|
46 | + // setPassword() |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Check a plain text password against the value of [password] column. |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | return password_verify($v, $this->password); |
64 | 64 | } |
65 | 65 | |
66 | - // checkPassword() |
|
66 | + // checkPassword() |
|
67 | 67 | |
68 | 68 | public function isAdmin() |
69 | 69 | { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getName() |
79 | 79 | { |
80 | - return $this->firstname.' '.$this->lastname; |
|
80 | + return $this->firstname . ' ' . $this->lastname; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | if ($socialAuth->getPlatform() == 'facebook') { |
97 | 97 | switch ($size) { |
98 | 98 | case 'small': // 50px x 50px |
99 | - return '//graph.facebook.com/'.$socialAuth->getSocialId().'/picture?type=square'; |
|
99 | + return '//graph.facebook.com/' . $socialAuth->getSocialId() . '/picture?type=square'; |
|
100 | 100 | break; |
101 | 101 | case 'medium': // 200px x 200px |
102 | - return '//graph.facebook.com/'.$socialAuth->getSocialId().'/picture?type=large'; |
|
102 | + return '//graph.facebook.com/' . $socialAuth->getSocialId() . '/picture?type=large'; |
|
103 | 103 | break; |
104 | 104 | case 'large': // 200px x 200px |
105 | - return '//graph.facebook.com/'.$socialAuth->getSocialId().'/picture?type=large'; |
|
105 | + return '//graph.facebook.com/' . $socialAuth->getSocialId() . '/picture?type=large'; |
|
106 | 106 | break; |
107 | 107 | default: |
108 | - return '//graph.facebook.com/'.$socialAuth->getSocialId().'/picture'; |
|
108 | + return '//graph.facebook.com/' . $socialAuth->getSocialId() . '/picture'; |
|
109 | 109 | break; |
110 | 110 | } |
111 | 111 | } elseif ($socialAuth->getPlatform() == 'onebody') { |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | $extension = pathinfo($socialAuth->getMeta()['photo-file-name'], PATHINFO_EXTENSION); |
115 | 115 | switch ($size) { |
116 | 116 | case 'small': // 50px x 50px |
117 | - return $baseUrl.'/system/production/people/photos/'.$socialAuth->getSocialId().'/tn/'.$photoFingerprint.'.'.$extension; |
|
117 | + return $baseUrl . '/system/production/people/photos/' . $socialAuth->getSocialId() . '/tn/' . $photoFingerprint . '.' . $extension; |
|
118 | 118 | break; |
119 | 119 | case 'medium': // 150px x 150px |
120 | - return $baseUrl.'/system/production/people/photos/'.$socialAuth->getSocialId().'/small/'.$photoFingerprint.'.'.$extension; |
|
120 | + return $baseUrl . '/system/production/people/photos/' . $socialAuth->getSocialId() . '/small/' . $photoFingerprint . '.' . $extension; |
|
121 | 121 | break; |
122 | 122 | case 'large': // 500px x 500px |
123 | - return $baseUrl.'/system/production/people/photos/'.$socialAuth->getSocialId().'/medium/'.$photoFingerprint.'.'.$extension; |
|
123 | + return $baseUrl . '/system/production/people/photos/' . $socialAuth->getSocialId() . '/medium/' . $photoFingerprint . '.' . $extension; |
|
124 | 124 | break; |
125 | 125 | default: |
126 | - return $baseUrl.'/system/production/people/photos/'.$socialAuth->getSocialId().'/tn/'.$photoFingerprint.'.'.$extension; |
|
126 | + return $baseUrl . '/system/production/people/photos/' . $socialAuth->getSocialId() . '/tn/' . $photoFingerprint . '.' . $extension; |
|
127 | 127 | break; |
128 | 128 | } |
129 | 129 | } |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | |
133 | 133 | switch ($size) { |
134 | 134 | case 'small': // 50px x 50px |
135 | - return '//www.gravatar.com/avatar/'.md5(strtolower(trim($this->email))).'?s=50&d=mm'; |
|
135 | + return '//www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?s=50&d=mm'; |
|
136 | 136 | break; |
137 | 137 | case 'medium': // 200px x 200px |
138 | - return '//www.gravatar.com/avatar/'.md5(strtolower(trim($this->email))).'?s=200&d=mm'; |
|
138 | + return '//www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?s=200&d=mm'; |
|
139 | 139 | break; |
140 | 140 | case 'large': // 500px x 500px |
141 | - return '//www.gravatar.com/avatar/'.md5(strtolower(trim($this->email))).'?s=500&d=mm'; |
|
141 | + return '//www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?s=500&d=mm'; |
|
142 | 142 | break; |
143 | 143 | default: |
144 | - return '//www.gravatar.com/avatar/'.md5(strtolower(trim($this->email))).'?s=50&d=mm'; |
|
144 | + return '//www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?s=50&d=mm'; |
|
145 | 145 | break; |
146 | 146 | } |
147 | 147 | } |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace TechWilk\Rota; |
4 | 4 | |
5 | -use DateTime; |
|
6 | - |
|
7 | 5 | /* |
8 | 6 | This file is part of Church Rota. |
9 | 7 |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | function executeDbSql($sql) |
27 | 27 | { |
28 | 28 | if (!mysqli_query(db(), $sql)) { |
29 | - die('Error: '.mysqli_error(db()).', SQL: '.$sql); |
|
29 | + die('Error: ' . mysqli_error(db()) . ', SQL: ' . $sql); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | function updateDatabase() |
34 | 34 | { |
35 | 35 | $sql = 'SELECT VERSION( ) AS mysqli_version'; |
36 | - $result = mysqli_query(db(), $sql) or die('MySQL-Error: '.mysqli_error(db())); |
|
36 | + $result = mysqli_query(db(), $sql) or die('MySQL-Error: ' . mysqli_error(db())); |
|
37 | 37 | $dbv = mysqli_fetch_array($result, MYSQLI_ASSOC); |
38 | 38 | $mysqli_version = $dbv['mysqli_version']; |
39 | 39 | //echo $mysqli_version."<br>"; |
@@ -87,41 +87,41 @@ discard block |
||
87 | 87 | executeDbSql("alter table cr_users add(isOverviewRecipient char(2) NOT NULL DEFAULT '0')"); |
88 | 88 | executeDbSql('alter table cr_groups add(short_name char(2))'); |
89 | 89 | |
90 | - executeDbSql("update cr_settings set lang_locale = 'en_GB'"); // de_DE |
|
90 | + executeDbSql("update cr_settings set lang_locale = 'en_GB'"); // de_DE |
|
91 | 91 | executeDbSql('update cr_settings set event_sorting_latest = 0'); |
92 | 92 | executeDbSql('update cr_settings set snapshot_show_two_month = 0'); |
93 | 93 | executeDbSql('update cr_settings set snapshot_reduce_skills_by_group = 0'); |
94 | 94 | executeDbSql('update cr_settings set logged_in_show_snapshot_button = 0'); |
95 | 95 | executeDbSql("update cr_settings set time_format_long = '%A, %B %e @ %I:%M %p'"); // de_DE: %A, %e. %B %Y, %R Uhr, KW%V |
96 | 96 | executeDbSql("update cr_settings set time_format_normal = '%m/%d/%y %I:%M %p'"); // de_DE: %d.%m.%Y %H:%M |
97 | - executeDbSql("update cr_settings set time_format_short = '%a, <strong>%b %e</strong>, %I:%M %p'"); // de_DE: %a, <strong>%e. %b</strong>, KW%V |
|
97 | + executeDbSql("update cr_settings set time_format_short = '%a, <strong>%b %e</strong>, %I:%M %p'"); // de_DE: %a, <strong>%e. %b</strong>, KW%V |
|
98 | 98 | executeDbSql("update cr_settings set version = '2.1.0'"); |
99 | 99 | executeDbSql('update cr_settings set users_start_with_myevents = 0'); |
100 | 100 | executeDbSql("update cr_settings set time_zone = 'Europe/London'"); //de_DE: Europe/Berlin |
101 | 101 | executeDbSql("update cr_settings set google_group_calendar = ''"); |
102 | 102 | executeDbSql("update cr_settings set overviewemail = 'Hello,\r\n\r\nIn this email you find the Rota for [MONTH] [YEAR].\r\n\r\n[OVERVIEW]\r\n\r\nPlease inform us as soon as possible, if you are not able to serve as scheduled.\r\n\r\nBe blessed.\r\nChurch Support Stuff'"); |
103 | 103 | |
104 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.1.0', $_SESSION['userid']); |
|
104 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.1.0', $_SESSION['userid']); |
|
105 | 105 | case '2.1.0': |
106 | 106 | executeDbSql('create table cr_settings_bkp2_1_0 as select * from cr_settings'); |
107 | 107 | executeDbSql('alter table cr_settings add(group_sorting_name int(1))'); |
108 | 108 | executeDbSql("update cr_settings set version = '2.1.1'"); |
109 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.1.1', $_SESSION['userid']); |
|
109 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.1.1', $_SESSION['userid']); |
|
110 | 110 | case '2.1.1': |
111 | 111 | executeDbSql("update cr_settings set version = '2.1.2'"); |
112 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.1.2', $_SESSION['userid']); |
|
112 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.1.2', $_SESSION['userid']); |
|
113 | 113 | case '2.1.2': |
114 | 114 | executeDbSql("alter table cr_settings add(debug_mode int(1) DEFAULT '0')"); |
115 | - executeDbSql('update cr_settings set group_sorting_name = 0'); //was a workaround, fixed in V2.2.1 |
|
115 | + executeDbSql('update cr_settings set group_sorting_name = 0'); //was a workaround, fixed in V2.2.1 |
|
116 | 116 | |
117 | 117 | executeDbSql("update cr_settings set version = '2.2.0'"); |
118 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.2.0', $_SESSION['userid']); |
|
118 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.2.0', $_SESSION['userid']); |
|
119 | 119 | case '2.2.0': |
120 | 120 | executeDbSql("alter table cr_users add(isBandAdmin char(2) NOT NULL DEFAULT '0')"); |
121 | 121 | executeDbSql('update cr_settings set group_sorting_name = 0'); //due to an error reset it again |
122 | 122 | |
123 | 123 | executeDbSql("update cr_settings set version = '2.2.1'"); |
124 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.2.1', $_SESSION['userid']); |
|
124 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.2.1', $_SESSION['userid']); |
|
125 | 125 | case '2.2.1': |
126 | 126 | $sql = "CREATE TABLE IF NOT EXISTS `cr_statistics` ( |
127 | 127 | `id` int(11) NOT NULL AUTO_INCREMENT, |
@@ -137,21 +137,21 @@ discard block |
||
137 | 137 | executeDbSql($sql); |
138 | 138 | |
139 | 139 | executeDbSql("update cr_settings set version = '2.3.0'"); |
140 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.3.0', $_SESSION['userid']); |
|
140 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.3.0', $_SESSION['userid']); |
|
141 | 141 | insertStatistics('system', __FILE__, 'db-update', '2.3.0', $version); |
142 | 142 | case '2.3.0': |
143 | 143 | executeDbSql("alter table cr_users add(isEventEditor char(2) NOT NULL DEFAULT '0')"); |
144 | 144 | |
145 | 145 | executeDbSql("update cr_settings set version = '2.3.1'"); |
146 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.3.1', $_SESSION['userid']); |
|
146 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.3.1', $_SESSION['userid']); |
|
147 | 147 | insertStatistics('system', __FILE__, 'db-update', '2.3.1', $version); |
148 | 148 | case '2.3.1': |
149 | 149 | executeDbSql("update cr_settings set version = '2.3.2'"); |
150 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.3.2', $_SESSION['userid']); |
|
150 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.3.2', $_SESSION['userid']); |
|
151 | 151 | insertStatistics('system', __FILE__, 'db-update', '2.3.2', $version); |
152 | 152 | case '2.3.2': |
153 | 153 | executeDbSql("update cr_settings set version = '2.3.3'"); |
154 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.3.3', $_SESSION['userid']); |
|
154 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.3.3', $_SESSION['userid']); |
|
155 | 155 | insertStatistics('system', __FILE__, 'db-update', '2.3.3', $version); |
156 | 156 | case '2.3.3': |
157 | 157 | if (substr($mysqli_version, 0, 1) == 5) { |
@@ -199,33 +199,33 @@ discard block |
||
199 | 199 | ); |
200 | 200 | } |
201 | 201 | executeDbSql("update cr_settings set version = '2.3.4'"); |
202 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.3.4', $_SESSION['userid']); |
|
202 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.3.4', $_SESSION['userid']); |
|
203 | 203 | insertStatistics('system', __FILE__, 'db-update', '2.3.4', $version); |
204 | 204 | case '2.3.4': |
205 | 205 | executeDbSql("update cr_settings set version = '2.3.5'"); |
206 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.3.5', $_SESSION['userid']); |
|
206 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.3.5', $_SESSION['userid']); |
|
207 | 207 | insertStatistics('system', __FILE__, 'db-update', '2.3.5', $version); |
208 | 208 | case '2.3.5': |
209 | 209 | executeDbSql("update cr_settings set version = '2.4.0'"); |
210 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.4.0', $_SESSION['userid']); |
|
210 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.4.0', $_SESSION['userid']); |
|
211 | 211 | insertStatistics('system', __FILE__, 'db-update', '2.4.0', $version); |
212 | 212 | case '2.4.0': |
213 | 213 | executeDbSql("update cr_settings set version = '2.4.1'"); |
214 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.4.1', $_SESSION['userid']); |
|
214 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.4.1', $_SESSION['userid']); |
|
215 | 215 | insertStatistics('system', __FILE__, 'db-update', '2.4.1', $version); |
216 | 216 | case '2.4.1': |
217 | 217 | executeDbSql('alter table cr_settings add(days_to_alert int(2) DEFAULT 5) '); |
218 | 218 | executeDbSql("alter table cr_settings add(token varchar(100) DEFAULT '') "); |
219 | 219 | executeDbSql("update cr_settings set version = '2.4.2'"); |
220 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.4.2', $_SESSION['userid']); |
|
220 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.4.2', $_SESSION['userid']); |
|
221 | 221 | insertStatistics('system', __FILE__, 'db-update', '2.4.2', $version); |
222 | 222 | case '2.4.2': |
223 | 223 | executeDbSql("update cr_settings set version = '2.4.3'"); |
224 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.4.3', $_SESSION['userid']); |
|
224 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.4.3', $_SESSION['userid']); |
|
225 | 225 | insertStatistics('system', __FILE__, 'db-update', '2.4.3', $version); |
226 | 226 | case '2.4.3': |
227 | 227 | executeDbSql("update cr_settings set version = '2.4.4'"); |
228 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.4.4', $_SESSION['userid']); |
|
228 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.4.4', $_SESSION['userid']); |
|
229 | 229 | insertStatistics('system', __FILE__, 'db-update', '2.4.4', $version); |
230 | 230 | case '2.4.4': |
231 | 231 | if (substr($mysqli_version, 0, 1) == 5) { |
@@ -274,27 +274,27 @@ discard block |
||
274 | 274 | ); |
275 | 275 | } |
276 | 276 | executeDbSql("update cr_settings set version = '2.4.5'"); |
277 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.4.5', $_SESSION['userid']); |
|
277 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.4.5', $_SESSION['userid']); |
|
278 | 278 | insertStatistics('system', __FILE__, 'db-update', '2.4.5', $version); |
279 | 279 | case '2.4.5': |
280 | 280 | executeDbSql("update cr_settings set version = '2.5.0'"); |
281 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.5.0', $_SESSION['userid']); |
|
281 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.5.0', $_SESSION['userid']); |
|
282 | 282 | insertStatistics('system', __FILE__, 'db-update', '2.5.0', $version); |
283 | 283 | case '2.5.0': |
284 | 284 | executeDbSql("update cr_settings set version = '2.5.1'"); |
285 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.5.1', $_SESSION['userid']); |
|
285 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.5.1', $_SESSION['userid']); |
|
286 | 286 | insertStatistics('system', __FILE__, 'db-update', '2.5.1', $version); |
287 | 287 | case '2.5.1': |
288 | 288 | executeDbSql("update cr_settings set version = '2.5.2'"); |
289 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.5.2', $_SESSION['userid']); |
|
289 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.5.2', $_SESSION['userid']); |
|
290 | 290 | insertStatistics('system', __FILE__, 'db-update', '2.5.2', $version); |
291 | 291 | case '2.5.2': |
292 | 292 | executeDbSql("update cr_settings set version = '2.5.3'"); |
293 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.5.3', $_SESSION['userid']); |
|
293 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.5.3', $_SESSION['userid']); |
|
294 | 294 | insertStatistics('system', __FILE__, 'db-update', '2.5.3', $version); |
295 | 295 | case '2.5.3': |
296 | 296 | executeDbSql("update cr_settings set version = '2.6.0'"); |
297 | - notifyInfo(__FILE__, 'db-update='.$version.'->2.6.0', $_SESSION['userid']); |
|
297 | + notifyInfo(__FILE__, 'db-update=' . $version . '->2.6.0', $_SESSION['userid']); |
|
298 | 298 | insertStatistics('system', __FILE__, 'db-update', '2.6.0', $version); |
299 | 299 | case '2.6.0': |
300 | 300 | $sql = "ALTER TABLE cr_users |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | executeDbSql($sql); |
371 | 371 | executeDbSql("update cr_settings set version = '3.0.0-pre1'"); |
372 | 372 | |
373 | - notifyInfo(__FILE__, 'db-update='.$version.'->3.0.0-pre1', $_SESSION['userid']); |
|
373 | + notifyInfo(__FILE__, 'db-update=' . $version . '->3.0.0-pre1', $_SESSION['userid']); |
|
374 | 374 | insertStatistics('system', __FILE__, 'db-update', '3.0.0-pre1', $version); |
375 | 375 | case '3.0.0-pre1': |
376 | 376 | $sql = "CREATE TABLE IF NOT EXISTS cr_notifications ( |
@@ -119,6 +119,9 @@ |
||
119 | 119 | return true; |
120 | 120 | } |
121 | 121 | |
122 | + /** |
|
123 | + * @param EmailAddress $username |
|
124 | + */ |
|
122 | 125 | private function numberOfLoginAttemptsIsOk($username) |
123 | 126 | { |
124 | 127 | $numberOfAllowedAttempts = 8; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $location = $event->getLocation(); |
83 | 83 | |
84 | 84 | $data = [ |
85 | - 'data' => [ |
|
85 | + 'data' => [ |
|
86 | 86 | 'id' => $event->getId(), |
87 | 87 | 'name' => $event->name, |
88 | 88 | 'date' => $event->datetime, |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | 'related' => '/events/'.$event->getId().'/series/'.$series->getId(), |
96 | 96 | ], |
97 | 97 | 'data' => [ |
98 | - 'type' => 'series', |
|
99 | - 'id' => $series->getId(), |
|
98 | + 'type' => 'series', |
|
99 | + 'id' => $series->getId(), |
|
100 | 100 | ], |
101 | 101 | ], |
102 | 102 | 'types' => [ |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | 'related' => '/events/'.$event->getId().'/types/'.$type->getId(), |
106 | 106 | ], |
107 | 107 | 'data' => [ |
108 | - 'type' => 'types', |
|
109 | - 'id' => $type->getId(), |
|
108 | + 'type' => 'types', |
|
109 | + 'id' => $type->getId(), |
|
110 | 110 | ], |
111 | 111 | ], |
112 | 112 | 'sub-types' => [ |
@@ -130,56 +130,56 @@ discard block |
||
130 | 130 | ], |
131 | 131 | ], |
132 | 132 | ], |
133 | - ], |
|
134 | - 'included' => [ |
|
135 | - [ |
|
133 | + ], |
|
134 | + 'included' => [ |
|
135 | + [ |
|
136 | 136 | 'type' => 'series', |
137 | 137 | 'id' => $series->getId(), |
138 | 138 | 'attributes' => [ |
139 | - 'name' => $series->name, |
|
140 | - 'description' => $series->description, |
|
139 | + 'name' => $series->name, |
|
140 | + 'description' => $series->description, |
|
141 | 141 | ], |
142 | 142 | 'links' => [ |
143 | 143 | 'self' => '/series/'.$series->getId(), |
144 | 144 | ], |
145 | - ], |
|
146 | - [ |
|
145 | + ], |
|
146 | + [ |
|
147 | 147 | 'type' => 'types', |
148 | 148 | 'id' => $type->getId(), |
149 | 149 | 'attributes' => [ |
150 | - 'name' => $type->name, |
|
151 | - 'description' => $type->description, |
|
150 | + 'name' => $type->name, |
|
151 | + 'description' => $type->description, |
|
152 | 152 | ], |
153 | 153 | 'links' => [ |
154 | 154 | 'self' => '/types/'.$type->getId(), |
155 | 155 | ], |
156 | - ], |
|
157 | - [ |
|
156 | + ], |
|
157 | + [ |
|
158 | 158 | 'type' => 'sub-types', |
159 | 159 | 'id' => $sub_type->getId(), |
160 | 160 | 'attributes' => [ |
161 | - 'name' => $sub_type->name, |
|
162 | - 'description' => $sub_type->description, |
|
161 | + 'name' => $sub_type->name, |
|
162 | + 'description' => $sub_type->description, |
|
163 | 163 | ], |
164 | 164 | 'links' => [ |
165 | 165 | 'self' => '/sub-types/'.$sub_type->getId(), |
166 | 166 | ], |
167 | - ], |
|
168 | - [ |
|
167 | + ], |
|
168 | + [ |
|
169 | 169 | 'type' => 'locations', |
170 | 170 | 'id' => $location->getId(), |
171 | 171 | 'attributes' => [ |
172 | - 'name' => $location->name, |
|
172 | + 'name' => $location->name, |
|
173 | 173 | ], |
174 | 174 | 'links' => [ |
175 | 175 | 'self' => '/locations/'.$location->getId(), |
176 | 176 | ], |
177 | - ], |
|
178 | - ], |
|
179 | - 'meta' => [ |
|
177 | + ], |
|
178 | + ], |
|
179 | + 'meta' => [ |
|
180 | 180 | 'status' => '200', |
181 | - ], |
|
182 | - ]; |
|
181 | + ], |
|
182 | + ]; |
|
183 | 183 | |
184 | 184 | return $response->withJson($data, 200); |
185 | 185 | }); |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | $series->createInDb($this->db); |
200 | 200 | |
201 | 201 | $data = [ |
202 | - 'data' => [ |
|
202 | + 'data' => [ |
|
203 | 203 | 'id' => $series->getId(), |
204 | 204 | 'name' => $series->name, |
205 | 205 | 'description' => $series->description, |
206 | 206 | ], |
207 | - ]; |
|
207 | + ]; |
|
208 | 208 | |
209 | 209 | return $response->withJson($data); |
210 | 210 | }); |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | $series->getFromDbWithId($this->db, $id); |
217 | 217 | |
218 | 218 | $data = [ |
219 | - 'data' => [ |
|
219 | + 'data' => [ |
|
220 | 220 | 'id' => $series->getId(), |
221 | 221 | 'name' => $series->name, |
222 | 222 | 'description' => $series->description, |
223 | 223 | ], |
224 | - ]; |
|
224 | + ]; |
|
225 | 225 | |
226 | 226 | return $response->withJson($data); |
227 | 227 | }); |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $series->deleteFromDbWithId($this->db, $id); |
234 | 234 | |
235 | 235 | $data = [ |
236 | - 'data' => [ |
|
236 | + 'data' => [ |
|
237 | 237 | 'id' => $series->getId(), |
238 | 238 | 'archived' => true, |
239 | 239 | ], |
240 | - ]; |
|
240 | + ]; |
|
241 | 241 | |
242 | 242 | return $response->withJson($data); |
243 | 243 | }); |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | $type->createInDb($this->db); |
258 | 258 | |
259 | 259 | $data = [ |
260 | - 'data' => [ |
|
260 | + 'data' => [ |
|
261 | 261 | 'id' => $type->getId(), |
262 | 262 | 'name' => $type->name, |
263 | 263 | 'description' => $type->description, |
264 | 264 | ], |
265 | - ]; |
|
265 | + ]; |
|
266 | 266 | |
267 | 267 | return $response->withJson($data); |
268 | 268 | }); |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | $type->getFromDbWithId($this->db, $id); |
275 | 275 | |
276 | 276 | $data = [ |
277 | - 'data' => [ |
|
277 | + 'data' => [ |
|
278 | 278 | 'id' => $type->getId(), |
279 | 279 | 'name' => $type->name, |
280 | 280 | 'description' => $type->description, |
281 | 281 | ], |
282 | - ]; |
|
282 | + ]; |
|
283 | 283 | |
284 | 284 | return $response->withJson($data); |
285 | 285 | }); |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | $type->deleteFromDbWithId($this->db, $id); |
292 | 292 | |
293 | 293 | $data = [ |
294 | - 'data' => [ |
|
294 | + 'data' => [ |
|
295 | 295 | 'id' => $type->getId(), |
296 | 296 | 'archived' => true, |
297 | 297 | ], |
298 | - ]; |
|
298 | + ]; |
|
299 | 299 | |
300 | 300 | return $response->withJson($data); |
301 | 301 | }); |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | $type->createInDb($this->db); |
316 | 316 | |
317 | 317 | $data = [ |
318 | - 'data' => [ |
|
318 | + 'data' => [ |
|
319 | 319 | 'id' => $type->getId(), |
320 | 320 | 'name' => $type->name, |
321 | 321 | 'description' => $type->description, |
322 | 322 | ], |
323 | - ]; |
|
323 | + ]; |
|
324 | 324 | |
325 | 325 | return $response->withJson($data); |
326 | 326 | }); |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | $type->getFromDbWithId($this->db, $id); |
333 | 333 | |
334 | 334 | $data = [ |
335 | - 'data' => [ |
|
335 | + 'data' => [ |
|
336 | 336 | 'id' => $type->getId(), |
337 | 337 | 'name' => $type->name, |
338 | 338 | 'description' => $type->description, |
339 | 339 | ], |
340 | - ]; |
|
340 | + ]; |
|
341 | 341 | |
342 | 342 | return $response->withJson($data); |
343 | 343 | }); |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | $type->deleteFromDbWithId($this->db, $id); |
350 | 350 | |
351 | 351 | $data = [ |
352 | - 'data' => [ |
|
352 | + 'data' => [ |
|
353 | 353 | 'id' => $type->getId(), |
354 | 354 | 'archived' => true, |
355 | 355 | ], |
356 | - ]; |
|
356 | + ]; |
|
357 | 357 | |
358 | 358 | return $response->withJson($data); |
359 | 359 | }); |
@@ -371,11 +371,11 @@ discard block |
||
371 | 371 | $type->createInDb($this->db); |
372 | 372 | |
373 | 373 | $data = [ |
374 | - 'data' => [ |
|
374 | + 'data' => [ |
|
375 | 375 | 'id' => $location->getId(), |
376 | 376 | 'name' => $location->name, |
377 | 377 | ], |
378 | - ]; |
|
378 | + ]; |
|
379 | 379 | |
380 | 380 | return $response->withJson($data); |
381 | 381 | }); |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | $location->getFromDbWithId($this->db, $id); |
388 | 388 | |
389 | 389 | $data = [ |
390 | - 'data' => [ |
|
390 | + 'data' => [ |
|
391 | 391 | 'id' => $location->getId(), |
392 | 392 | 'name' => $location->name, |
393 | 393 | ], |
394 | - ]; |
|
394 | + ]; |
|
395 | 395 | |
396 | 396 | return $response->withJson($data); |
397 | 397 | }); |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $location->deleteFromDbWithId($this->db, $id); |
404 | 404 | |
405 | 405 | $data = [ |
406 | - 'data' => [ |
|
406 | + 'data' => [ |
|
407 | 407 | 'id' => $location->getId(), |
408 | 408 | 'archived' => true, |
409 | 409 | ], |
410 | - ]; |
|
410 | + ]; |
|
411 | 411 | |
412 | 412 | return $response->withJson($data); |
413 | 413 | }); |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | // Start of API |
24 | 24 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
25 | 25 | |
26 | -require_once dirname(__FILE__).'/../../../vendor/autoload.php'; |
|
26 | +require_once dirname(__FILE__) . '/../../../vendor/autoload.php'; |
|
27 | 27 | |
28 | -include_once dirname(__FILE__).'/../../../config/database.php'; |
|
28 | +include_once dirname(__FILE__) . '/../../../config/database.php'; |
|
29 | 29 | |
30 | 30 | // Create and configure Slim app |
31 | 31 | $app = new \Slim\App(['settings' => $config]); |
32 | 32 | |
33 | -spl_autoload_register(function ($classname) { |
|
34 | - require dirname(__FILE__).'/../../../api-classes/'.$classname.'.php'; |
|
33 | +spl_autoload_register(function($classname) { |
|
34 | + require dirname(__FILE__) . '/../../../api-classes/' . $classname . '.php'; |
|
35 | 35 | }); |
36 | 36 | |
37 | 37 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $container = $app->getContainer(); |
42 | 42 | |
43 | -$container['db'] = function ($c) { |
|
43 | +$container['db'] = function($c) { |
|
44 | 44 | $db_config = $c['settings']['db']; |
45 | 45 | $db = new Database($db_config); |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // ~~~~~~~~~~~~~~~ Event ~~~~~~~~~~~~~~~ |
55 | 55 | |
56 | -$app->post('/events', function ($request, $response, $args) { |
|
56 | +$app->post('/events', function($request, $response, $args) { |
|
57 | 57 | $postData = $request->getParsedBody(); |
58 | 58 | |
59 | 59 | $name = filter_var($postData['name'], FILTER_SANITIZE_STRING); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return $response->withJson($data); |
66 | 66 | }); |
67 | 67 | |
68 | -$app->get('/events/{id}', function ($request, $response, $args) { |
|
68 | +$app->get('/events/{id}', function($request, $response, $args) { |
|
69 | 69 | $id = filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
70 | 70 | |
71 | 71 | $event = new Event(); |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | 'relationships' => [ |
92 | 92 | 'series' => [ |
93 | 93 | 'links' => [ |
94 | - 'self' => '/events/'.$event->getId().'/relationships/series', |
|
95 | - 'related' => '/events/'.$event->getId().'/series/'.$series->getId(), |
|
94 | + 'self' => '/events/' . $event->getId() . '/relationships/series', |
|
95 | + 'related' => '/events/' . $event->getId() . '/series/' . $series->getId(), |
|
96 | 96 | ], |
97 | 97 | 'data' => [ |
98 | 98 | 'type' => 'series', |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | ], |
102 | 102 | 'types' => [ |
103 | 103 | 'links' => [ |
104 | - 'self' => '/events/'.$event->getId().'/relationships/types', |
|
105 | - 'related' => '/events/'.$event->getId().'/types/'.$type->getId(), |
|
104 | + 'self' => '/events/' . $event->getId() . '/relationships/types', |
|
105 | + 'related' => '/events/' . $event->getId() . '/types/' . $type->getId(), |
|
106 | 106 | ], |
107 | 107 | 'data' => [ |
108 | 108 | 'type' => 'types', |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | ], |
112 | 112 | 'sub-types' => [ |
113 | 113 | 'links' => [ |
114 | - 'self' => '/events/'.$event->getId().'/relationships/sub-types', |
|
115 | - 'related' => '/events/'.$event->getId().'/sub-types/'.$sub_type->getId(), |
|
114 | + 'self' => '/events/' . $event->getId() . '/relationships/sub-types', |
|
115 | + 'related' => '/events/' . $event->getId() . '/sub-types/' . $sub_type->getId(), |
|
116 | 116 | ], |
117 | 117 | 'data' => [ |
118 | 118 | 'type' => 'sub-types', |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | ], |
122 | 122 | 'location' => [ |
123 | 123 | 'links' => [ |
124 | - 'self' => '/events/'.$event->getId().'/relationships/locations', |
|
125 | - 'related' => '/events/'.$event->getId().'/locations/'.$location->getId(), |
|
124 | + 'self' => '/events/' . $event->getId() . '/relationships/locations', |
|
125 | + 'related' => '/events/' . $event->getId() . '/locations/' . $location->getId(), |
|
126 | 126 | ], |
127 | 127 | 'data' => [ |
128 | 128 | 'type' => 'locations', |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'description' => $series->description, |
141 | 141 | ], |
142 | 142 | 'links' => [ |
143 | - 'self' => '/series/'.$series->getId(), |
|
143 | + 'self' => '/series/' . $series->getId(), |
|
144 | 144 | ], |
145 | 145 | ], |
146 | 146 | [ |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'description' => $type->description, |
152 | 152 | ], |
153 | 153 | 'links' => [ |
154 | - 'self' => '/types/'.$type->getId(), |
|
154 | + 'self' => '/types/' . $type->getId(), |
|
155 | 155 | ], |
156 | 156 | ], |
157 | 157 | [ |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'description' => $sub_type->description, |
163 | 163 | ], |
164 | 164 | 'links' => [ |
165 | - 'self' => '/sub-types/'.$sub_type->getId(), |
|
165 | + 'self' => '/sub-types/' . $sub_type->getId(), |
|
166 | 166 | ], |
167 | 167 | ], |
168 | 168 | [ |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | 'name' => $location->name, |
173 | 173 | ], |
174 | 174 | 'links' => [ |
175 | - 'self' => '/locations/'.$location->getId(), |
|
175 | + 'self' => '/locations/' . $location->getId(), |
|
176 | 176 | ], |
177 | 177 | ], |
178 | 178 | ], |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | // ~~~~~~~~~~~~~~~ Series ~~~~~~~~~~~~~~~ |
188 | 188 | |
189 | -$app->post('/series', function ($request, $response, $args) { |
|
189 | +$app->post('/series', function($request, $response, $args) { |
|
190 | 190 | $postData = $request->getParsedBody(); |
191 | 191 | |
192 | 192 | $name = filter_var($postData['name'], FILTER_SANITIZE_STRING); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | return $response->withJson($data); |
210 | 210 | }); |
211 | 211 | |
212 | -$app->get('/series/{id}', function ($request, $response, $args) { |
|
212 | +$app->get('/series/{id}', function($request, $response, $args) { |
|
213 | 213 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
214 | 214 | |
215 | 215 | $series = new Series(); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | return $response->withJson($data); |
227 | 227 | }); |
228 | 228 | |
229 | -$app->delete('/series/{id}', function ($request, $response, $args) { |
|
229 | +$app->delete('/series/{id}', function($request, $response, $args) { |
|
230 | 230 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
231 | 231 | |
232 | 232 | $series = new Series(); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | // ~~~~~~~~~~~~~~~ Type ~~~~~~~~~~~~~~~ |
246 | 246 | |
247 | -$app->post('/types', function ($request, $response, $args) { |
|
247 | +$app->post('/types', function($request, $response, $args) { |
|
248 | 248 | $postData = $request->getParsedBody(); |
249 | 249 | |
250 | 250 | $name = filter_var($postData['name'], FILTER_SANITIZE_STRING); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | return $response->withJson($data); |
268 | 268 | }); |
269 | 269 | |
270 | -$app->get('/types/{id}', function ($request, $response, $args) { |
|
270 | +$app->get('/types/{id}', function($request, $response, $args) { |
|
271 | 271 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
272 | 272 | |
273 | 273 | $type = new Type(); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | return $response->withJson($data); |
285 | 285 | }); |
286 | 286 | |
287 | -$app->delete('/types/{id}', function ($request, $response, $args) { |
|
287 | +$app->delete('/types/{id}', function($request, $response, $args) { |
|
288 | 288 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
289 | 289 | |
290 | 290 | $type = new Type(); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | // ~~~~~~~~~~~~~~~ Sub Type ~~~~~~~~~~~~~~~ |
304 | 304 | |
305 | -$app->post('/sub-types', function ($request, $response, $args) { |
|
305 | +$app->post('/sub-types', function($request, $response, $args) { |
|
306 | 306 | $postData = $request->getParsedBody(); |
307 | 307 | |
308 | 308 | $name = filter_var($postData['name'], FILTER_SANITIZE_STRING); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | return $response->withJson($data); |
326 | 326 | }); |
327 | 327 | |
328 | -$app->get('/sub-types/{id}', function ($request, $response, $args) { |
|
328 | +$app->get('/sub-types/{id}', function($request, $response, $args) { |
|
329 | 329 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
330 | 330 | |
331 | 331 | $type = new SubType(); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | return $response->withJson($data); |
343 | 343 | }); |
344 | 344 | |
345 | -$app->delete('/sub-types/{id}', function ($request, $response, $args) { |
|
345 | +$app->delete('/sub-types/{id}', function($request, $response, $args) { |
|
346 | 346 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
347 | 347 | |
348 | 348 | $type = new SubType(); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | // ~~~~~~~~~~~~~~~ Location ~~~~~~~~~~~~~~~ |
362 | 362 | |
363 | -$app->post('/locations', function ($request, $response, $args) { |
|
363 | +$app->post('/locations', function($request, $response, $args) { |
|
364 | 364 | $postData = $request->getParsedBody(); |
365 | 365 | |
366 | 366 | $name = filter_var($postData['name'], FILTER_SANITIZE_STRING); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | return $response->withJson($data); |
381 | 381 | }); |
382 | 382 | |
383 | -$app->get('/locations/{id}', function ($request, $response, $args) { |
|
383 | +$app->get('/locations/{id}', function($request, $response, $args) { |
|
384 | 384 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
385 | 385 | |
386 | 386 | $location = new Location(); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | return $response->withJson($data); |
397 | 397 | }); |
398 | 398 | |
399 | -$app->delete('/locations/{id}', function ($request, $response, $args) { |
|
399 | +$app->delete('/locations/{id}', function($request, $response, $args) { |
|
400 | 400 | $id = (int) filter_var($args['id'], FILTER_SANITIZE_NUMBER_INT); |
401 | 401 | |
402 | 402 | $location = new Location(); |
@@ -419,7 +419,9 @@ |
||
419 | 419 | // End of very very very basic auth |
420 | 420 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
421 | 421 | |
422 | -else: |
|
422 | +else { |
|
423 | + : |
|
423 | 424 | http_response_code(401); |
425 | +} |
|
424 | 426 | |
425 | 427 | endif; |
@@ -29,11 +29,11 @@ |
||
29 | 29 | // parameter represents the DataTables column identifier. In this case simple |
30 | 30 | // indexes |
31 | 31 | $columns = [ |
32 | - ['db' => 'id', 'dt' => 0], |
|
33 | - ['db' => 'firstname', 'dt' => 1], |
|
34 | - ['db' => 'surname', 'dt' => 2], |
|
35 | - ['db' => 'zip', 'dt' => 3], |
|
36 | - ['db' => 'country', 'dt' => 4], |
|
32 | + ['db' => 'id', 'dt' => 0], |
|
33 | + ['db' => 'firstname', 'dt' => 1], |
|
34 | + ['db' => 'surname', 'dt' => 2], |
|
35 | + ['db' => 'zip', 'dt' => 3], |
|
36 | + ['db' => 'country', 'dt' => 4], |
|
37 | 37 | ]; |
38 | 38 | |
39 | 39 | // SQL server connection information |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | // ensure user is allowed to see page |
40 | 40 | |
41 | 41 | if (!isAdmin() && $queryStringUser != $sessionUserId) { |
42 | - header('Location: swaps.php?user='.$sessionUserId); |
|
42 | + header('Location: swaps.php?user=' . $sessionUserId); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // fetch swaps |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | <p> |
91 | 91 | <strong> |
92 | 92 | <s class="text-red"> |
93 | - <?php echo $swap->getOldUserRole()->getUser()->getFirstName().' '.$swap->getOldUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getOldUserRole()->getRole()->getName() ?>) |
|
93 | + <?php echo $swap->getOldUserRole()->getUser()->getFirstName() . ' ' . $swap->getOldUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getOldUserRole()->getRole()->getName() ?>) |
|
94 | 94 | </s> |
95 | 95 | → |
96 | 96 | <span class="text-green"> |
97 | - <?php echo $swap->getNewUserRole()->getUser()->getFirstName().' '.$swap->getNewUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getNewUserRole()->getRole()->getName() ?>) |
|
97 | + <?php echo $swap->getNewUserRole()->getUser()->getFirstName() . ' ' . $swap->getNewUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getNewUserRole()->getRole()->getName() ?>) |
|
98 | 98 | </span> |
99 | 99 | </strong> |
100 | 100 | </p> |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | exit; |
34 | 34 | } |
35 | 35 | if (!isAdmin()) { |
36 | - header('Location: error.php?no=100&page='.basename($_SERVER['SCRIPT_FILENAME'])); |
|
36 | + header('Location: error.php?no=100&page=' . basename($_SERVER['SCRIPT_FILENAME'])); |
|
37 | 37 | exit; |
38 | 38 | } |
39 | 39 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | <?php |
117 | 117 | else: |
118 | - echo '<div class="box-body">'.$sentSuccess.'</div>'; |
|
118 | + echo '<div class="box-body">' . $sentSuccess . '</div>'; |
|
119 | 119 | endif; |
120 | 120 | ?> |
121 | 121 | </div> |
@@ -114,8 +114,10 @@ |
||
114 | 114 | </form> |
115 | 115 | |
116 | 116 | <?php |
117 | - else: |
|
117 | + else { |
|
118 | + : |
|
118 | 119 | echo '<div class="box-body">'.$sentSuccess.'</div>'; |
120 | + } |
|
119 | 121 | endif; |
120 | 122 | ?> |
121 | 123 | </div> |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | exit; |
34 | 34 | } |
35 | 35 | if (!isAdmin()) { |
36 | - header('Location: error.php?no=100&page='.basename($_SERVER['SCRIPT_FILENAME'])); |
|
36 | + header('Location: error.php?no=100&page=' . basename($_SERVER['SCRIPT_FILENAME'])); |
|
37 | 37 | exit; |
38 | 38 | } |
39 | 39 | |
@@ -119,15 +119,15 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | if ($viewPeople['skill'] != '') { |
122 | - $skill = ' - <em>'.$viewPeople['skill'].'</em>'; |
|
122 | + $skill = ' - <em>' . $viewPeople['skill'] . '</em>'; |
|
123 | 123 | } else { |
124 | 124 | $skill = ''; |
125 | 125 | } |
126 | 126 | if ($position == 2) { |
127 | - echo "<div class='checkboxitem right'><label class='styled' for='rehearsaldate[".$viewPeople['skillID']."]'>". |
|
128 | - $viewPeople['name'].$skill."</em></label><input class='styled' ".$checked."type='checkbox' id='rehearsaldate[". |
|
129 | - $viewPeople['skillID']."]' name='rehearsaldate[]' value='". |
|
130 | - $viewPeople['skillID']."' /></div></div>"; |
|
127 | + echo "<div class='checkboxitem right'><label class='styled' for='rehearsaldate[" . $viewPeople['skillID'] . "]'>" . |
|
128 | + $viewPeople['name'] . $skill . "</em></label><input class='styled' " . $checked . "type='checkbox' id='rehearsaldate[" . |
|
129 | + $viewPeople['skillID'] . "]' name='rehearsaldate[]' value='" . |
|
130 | + $viewPeople['skillID'] . "' /></div></div>"; |
|
131 | 131 | |
132 | 132 | $position = 1; |
133 | 133 | } else { |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $i = '1'; |
140 | 140 | } |
141 | 141 | |
142 | - echo "<div class='row".$class."'> |
|
143 | - <div class='checkboxitem'><label class='styled' for='rehearsaldate[".$viewPeople['skillID']."]'>". |
|
144 | - $viewPeople['name'].$skill."</em></label><input class='styled' ".$checked."type='checkbox' id='rehearsaldate[". |
|
145 | - $viewPeople['skillID']."]' name='rehearsaldate[]' value='". |
|
146 | - $viewPeople['skillID']."' /></div>"; |
|
142 | + echo "<div class='row" . $class . "'> |
|
143 | + <div class='checkboxitem'><label class='styled' for='rehearsaldate[".$viewPeople['skillID'] . "]'>" . |
|
144 | + $viewPeople['name'] . $skill . "</em></label><input class='styled' " . $checked . "type='checkbox' id='rehearsaldate[" . |
|
145 | + $viewPeople['skillID'] . "]' name='rehearsaldate[]' value='" . |
|
146 | + $viewPeople['skillID'] . "' /></div>"; |
|
147 | 147 | |
148 | 148 | $position = 2; |
149 | 149 | } |