@@ -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 | { |
@@ -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 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | if (!password_verify($v, $this->password)) { |
35 | 35 | $bcrypt_options = [ |
36 | 36 | 'cost' => 12, |
37 | - ]; |
|
37 | + ]; |
|
38 | 38 | $this->password = password_hash($v, PASSWORD_BCRYPT, $bcrypt_options); |
39 | 39 | |
40 | 40 | $this->modifiedColumns[UserTableMap::COL_PASSWORD] = true; |
@@ -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 users add(isOverviewRecipient char(2) NOT NULL DEFAULT '0')"); |
88 | 88 | executeDbSql('alter table groups add(short_name char(2))'); |
89 | 89 | |
90 | - executeDbSql("update settings set lang_locale = 'en_GB'"); // de_DE |
|
90 | + executeDbSql("update settings set lang_locale = 'en_GB'"); // de_DE |
|
91 | 91 | executeDbSql('update settings set event_sorting_latest = 0'); |
92 | 92 | executeDbSql('update settings set snapshot_show_two_month = 0'); |
93 | 93 | executeDbSql('update settings set snapshot_reduce_skills_by_group = 0'); |
94 | 94 | executeDbSql('update settings set logged_in_show_snapshot_button = 0'); |
95 | 95 | executeDbSql("update 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 settings set time_format_normal = '%m/%d/%y %I:%M %p'"); // de_DE: %d.%m.%Y %H:%M |
97 | - executeDbSql("update 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 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 settings set version = '2.1.0'"); |
99 | 99 | executeDbSql('update settings set users_start_with_myevents = 0'); |
100 | 100 | executeDbSql("update settings set time_zone = 'Europe/London'"); //de_DE: Europe/Berlin |
101 | 101 | executeDbSql("update settings set google_group_calendar = ''"); |
102 | 102 | executeDbSql("update 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 settings_bkp2_1_0 as select * from settings'); |
107 | 107 | executeDbSql('alter table settings add(group_sorting_name int(1))'); |
108 | 108 | executeDbSql("update 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 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 settings add(debug_mode int(1) DEFAULT '0')"); |
115 | - executeDbSql('update settings set group_sorting_name = 0'); //was a workaround, fixed in V2.2.1 |
|
115 | + executeDbSql('update settings set group_sorting_name = 0'); //was a workaround, fixed in V2.2.1 |
|
116 | 116 | |
117 | 117 | executeDbSql("update 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 users add(isBandAdmin char(2) NOT NULL DEFAULT '0')"); |
121 | 121 | executeDbSql('update settings set group_sorting_name = 0'); //due to an error reset it again |
122 | 122 | |
123 | 123 | executeDbSql("update 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 `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 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 users add(isEventEditor char(2) NOT NULL DEFAULT '0')"); |
144 | 144 | |
145 | 145 | executeDbSql("update 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 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 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 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 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 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 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 settings add(days_to_alert int(2) DEFAULT 5) '); |
218 | 218 | executeDbSql("alter table settings add(token varchar(100) DEFAULT '') "); |
219 | 219 | executeDbSql("update 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 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 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 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 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 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 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 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 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 users |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | executeDbSql($sql); |
371 | 371 | executeDbSql("update 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 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; |
@@ -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; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | // Start of API |
24 | 24 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
25 | 25 | |
26 | -require_once __DIR__.'/../../../vendor/autoload.php'; |
|
26 | +require_once __DIR__ . '/../../../vendor/autoload.php'; |
|
27 | 27 | |
28 | -require_once __DIR__.'/../../../generated-conf/config.php'; |
|
28 | +require_once __DIR__ . '/../../../generated-conf/config.php'; |
|
29 | 29 | |
30 | 30 | // Create and configure Slim app |
31 | 31 | $app = new \Slim\App(['settings' => $config]); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $container = $app->getContainer(); |
38 | 38 | |
39 | -$container['db'] = function ($c) { |
|
39 | +$container['db'] = function($c) { |
|
40 | 40 | $db_config = $c['settings']['db']; |
41 | 41 | $db = new Database($db_config); |
42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | // ~~~~~~~~~~~~~~~ Series ~~~~~~~~~~~~~~~ |
51 | 51 | |
52 | -$app->post('/series', function ($request, $response, $args) { |
|
52 | +$app->post('/series', function($request, $response, $args) { |
|
53 | 53 | $postData = $request->getParsedBody(); |
54 | 54 | |
55 | 55 | $name = filter_var($postData['name'], FILTER_SANITIZE_STRING); |
@@ -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> |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | case 'accept': |
65 | 65 | if (canAcceptSwap($swapId) || $verify == verificationCodeForSwap($swapId)) { |
66 | 66 | switch (acceptSwap($swapId)) { |
67 | - case '1': |
|
68 | - $message = 'Swap Successful'; |
|
69 | - break; |
|
70 | - case '2': |
|
71 | - $message = 'Swap already accepted.'; |
|
72 | - break; |
|
73 | - case '3': |
|
74 | - $message = 'Swap already declined.'; |
|
75 | - break; |
|
76 | - case '4': |
|
77 | - $message = 'Swap already reverted.'; |
|
78 | - break; |
|
79 | - default: |
|
80 | - $err = 'Technical issue - please inform system administrator'; |
|
81 | - break; |
|
67 | + case '1': |
|
68 | + $message = 'Swap Successful'; |
|
69 | + break; |
|
70 | + case '2': |
|
71 | + $message = 'Swap already accepted.'; |
|
72 | + break; |
|
73 | + case '3': |
|
74 | + $message = 'Swap already declined.'; |
|
75 | + break; |
|
76 | + case '4': |
|
77 | + $message = 'Swap already reverted.'; |
|
78 | + break; |
|
79 | + default: |
|
80 | + $err = 'Technical issue - please inform system administrator'; |
|
81 | + break; |
|
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | $err = 'Swap Already Actioned or Verification Code Invalid'; |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | case 'decline': |
88 | 88 | if (canDeclineSwap($swapId) || $verify == verificationCodeForSwap($swapId)) { |
89 | 89 | switch (declineSwap($swapId)) { |
90 | - case '1': |
|
91 | - $message = 'Swap declined'; |
|
92 | - break; |
|
93 | - case '2': |
|
94 | - $message = 'Swap already declined.'; |
|
95 | - break; |
|
96 | - default: |
|
97 | - $err = 'Technical issue - please inform system administrator'; |
|
98 | - break; |
|
90 | + case '1': |
|
91 | + $message = 'Swap declined'; |
|
92 | + break; |
|
93 | + case '2': |
|
94 | + $message = 'Swap already declined.'; |
|
95 | + break; |
|
96 | + default: |
|
97 | + $err = 'Technical issue - please inform system administrator'; |
|
98 | + break; |
|
99 | 99 | } |
100 | 100 | } else { |
101 | 101 | $err = 'Swap Already Actioned or Verification Code Invalid'; |
@@ -271,14 +271,17 @@ |
||
271 | 271 | |
272 | 272 | <?php endforeach; ?> |
273 | 273 | |
274 | - <?php else: ?> |
|
274 | + <?php else { |
|
275 | + : ?> |
|
275 | 276 | <?php // event has no roles the user can cover?> |
276 | 277 | |
277 | 278 | <div class="alert alert-warning"> |
278 | 279 | <h4><i class="icon fa fa-info"></i>There are no roles in the event you are skilled to cover.</h4> |
279 | 280 | <p>If you need adding to the rota, speak to an admin.</p> |
280 | 281 | </div> |
281 | - <?php endif; ?> |
|
282 | + <?php endif; |
|
283 | +} |
|
284 | +?> |
|
282 | 285 | |
283 | 286 | |
284 | 287 | <?php include 'includes/footer.php'; ?> |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $swapId = filter_var($swapId, FILTER_SANITIZE_NUMBER_INT); |
48 | 48 | |
49 | 49 | switch ($action) { |
50 | - case 'swap': |
|
50 | + case 'swap': |
|
51 | 51 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
52 | 52 | $eventPersonId = $_POST['eventPerson']; |
53 | 53 | $newUserRoleId = $_POST['newUserRole']; |
@@ -61,48 +61,48 @@ discard block |
||
61 | 61 | $err = 'Swap details incorrect, please try again.'; |
62 | 62 | } |
63 | 63 | break; |
64 | - case 'accept': |
|
64 | + case 'accept': |
|
65 | 65 | if (canAcceptSwap($swapId) || $verify == verificationCodeForSwap($swapId)) { |
66 | 66 | switch (acceptSwap($swapId)) { |
67 | 67 | case '1': |
68 | 68 | $message = 'Swap Successful'; |
69 | - break; |
|
69 | + break; |
|
70 | 70 | case '2': |
71 | 71 | $message = 'Swap already accepted.'; |
72 | - break; |
|
72 | + break; |
|
73 | 73 | case '3': |
74 | 74 | $message = 'Swap already declined.'; |
75 | - break; |
|
75 | + break; |
|
76 | 76 | case '4': |
77 | 77 | $message = 'Swap already reverted.'; |
78 | - break; |
|
78 | + break; |
|
79 | 79 | default: |
80 | 80 | $err = 'Technical issue - please inform system administrator'; |
81 | - break; |
|
82 | - } |
|
81 | + break; |
|
82 | + } |
|
83 | 83 | } else { |
84 | 84 | $err = 'Swap Already Actioned or Verification Code Invalid'; |
85 | 85 | } |
86 | 86 | break; |
87 | - case 'decline': |
|
87 | + case 'decline': |
|
88 | 88 | if (canDeclineSwap($swapId) || $verify == verificationCodeForSwap($swapId)) { |
89 | 89 | switch (declineSwap($swapId)) { |
90 | 90 | case '1': |
91 | 91 | $message = 'Swap declined'; |
92 | - break; |
|
92 | + break; |
|
93 | 93 | case '2': |
94 | 94 | $message = 'Swap already declined.'; |
95 | - break; |
|
95 | + break; |
|
96 | 96 | default: |
97 | 97 | $err = 'Technical issue - please inform system administrator'; |
98 | - break; |
|
98 | + break; |
|
99 | 99 | } |
100 | 100 | } else { |
101 | 101 | $err = 'Swap Already Actioned or Verification Code Invalid'; |
102 | 102 | } |
103 | 103 | break; |
104 | 104 | |
105 | - default: |
|
105 | + default: |
|
106 | 106 | // code... |
107 | 107 | break; |
108 | 108 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | <section class="content"> |
164 | 164 | |
165 | 165 | <?php |
166 | - if (isset($message)): ?> |
|
166 | + if (isset($message)): ?> |
|
167 | 167 | |
168 | 168 | <p><?php echo $message ?></p> |
169 | 169 | |
@@ -224,19 +224,19 @@ discard block |
||
224 | 224 | <label for="newUserRole">Swap To:</label> |
225 | 225 | <select name="newUserRole" class="form-control"> |
226 | 226 | <?php |
227 | - if (roleCanSwapToOtherRoleInGroup($role->roleId)) { |
|
228 | - $whereAnd = 'r.groupId = '.groupIdWithRole($role->roleId).' AND r.allowRoleSwaps IS NOT FALSE'; |
|
229 | - } else { |
|
230 | - $whereAnd = 'r.id = '.$role->roleId; |
|
231 | - } |
|
232 | - $sql = 'SELECT ur.id, u.firstName, u.lastName, r.name FROM users u INNER JOIN userRoles ur ON ur.userId = u.id INNER JOIN roles r ON r.id = ur.roleId WHERE u.id <> '.$role->userId.' AND '.$whereAnd.' ORDER BY lastName, firstName, r.name'; |
|
233 | - $result = mysqli_query(db(), $sql) or die(mysqli_error(db())); |
|
234 | - |
|
235 | - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
|
236 | - ?> |
|
227 | + if (roleCanSwapToOtherRoleInGroup($role->roleId)) { |
|
228 | + $whereAnd = 'r.groupId = '.groupIdWithRole($role->roleId).' AND r.allowRoleSwaps IS NOT FALSE'; |
|
229 | + } else { |
|
230 | + $whereAnd = 'r.id = '.$role->roleId; |
|
231 | + } |
|
232 | + $sql = 'SELECT ur.id, u.firstName, u.lastName, r.name FROM users u INNER JOIN userRoles ur ON ur.userId = u.id INNER JOIN roles r ON r.id = ur.roleId WHERE u.id <> '.$role->userId.' AND '.$whereAnd.' ORDER BY lastName, firstName, r.name'; |
|
233 | + $result = mysqli_query(db(), $sql) or die(mysqli_error(db())); |
|
234 | + |
|
235 | + while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
|
236 | + ?> |
|
237 | 237 | <option value='<?php echo $row['id']; ?>'><?php echo $row['firstName'].' '.$row['lastName'].' ('.$row['name'].')'; ?></option> |
238 | 238 | <?php |
239 | - } ?> |
|
239 | + } ?> |
|
240 | 240 | </select> |
241 | 241 | </div> |
242 | 242 | </div> |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | if (!empty($eventId)) { |
111 | 111 | // ensure user is logged in before allowing creation of swap |
112 | 112 | if (!(isset($_SESSION['is_logged_in']) || $_SESSION['db_is_logged_in'] == true)) { |
113 | - $_SESSION['redirectUrl'] = siteSettings()->getSiteUrl().'/swap.php?event='.$eventId; |
|
113 | + $_SESSION['redirectUrl'] = siteSettings()->getSiteUrl() . '/swap.php?event=' . $eventId; |
|
114 | 114 | header('Location: login.php'); |
115 | 115 | } |
116 | 116 | $createSwap = true; |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | <p> |
187 | 187 | <strong> |
188 | 188 | <s class="text-red"> |
189 | - <?php echo $swap->getOldUserRole()->getUser()->getFirstName().' '.$swap->getOldUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getOldUserRole()->getRole()->getName() ?>) |
|
189 | + <?php echo $swap->getOldUserRole()->getUser()->getFirstName() . ' ' . $swap->getOldUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getOldUserRole()->getRole()->getName() ?>) |
|
190 | 190 | </s> |
191 | 191 | → |
192 | 192 | <span class="text-green"> |
193 | - <?php echo $swap->getNewUserRole()->getUser()->getFirstName().' '.$swap->getNewUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getNewUserRole()->getRole()->getName() ?>) |
|
193 | + <?php echo $swap->getNewUserRole()->getUser()->getFirstName() . ' ' . $swap->getNewUserRole()->getUser()->getLastName() ?> (<?php echo $swap->getNewUserRole()->getRole()->getName() ?>) |
|
194 | 194 | </span> |
195 | 195 | </strong> |
196 | 196 | </p> |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | <select name="newUserRole" class="form-control"> |
226 | 226 | <?php |
227 | 227 | if (roleCanSwapToOtherRoleInGroup($role->roleId)) { |
228 | - $whereAnd = 'r.groupId = '.groupIdWithRole($role->roleId).' AND r.allowRoleSwaps IS NOT FALSE'; |
|
228 | + $whereAnd = 'r.groupId = ' . groupIdWithRole($role->roleId) . ' AND r.allowRoleSwaps IS NOT FALSE'; |
|
229 | 229 | } else { |
230 | - $whereAnd = 'r.id = '.$role->roleId; |
|
230 | + $whereAnd = 'r.id = ' . $role->roleId; |
|
231 | 231 | } |
232 | - $sql = 'SELECT ur.id, u.firstName, u.lastName, r.name FROM users u INNER JOIN userRoles ur ON ur.userId = u.id INNER JOIN roles r ON r.id = ur.roleId WHERE u.id <> '.$role->userId.' AND '.$whereAnd.' ORDER BY lastName, firstName, r.name'; |
|
232 | + $sql = 'SELECT ur.id, u.firstName, u.lastName, r.name FROM users u INNER JOIN userRoles ur ON ur.userId = u.id INNER JOIN roles r ON r.id = ur.roleId WHERE u.id <> ' . $role->userId . ' AND ' . $whereAnd . ' ORDER BY lastName, firstName, r.name'; |
|
233 | 233 | $result = mysqli_query(db(), $sql) or die(mysqli_error(db())); |
234 | 234 | |
235 | 235 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
236 | 236 | ?> |
237 | - <option value='<?php echo $row['id']; ?>'><?php echo $row['firstName'].' '.$row['lastName'].' ('.$row['name'].')'; ?></option> |
|
237 | + <option value='<?php echo $row['id']; ?>'><?php echo $row['firstName'] . ' ' . $row['lastName'] . ' (' . $row['name'] . ')'; ?></option> |
|
238 | 238 | <?php |
239 | 239 | } ?> |
240 | 240 | </select> |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | while ($ob = mysqli_fetch_object($result)) { |
89 | 89 | if (!(isset($type) && $ob->id == $type)) { |
90 | 90 | $defaultTime = strftime('%H:%M', strtotime($ob->defaultTime)); |
91 | - echo "<option value='".$ob->id."' title='".$ob->description."' data-time='".($defaultTime == '00:00' ? '' : $defaultTime)."' data-location='".(is_null($ob->defaultLocationId) ? '' : $ob->defaultLocationId)."'>".$ob->name.'</option>'; |
|
91 | + echo "<option value='" . $ob->id . "' title='" . $ob->description . "' data-time='" . ($defaultTime == '00:00' ? '' : $defaultTime) . "' data-location='" . (is_null($ob->defaultLocationId) ? '' : $ob->defaultLocationId) . "'>" . $ob->name . '</option>'; |
|
92 | 92 | } |
93 | 93 | } ?> |
94 | 94 | </select> |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
115 | 115 | if (isset($subtype) && $row['id'] == $subtype) { |
116 | 116 | } else { |
117 | - echo "<option value='".$row['id']."' title='".$row['description']."'>".$row['name'].'</option>'; |
|
117 | + echo "<option value='" . $row['id'] . "' title='" . $row['description'] . "'>" . $row['name'] . '</option>'; |
|
118 | 118 | } |
119 | 119 | } ?> |
120 | 120 | </select> |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
143 | 143 | if (isset($location) && $row['id'] == $location) { |
144 | 144 | } else { |
145 | - echo "<option value='".$row['id']."'>".$row['name'].'</option>'; |
|
145 | + echo "<option value='" . $row['id'] . "'>" . $row['name'] . '</option>'; |
|
146 | 146 | } |
147 | 147 | } ?> |
148 | 148 | </select> |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
286 | 286 | if (isset($type) && $row['id'] == $type) { |
287 | 287 | } else { |
288 | - echo "<option value='".$row['id']."' title='".$row['description']."'>".$row['name'].'</option>'; |
|
288 | + echo "<option value='" . $row['id'] . "' title='" . $row['description'] . "'>" . $row['name'] . '</option>'; |
|
289 | 289 | } |
290 | 290 | } ?> |
291 | 291 | </select> |