@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $name = $request->get('_name'); |
25 | 25 | $recaptcha = $request->get('_recaptcha'); |
26 | 26 | |
27 | - if(empty($password) |
|
27 | + if (empty($password) |
|
28 | 28 | || empty($confirmPassword) |
29 | 29 | || empty($emailAddress) |
30 | 30 | || empty($name) |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $this->validateEmailAddress($emailAddress, $errors, $valid); |
43 | 43 | |
44 | - if(!$this->app['phpdraft.LoginUserRepository']->NameIsUnique($name)) { |
|
44 | + if (!$this->app['phpdraft.LoginUserRepository']->NameIsUnique($name)) { |
|
45 | 45 | $errors[] = "Name already taken."; |
46 | 46 | $valid = false; |
47 | 47 | } |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | $emailAddress = $request->get('_email'); |
59 | 59 | $verificationToken = $this->app['phpdraft.SaltService']->UrlDecodeSalt($request->get('_verificationToken')); |
60 | 60 | |
61 | - if(strlen($verificationToken) != 16) { |
|
61 | + if (strlen($verificationToken) != 16) { |
|
62 | 62 | $errors[] = "Verification token invalid."; |
63 | 63 | $valid = false; |
64 | 64 | } |
65 | 65 | |
66 | 66 | $this->validateEmailAddress($emailAddress, $errors, $valid); |
67 | 67 | |
68 | - if(!$this->app['phpdraft.LoginUserRepository']->VerificationMatches($emailAddress, $verificationToken)) { |
|
68 | + if (!$this->app['phpdraft.LoginUserRepository']->VerificationMatches($emailAddress, $verificationToken)) { |
|
69 | 69 | $errors[] = "Verification token invalid."; |
70 | 70 | $valid = false; |
71 | 71 | } |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | $valid = true; |
100 | 100 | $errors = array(); |
101 | 101 | |
102 | - if(empty($emailAddress) |
|
102 | + if (empty($emailAddress) |
|
103 | 103 | || empty($verificationToken)) { |
104 | 104 | $errors[] = "One or more missing fields"; |
105 | 105 | $valid = false; |
106 | 106 | } |
107 | 107 | |
108 | - if(strlen($verificationToken) != 16) { |
|
108 | + if (strlen($verificationToken) != 16) { |
|
109 | 109 | $errors[] = "Verification token invalid."; |
110 | 110 | $valid = false; |
111 | 111 | } |
112 | 112 | |
113 | - if(!$this->app['phpdraft.LoginUserRepository']->VerificationMatches($emailAddress, $verificationToken)) { |
|
113 | + if (!$this->app['phpdraft.LoginUserRepository']->VerificationMatches($emailAddress, $verificationToken)) { |
|
114 | 114 | $errors[] = "Verification token invalid."; |
115 | 115 | $valid = false; |
116 | 116 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $confirmPassword = $request->get('_confirmPassword'); |
132 | 132 | $verificationToken = $this->app['phpdraft.SaltService']->UrlDecodeSalt($request->get('_verificationToken')); |
133 | 133 | |
134 | - if(empty($emailAddress) |
|
134 | + if (empty($emailAddress) |
|
135 | 135 | || empty($password) |
136 | 136 | || empty($confirmPassword) |
137 | 137 | || empty($verificationToken)) { |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | $valid = false; |
140 | 140 | } |
141 | 141 | |
142 | - if(strlen($verificationToken) != 16) { |
|
142 | + if (strlen($verificationToken) != 16) { |
|
143 | 143 | $errors[] = "Verification token invalid."; |
144 | 144 | $valid = false; |
145 | 145 | } |
146 | 146 | |
147 | - if(!$this->app['phpdraft.LoginUserRepository']->VerificationMatches($emailAddress, $verificationToken)) { |
|
147 | + if (!$this->app['phpdraft.LoginUserRepository']->VerificationMatches($emailAddress, $verificationToken)) { |
|
148 | 148 | $errors[] = "Verification token invalid."; |
149 | 149 | $valid = false; |
150 | 150 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $currentUser = $this->app['phpdraft.LoginUserService']->GetCurrentUser(); |
174 | 174 | |
175 | - if(empty($currentUser) || $currentUser == null) { |
|
175 | + if (empty($currentUser) || $currentUser == null) { |
|
176 | 176 | $valid = false; |
177 | 177 | $errors[] = "Invalid user."; |
178 | 178 | |
@@ -181,38 +181,38 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | //Password required to make any changes |
184 | - if(empty($password) || !$this->app['security.encoder.digest']->isPasswordValid($currentUser->password, $password, $currentUser->salt)) { |
|
184 | + if (empty($password) || !$this->app['security.encoder.digest']->isPasswordValid($currentUser->password, $password, $currentUser->salt)) { |
|
185 | 185 | $errors[] = "Incorrect password entered."; |
186 | 186 | $valid = false; |
187 | 187 | } |
188 | 188 | |
189 | 189 | //Need to verify new email |
190 | - if(empty($emailAddress)) { |
|
190 | + if (empty($emailAddress)) { |
|
191 | 191 | $errors[] = "Email address is missing."; |
192 | 192 | $valid = false; |
193 | - } else if(!$this->app['phpdraft.StringsEqual']($emailAddress, $currentUser->email)) { |
|
193 | + } else if (!$this->app['phpdraft.StringsEqual']($emailAddress, $currentUser->email)) { |
|
194 | 194 | $this->validateEmailAddress($emailAddress, $errors, $valid); |
195 | 195 | |
196 | 196 | $this->validateUniqueEmail($emailAddress, $errors, $valid); |
197 | 197 | } |
198 | 198 | |
199 | 199 | //Need to verify new password, ensure old password is correct |
200 | - if(!empty($newPassword)) { |
|
200 | + if (!empty($newPassword)) { |
|
201 | 201 | $this->validatePasswordLength($newPassword, $errors, $valid); |
202 | 202 | |
203 | 203 | $this->validatePasswordsMatch($newPassword, $newConfirmedPassword, $errors, $valid); |
204 | 204 | } |
205 | 205 | |
206 | 206 | //If the name has changed, ensure the new one is valid and unique |
207 | - if($currentUser->name != $name) { |
|
208 | - if(empty($name)) { |
|
207 | + if ($currentUser->name != $name) { |
|
208 | + if (empty($name)) { |
|
209 | 209 | $errors[] = "Name is required."; |
210 | 210 | $valid = false; |
211 | 211 | } |
212 | 212 | |
213 | 213 | $this->validateNameLength($name, $errors, $valid); |
214 | 214 | |
215 | - if(!$this->app['phpdraft.LoginUserRepository']->NameIsUnique($name)) { |
|
215 | + if (!$this->app['phpdraft.LoginUserRepository']->NameIsUnique($name)) { |
|
216 | 216 | $errors[] = "Name already taken."; |
217 | 217 | $valid = false; |
218 | 218 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | $loadedUser = $this->app['phpdraft.LoginUserRepository']->LoadById($user->id); |
229 | 229 | |
230 | - if($user->id == 0 || empty($loadedUser)) { |
|
230 | + if ($user->id == 0 || empty($loadedUser)) { |
|
231 | 231 | $valid = false; |
232 | 232 | $errors[] = "Invalid user."; |
233 | 233 | |
@@ -236,21 +236,21 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | //Need to verify new email |
239 | - if(empty($user->email)) { |
|
239 | + if (empty($user->email)) { |
|
240 | 240 | $errors[] = "Email address is missing."; |
241 | 241 | $valid = false; |
242 | - } else if(!$this->app['phpdraft.StringsEqual']($user->email, $loadedUser->email)) { |
|
242 | + } else if (!$this->app['phpdraft.StringsEqual']($user->email, $loadedUser->email)) { |
|
243 | 243 | $this->validateEmailAddress($user->email, $errors, $valid); |
244 | 244 | |
245 | 245 | $this->validateUniqueEmail($user->email, $errors, $valid); |
246 | 246 | } |
247 | 247 | |
248 | - if(strlen($user->name) > 100) { |
|
248 | + if (strlen($user->name) > 100) { |
|
249 | 249 | $errors[] = "Name is above maximum length"; |
250 | 250 | $valid = false; |
251 | 251 | } |
252 | 252 | |
253 | - if(!$this->app['phpdraft.LoginUserRepository']->NameIsUnique($user->name, $user->id)) { |
|
253 | + if (!$this->app['phpdraft.LoginUserRepository']->NameIsUnique($user->name, $user->id)) { |
|
254 | 254 | $errors[] = "Name already taken."; |
255 | 255 | $valid = false; |
256 | 256 | } |
@@ -259,47 +259,47 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | private function validatePasswordsMatch($password1, $password2, &$errors, &$valid) { |
262 | - if(!$this->app['phpdraft.StringsEqual']($password1, $password2)) { |
|
262 | + if (!$this->app['phpdraft.StringsEqual']($password1, $password2)) { |
|
263 | 263 | $errors[] = "Password values do not match."; |
264 | 264 | $valid = false; |
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | 268 | private function validateUniqueEmail($emailAddress, &$errors, &$valid) { |
269 | - if(!$this->app['phpdraft.LoginUserRepository']->EmailIsUnique($emailAddress)) { |
|
269 | + if (!$this->app['phpdraft.LoginUserRepository']->EmailIsUnique($emailAddress)) { |
|
270 | 270 | $errors[] = "Email already registered."; |
271 | 271 | $valid = false; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | 275 | private function validateEmailExists($emailAddress, &$errors, &$valid) { |
276 | - if(!$this->app['phpdraft.LoginUserRepository']->EmailExists($emailAddress)) { |
|
276 | + if (!$this->app['phpdraft.LoginUserRepository']->EmailExists($emailAddress)) { |
|
277 | 277 | $errors[] = "Email invalid."; |
278 | 278 | $valid = false; |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | 282 | private function validateEmailAddress($emailAddress, &$errors, &$valid) { |
283 | - if(!$this->app['phpdraft.EmailValidator']->isValid($emailAddress) || strlen($emailAddress) > 255) { |
|
283 | + if (!$this->app['phpdraft.EmailValidator']->isValid($emailAddress) || strlen($emailAddress) > 255) { |
|
284 | 284 | $errors[] = "Email invalid."; |
285 | 285 | $valid = false; |
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | 289 | private function validatePasswordLength($password, &$errors, &$valid) { |
290 | - if(strlen($password) < 8) { |
|
290 | + if (strlen($password) < 8) { |
|
291 | 291 | $errors[] = "Password is below minimum length."; |
292 | 292 | $valid = false; |
293 | 293 | } |
294 | 294 | |
295 | - if(strlen($password) > 255) { |
|
295 | + if (strlen($password) > 255) { |
|
296 | 296 | $errors[] = "Password is above maximum length."; |
297 | 297 | $valid = false; |
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | 301 | private function validateNameLength($name, &$errors, &$valid) { |
302 | - if(strlen($name) > 100) { |
|
302 | + if (strlen($name) > 100) { |
|
303 | 303 | $errors[] = "Name is above maximum length"; |
304 | 304 | $valid = false; |
305 | 305 | } |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | |
21 | 21 | try { |
22 | 22 | $current_manager_count = $this->app['phpdraft.ManagerRepository']->GetNumberOfCurrentManagers($draft_id); |
23 | - } catch(\Exception $e) { |
|
23 | + } catch (\Exception $e) { |
|
24 | 24 | $errors[] = $e->getMessage(); |
25 | 25 | $valid = false; |
26 | 26 | $current_manager_count = 0; |
27 | 27 | } |
28 | 28 | |
29 | - if(empty($manager->draft_id) |
|
29 | + if (empty($manager->draft_id) |
|
30 | 30 | || empty($manager->manager_name)) { |
31 | 31 | $errors[] = "One or more missing fields."; |
32 | 32 | $valid = false; |
33 | 33 | } |
34 | 34 | |
35 | - if(!empty($manager->manager_name) && strlen($manager->manager_name) > 255) { |
|
35 | + if (!empty($manager->manager_name) && strlen($manager->manager_name) > 255) { |
|
36 | 36 | $errors[] = "Manager name is above maximum length."; |
37 | 37 | $valid = false; |
38 | 38 | } |
39 | 39 | |
40 | - if($current_manager_count > 19) { |
|
40 | + if ($current_manager_count > 19) { |
|
41 | 41 | $errors[] = "Unable to add more managers - 20 is the maximum number of managers allowed."; |
42 | 42 | $valid = false; |
43 | 43 | } |
44 | 44 | |
45 | - if(!$this->app['phpdraft.ManagerRepository']->NameIsUnique($manager->manager_name)) { |
|
45 | + if (!$this->app['phpdraft.ManagerRepository']->NameIsUnique($manager->manager_name)) { |
|
46 | 46 | $errors[] = "Manager name '$manager->manager_name' already exists - please choose another name."; |
47 | 47 | $valid = false; |
48 | 48 | } |
@@ -56,34 +56,34 @@ discard block |
||
56 | 56 | $current_manager_count = $this->app['phpdraft.ManagerRepository']->GetNumberOfCurrentManagers($draft_id); |
57 | 57 | $numberOfNewManagers = count($managersArray); |
58 | 58 | $maxNumberOfManagers = 20 - $current_manager_count; |
59 | - $numberOfManagersOver = $numberOfNewManagers-$maxNumberOfManagers; |
|
59 | + $numberOfManagersOver = $numberOfNewManagers - $maxNumberOfManagers; |
|
60 | 60 | $uniqueManagersCount = count(array_unique($managersArray)); |
61 | 61 | |
62 | - if($numberOfNewManagers > $maxNumberOfManagers) { |
|
62 | + if ($numberOfNewManagers > $maxNumberOfManagers) { |
|
63 | 63 | $manager_noun = $numberOfManagersOver > 1 ? "managers" : "manager"; |
64 | 64 | $errors[] = "Unable to add $numberOfNewManagers new managers - the maximum number of managers is 20. Draft currently has $current_manager_count, so please remove $numberOfManagersOver $manager_noun to continue."; |
65 | 65 | $valid = false; |
66 | 66 | } |
67 | 67 | |
68 | - if($numberOfNewManagers != $uniqueManagersCount) { |
|
68 | + if ($numberOfNewManagers != $uniqueManagersCount) { |
|
69 | 69 | $errors[] = "Two or more managers had the same name - please ensure all managers have unique names."; |
70 | 70 | $valid = false; |
71 | 71 | } |
72 | 72 | |
73 | 73 | $manager_number = 1; |
74 | - foreach($managersArray as $manager) { |
|
75 | - if(empty($manager->draft_id) |
|
74 | + foreach ($managersArray as $manager) { |
|
75 | + if (empty($manager->draft_id) |
|
76 | 76 | || empty($manager->manager_name)) { |
77 | 77 | $errors[] = "One or more missing fields for manager #$manager_number."; |
78 | 78 | $valid = false; |
79 | 79 | } |
80 | 80 | |
81 | - if(!empty($manager->manager_name) && strlen($manager->manager_name) > 255) { |
|
81 | + if (!empty($manager->manager_name) && strlen($manager->manager_name) > 255) { |
|
82 | 82 | $errors[] = "Manager #$manager_number's name is above the maximum length."; |
83 | 83 | $valid = false; |
84 | 84 | } |
85 | 85 | |
86 | - if(!$this->app['phpdraft.ManagerRepository']->NameIsUnique($manager->manager_name, $draft_id)) { |
|
86 | + if (!$this->app['phpdraft.ManagerRepository']->NameIsUnique($manager->manager_name, $draft_id)) { |
|
87 | 87 | $errors[] = "Manager name '$manager->manager_name' already exists - please choose another name."; |
88 | 88 | $valid = false; |
89 | 89 | } |
@@ -100,26 +100,26 @@ discard block |
||
100 | 100 | $current_manager_count = $this->app['phpdraft.ManagerRepository']->GetNumberOfCurrentManagers($draft_id); |
101 | 101 | $ids_given = count($managersIdArray); |
102 | 102 | |
103 | - if(count($managersIdArray) == 0) { |
|
103 | + if (count($managersIdArray) == 0) { |
|
104 | 104 | $errors[] = "One or more missing fields."; |
105 | 105 | $valid = false; |
106 | 106 | } |
107 | 107 | |
108 | - if($ids_given > 20) { |
|
108 | + if ($ids_given > 20) { |
|
109 | 109 | $errors[] = "Too many managers given - maximum number of managers is 20"; |
110 | 110 | $valid = false; |
111 | 111 | } |
112 | 112 | |
113 | - if($ids_given != $current_manager_count) { |
|
113 | + if ($ids_given != $current_manager_count) { |
|
114 | 114 | $manager_noun = $current_manager_count > 1 ? "managers" : "manager"; |
115 | 115 | $errors[] = "Incorrect number of managers given. Draft #$draft_id has $current_manager_count $manager_noun, but $ids_given were received."; |
116 | 116 | $valid = false; |
117 | 117 | } |
118 | 118 | |
119 | 119 | //Save ourself a little processing if we've been handled a faulty request: |
120 | - if($valid = true) { |
|
121 | - foreach($managersIdArray as $manager_id) { |
|
122 | - if(!$this->app['phpdraft.ManagerRepository']->ManagerExists($manager_id, $draft_id)) { |
|
120 | + if ($valid = true) { |
|
121 | + foreach ($managersIdArray as $manager_id) { |
|
122 | + if (!$this->app['phpdraft.ManagerRepository']->ManagerExists($manager_id, $draft_id)) { |
|
123 | 123 | $errors[] = "Manager #$manager_id does not exist."; |
124 | 124 | $valid = false; |
125 | 125 | } |
@@ -133,24 +133,24 @@ discard block |
||
133 | 133 | $valid = true; |
134 | 134 | $errors = array(); |
135 | 135 | |
136 | - if(empty($manager->manager_id) |
|
136 | + if (empty($manager->manager_id) |
|
137 | 137 | || empty($manager->draft_id) |
138 | 138 | || empty($manager->manager_name)) { |
139 | 139 | $errors[] = "One or more missing fields."; |
140 | 140 | $valid = false; |
141 | 141 | } |
142 | 142 | |
143 | - if($draft->draft_id != $manager->draft_id) { |
|
143 | + if ($draft->draft_id != $manager->draft_id) { |
|
144 | 144 | $errors[] = "Manager does not belong to draft #$draft_id"; |
145 | 145 | $valid = false; |
146 | 146 | } |
147 | 147 | |
148 | - if(!empty($manager->manager_name) && strlen($manager->manager_name) > 255) { |
|
148 | + if (!empty($manager->manager_name) && strlen($manager->manager_name) > 255) { |
|
149 | 149 | $errors[] = "Manager name is above maximum length."; |
150 | 150 | $valid = false; |
151 | 151 | } |
152 | 152 | |
153 | - if(!$this->app['phpdraft.ManagerRepository']->NameIsUnique($manager->manager_name, $draft->draft_id, $manager->manager_id)) { |
|
153 | + if (!$this->app['phpdraft.ManagerRepository']->NameIsUnique($manager->manager_name, $draft->draft_id, $manager->manager_id)) { |
|
154 | 154 | $errors[] = "Manager name '$manager->manager_name' already exists - please choose another name."; |
155 | 155 | $valid = false; |
156 | 156 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $teams = $this->app['phpdraft.DraftDataRepository']->GetTeams($draft->draft_sport); |
21 | 21 | $positions = $this->app['phpdraft.DraftDataRepository']->GetPositions($draft->draft_sport); |
22 | 22 | |
23 | - if(empty($pick->first_name) |
|
23 | + if (empty($pick->first_name) |
|
24 | 24 | || empty($pick->last_name) |
25 | 25 | || empty($pick->team) |
26 | 26 | || empty($pick->position)) { |
@@ -28,32 +28,32 @@ discard block |
||
28 | 28 | $valid = false; |
29 | 29 | } |
30 | 30 | |
31 | - if($pick->draft_id != $draft->draft_id) { |
|
31 | + if ($pick->draft_id != $draft->draft_id) { |
|
32 | 32 | $errors[] = "Pick does not belong to draft #$draft->draft_id."; |
33 | 33 | $valid = false; |
34 | 34 | } |
35 | 35 | |
36 | - if(strlen($pick->first_name) > 255) { |
|
36 | + if (strlen($pick->first_name) > 255) { |
|
37 | 37 | $errors[] = "First name is above maximum length."; |
38 | 38 | $valid = false; |
39 | 39 | } |
40 | 40 | |
41 | - if(strlen($pick->last_name) > 255) { |
|
41 | + if (strlen($pick->last_name) > 255) { |
|
42 | 42 | $errors[] = "Last name is above maximum length."; |
43 | 43 | $valid = false; |
44 | 44 | } |
45 | 45 | |
46 | - if($draft->draft_current_pick != $pick->player_pick) { |
|
46 | + if ($draft->draft_current_pick != $pick->player_pick) { |
|
47 | 47 | $errors[] = "Pick #$pick->player_pick is not the current pick for draft #$draft->draft_id."; |
48 | 48 | $valid = false; |
49 | 49 | } |
50 | 50 | |
51 | - if(!array_key_exists($pick->team, $teams)) { |
|
51 | + if (!array_key_exists($pick->team, $teams)) { |
|
52 | 52 | $errors[] = "Team $pick->team is an invalid value."; |
53 | 53 | $valid = false; |
54 | 54 | } |
55 | 55 | |
56 | - if(!array_key_exists($pick->position, $positions)) { |
|
56 | + if (!array_key_exists($pick->position, $positions)) { |
|
57 | 57 | $errors[] = "Position $pick->position is an invalid value."; |
58 | 58 | $valid = false; |
59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $teams = $this->app['phpdraft.DraftDataRepository']->GetTeams($draft->draft_sport); |
68 | 68 | $positions = $this->app['phpdraft.DraftDataRepository']->GetPositions($draft->draft_sport); |
69 | 69 | |
70 | - if(empty($pick->first_name) |
|
70 | + if (empty($pick->first_name) |
|
71 | 71 | || empty($pick->last_name) |
72 | 72 | || empty($pick->team) |
73 | 73 | || empty($pick->position)) { |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | $valid = false; |
76 | 76 | } |
77 | 77 | |
78 | - if($pick->draft_id != $draft->draft_id) { |
|
78 | + if ($pick->draft_id != $draft->draft_id) { |
|
79 | 79 | $errors[] = "Pick does not belong to draft #$draft->draft_id."; |
80 | 80 | $valid = false; |
81 | 81 | } |
82 | 82 | |
83 | - if(strlen($pick->first_name) > 255) { |
|
83 | + if (strlen($pick->first_name) > 255) { |
|
84 | 84 | $errors[] = "First name is above maximum length."; |
85 | 85 | $valid = false; |
86 | 86 | } |
87 | 87 | |
88 | - if(strlen($pick->last_name) > 255) { |
|
88 | + if (strlen($pick->last_name) > 255) { |
|
89 | 89 | $errors[] = "Last name is above maximum length."; |
90 | 90 | $valid = false; |
91 | 91 | } |
92 | 92 | |
93 | - if(!array_key_exists($pick->team, $teams)) { |
|
93 | + if (!array_key_exists($pick->team, $teams)) { |
|
94 | 94 | $errors[] = "Team $pick->team is an invalid value."; |
95 | 95 | $valid = false; |
96 | 96 | } |
97 | 97 | |
98 | - if(!array_key_exists($pick->position, $positions)) { |
|
98 | + if (!array_key_exists($pick->position, $positions)) { |
|
99 | 99 | $errors[] = "Position $pick->position is an invalid value."; |
100 | 100 | $valid = false; |
101 | 101 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $valid = true; |
108 | 108 | $errors = array(); |
109 | 109 | |
110 | - if($pick->draft_id != $draft->draft_id) { |
|
110 | + if ($pick->draft_id != $draft->draft_id) { |
|
111 | 111 | $errors[] = "Pick does not belong to draft #$draft->draft_id."; |
112 | 112 | $valid = false; |
113 | 113 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $errors = array(); |
18 | 18 | $draft_sports = $this->app['phpdraft.DraftDataRepository']->GetSports(); |
19 | 19 | |
20 | - if(strlen($draft_sport) < 3 || strlen($draft_sport) > 4 || strlen($draft_sports[$draft_sport]) == 0) { |
|
20 | + if (strlen($draft_sport) < 3 || strlen($draft_sport) > 4 || strlen($draft_sports[$draft_sport]) == 0) { |
|
21 | 21 | $errors[] = "Draft sport is an invalid value."; |
22 | 22 | $valid = false; |
23 | 23 | } |
@@ -29,28 +29,28 @@ discard block |
||
29 | 29 | $valid = true; |
30 | 30 | $errors = array(); |
31 | 31 | |
32 | - if(count($depthChartPositionCreateModel->positions) !== count(array_unique($depthChartPositionCreateModel->positions))) { |
|
32 | + if (count($depthChartPositionCreateModel->positions) !== count(array_unique($depthChartPositionCreateModel->positions))) { |
|
33 | 33 | $valid = false; |
34 | 34 | $errors[] = "One or more of the positions are not unique."; |
35 | 35 | } |
36 | 36 | |
37 | 37 | $rounds = 0; |
38 | 38 | |
39 | - foreach($depthChartPositionCreateModel->positions as $depthChartPosition) { |
|
39 | + foreach ($depthChartPositionCreateModel->positions as $depthChartPosition) { |
|
40 | 40 | $rounds += (int)$depthChartPosition->slots; |
41 | 41 | } |
42 | 42 | |
43 | - if($rounds == 0) { |
|
43 | + if ($rounds == 0) { |
|
44 | 44 | $valid = false; |
45 | 45 | $errors[] = "The depth chart positions must specify at least 1 slot"; |
46 | 46 | } |
47 | 47 | |
48 | - if($rounds > 30) { |
|
48 | + if ($rounds > 30) { |
|
49 | 49 | $valid = false; |
50 | 50 | $errors[] = "The depth chart positions cannot specify more than 30 slots in total."; |
51 | 51 | } |
52 | 52 | |
53 | - if(count($depthChartPositionCreateModel->positions) > 30) { |
|
53 | + if (count($depthChartPositionCreateModel->positions) > 30) { |
|
54 | 54 | $valid = false; |
55 | 55 | $errors[] = "Too many depth chart positions have been provided - 30 is the maximum."; |
56 | 56 | } |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | $current_user = $this->app['phpdraft.LoginUserService']->GetUserFromHeaderToken($request); |
22 | 22 | $draft_password = $request->headers->get(DRAFT_PASSWORD_HEADER, ''); |
23 | 23 | |
24 | - if($current_user != null && ($draft->commish_id == $current_user->id || $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user))) { |
|
24 | + if ($current_user != null && ($draft->commish_id == $current_user->id || $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user))) { |
|
25 | 25 | return true; |
26 | 26 | } |
27 | 27 | |
28 | - if(empty($draft->draft_password) || ($draft->draft_password == $draft_password)) { |
|
28 | + if (empty($draft->draft_password) || ($draft->draft_password == $draft_password)) { |
|
29 | 29 | return true; |
30 | 30 | } |
31 | 31 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function IsDraftEditableForUser(Draft $draft, LoginUser $current_user) { |
36 | - if(!empty($current_user) && !empty($draft) && $draft->commish_id == $current_user->id) { |
|
36 | + if (!empty($current_user) && !empty($draft) && $draft->commish_id == $current_user->id) { |
|
37 | 37 | return true; |
38 | 38 | } |
39 | 39 | |
40 | - if(!empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user)) { |
|
40 | + if (!empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user)) { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $draft_sports = $this->app['phpdraft.DraftDataRepository']->GetSports(); |
51 | 51 | $draft_styles = $this->app['phpdraft.DraftDataRepository']->GetStyles(); |
52 | 52 | |
53 | - if(empty($draft->commish_id) |
|
53 | + if (empty($draft->commish_id) |
|
54 | 54 | || empty($draft->draft_name) |
55 | 55 | || empty($draft->draft_sport) |
56 | 56 | || empty($draft->draft_style)) { |
@@ -58,33 +58,33 @@ discard block |
||
58 | 58 | $valid = false; |
59 | 59 | } |
60 | 60 | |
61 | - if(!empty($draft->draft_password) && strlen($draft->draft_password) > 255) { |
|
61 | + if (!empty($draft->draft_password) && strlen($draft->draft_password) > 255) { |
|
62 | 62 | $errors[] = "Password is above maximum length."; |
63 | 63 | $valid = false; |
64 | 64 | } |
65 | 65 | |
66 | - if(strlen($draft->draft_name) > 255) { |
|
66 | + if (strlen($draft->draft_name) > 255) { |
|
67 | 67 | $errors[] = "Draft name is above maximum length"; |
68 | 68 | $valid = false; |
69 | 69 | } |
70 | 70 | |
71 | - if(strlen($draft->draft_sport) < 3 || strlen($draft->draft_sport) > 4 || strlen($draft_sports[$draft->draft_sport]) == 0) { |
|
71 | + if (strlen($draft->draft_sport) < 3 || strlen($draft->draft_sport) > 4 || strlen($draft_sports[$draft->draft_sport]) == 0) { |
|
72 | 72 | $errors[] = "Draft sport is an invalid value."; |
73 | 73 | $valid = false; |
74 | 74 | } |
75 | 75 | |
76 | - if(!array_key_exists($draft->draft_style, $draft_styles)) { |
|
76 | + if (!array_key_exists($draft->draft_style, $draft_styles)) { |
|
77 | 77 | |
78 | 78 | $errors[] = "Draft style is an invalid value."; |
79 | 79 | $valid = false; |
80 | 80 | } |
81 | 81 | |
82 | - if(!$this->app['phpdraft.DraftRepository']->NameIsUnique($draft->draft_name, $draft->draft_id)) { |
|
82 | + if (!$this->app['phpdraft.DraftRepository']->NameIsUnique($draft->draft_name, $draft->draft_id)) { |
|
83 | 83 | $errors[] = "Draft name is already taken, please choose a different name."; |
84 | 84 | $valid = false; |
85 | 85 | } |
86 | 86 | |
87 | - if($draft->draft_rounds < 1 || $draft->draft_rounds > 30) { |
|
87 | + if ($draft->draft_rounds < 1 || $draft->draft_rounds > 30) { |
|
88 | 88 | $errors[] = "Invalid number of draft rounds."; |
89 | 89 | $valid = false; |
90 | 90 | } |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | $errors = array(); |
98 | 98 | $draft_statuses = $this->app['phpdraft.DraftDataRepository']->GetStatuses(); |
99 | 99 | |
100 | - if($old_status == "complete") { |
|
100 | + if ($old_status == "complete") { |
|
101 | 101 | $valid = false; |
102 | 102 | $errors[] = "The draft is completed, therefore its status cannot be changed."; |
103 | 103 | } |
104 | 104 | |
105 | - if($draft->draft_status == "complete") { |
|
105 | + if ($draft->draft_status == "complete") { |
|
106 | 106 | $valid = false; |
107 | 107 | $errors[] = "You cannot set the draft as completed manually."; |
108 | 108 | } |
109 | 109 | |
110 | - if(empty($draft->draft_status)) { |
|
110 | + if (empty($draft->draft_status)) { |
|
111 | 111 | $errors[] = "One or more missing fields."; |
112 | 112 | $valid = false; |
113 | 113 | } |
114 | 114 | |
115 | - if(!array_key_exists($draft->draft_status, $draft_statuses)) { |
|
115 | + if (!array_key_exists($draft->draft_status, $draft_statuses)) { |
|
116 | 116 | $errors[] = "Draft status is an invalid value."; |
117 | 117 | $valid = false; |
118 | 118 | } |
119 | 119 | |
120 | - if($draft->draft_status == "in_progress" && !$this->app['phpdraft.ManagerRepository']->DraftHasManagers($draft->draft_id)) { |
|
120 | + if ($draft->draft_status == "in_progress" && !$this->app['phpdraft.ManagerRepository']->DraftHasManagers($draft->draft_id)) { |
|
121 | 121 | $valid = false; |
122 | 122 | $errors[] = "A draft must have at least 2 managers before it can begin."; |
123 | 123 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $current_status_text = strtolower($draft_statuses[$draft->draft_status]); |
133 | 133 | $is_setting_up = $this->app['phpdraft.DraftService']->DraftSettingUp($draft); |
134 | 134 | |
135 | - if(!$is_setting_up) { |
|
135 | + if (!$is_setting_up) { |
|
136 | 136 | $valid = false; |
137 | 137 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is $current_status_text"; |
138 | 138 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $is_setting_up = $this->app['phpdraft.DraftService']->DraftSettingUp($draft); |
149 | 149 | $is_in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft); |
150 | 150 | |
151 | - if(!$is_setting_up && !$is_in_progress) { |
|
151 | + if (!$is_setting_up && !$is_in_progress) { |
|
152 | 152 | $valid = false; |
153 | 153 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is $current_status_text"; |
154 | 154 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $current_status_text = strtolower($draft_statuses[$draft->draft_status]); |
164 | 164 | $is_in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft); |
165 | 165 | |
166 | - if(!$is_in_progress) { |
|
166 | + if (!$is_in_progress) { |
|
167 | 167 | $valid = false; |
168 | 168 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is $current_status_text"; |
169 | 169 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $is_in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft); |
180 | 180 | $is_complete = $this->app['phpdraft.DraftService']->DraftComplete($draft); |
181 | 181 | |
182 | - if(!$is_complete && !$is_in_progress) { |
|
182 | + if (!$is_complete && !$is_in_progress) { |
|
183 | 183 | $valid = false; |
184 | 184 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is $current_status_text"; |
185 | 185 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $is_complete = $this->app['phpdraft.DraftService']->DraftComplete($draft); |
197 | 197 | $isLessThanTenMinutes = false; |
198 | 198 | |
199 | - if($is_complete) { |
|
199 | + if ($is_complete) { |
|
200 | 200 | $utc_timezone = new \DateTimeZone("UTC"); |
201 | 201 | $now_utc = new \DateTime(null, $utc_timezone); |
202 | 202 | $end_time = new \DateTime($draft->draft_end_time, $utc_timezone); |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | $end_seconds = $end_time->getTimestamp(); |
205 | 205 | $seconds_elapsed = $end_seconds - $now_seconds; |
206 | 206 | |
207 | - if($seconds_elapsed < 600) { |
|
207 | + if ($seconds_elapsed < 600) { |
|
208 | 208 | $isLessThanTenMinutes = true; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if(!$is_complete && !$is_in_progress) { |
|
212 | + if (!$is_complete && !$is_in_progress) { |
|
213 | 213 | $valid = false; |
214 | 214 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is $current_status_text"; |
215 | 215 | } |
216 | 216 | |
217 | - if($is_complete && !$isLessThanTenMinutes) { |
|
217 | + if ($is_complete && !$isLessThanTenMinutes) { |
|
218 | 218 | $valid = false; |
219 | 219 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is complete and beyond the ten minute grace period."; |
220 | 220 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $current_status_text = strtolower($draft_statuses[$draft->draft_status]); |
230 | 230 | $is_complete = $this->app['phpdraft.DraftService']->DraftComplete($draft); |
231 | 231 | |
232 | - if(!$is_complete) { |
|
232 | + if (!$is_complete) { |
|
233 | 233 | $valid = false; |
234 | 234 | $errors[] = "Unable to work on draft #$draft->draft_id: draft is $current_status_text"; |
235 | 235 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | $response->success = true; |
49 | 49 | $response->trade = $trade; |
50 | - } catch(\Exception $e) { |
|
50 | + } catch (\Exception $e) { |
|
51 | 51 | $response->success = false; |
52 | 52 | $response->errors = array($e->getMessage()); |
53 | 53 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $response->success = true; |
36 | 36 | $response->draft = $draft; |
37 | - }catch(\Exception $e) { |
|
37 | + } catch(\Exception $e) { |
|
38 | 38 | $response->success = false; |
39 | 39 | $response->errors = array($e->getMessage()); |
40 | 40 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $response->success = true; |
57 | 57 | $response->draft = $draft; |
58 | - }catch(\Exception $e) { |
|
58 | + } catch(\Exception $e) { |
|
59 | 59 | $response->success = false; |
60 | 60 | $response->errors = array($e->getMessage()); |
61 | 61 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $response->success = true; |
87 | 87 | $response->draft = $draft; |
88 | - }catch(\Exception $e) { |
|
88 | + } catch(\Exception $e) { |
|
89 | 89 | $response->success = false; |
90 | 90 | $response->errors = array($e->getMessage()); |
91 | 91 | } |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | try { |
29 | 29 | $draft = $this->app['phpdraft.DraftRepository']->Create($draft); |
30 | 30 | |
31 | - if($draft->using_depth_charts) { |
|
31 | + if ($draft->using_depth_charts) { |
|
32 | 32 | $depth_charts = $this->app['phpdraft.DepthChartPositionRepository']->Save($depthChartModel, $draft->draft_id); |
33 | 33 | } |
34 | 34 | |
35 | 35 | $response->success = true; |
36 | 36 | $response->draft = $draft; |
37 | - }catch(\Exception $e) { |
|
37 | + } catch (\Exception $e) { |
|
38 | 38 | $response->success = false; |
39 | 39 | $response->errors = array($e->getMessage()); |
40 | 40 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | try { |
49 | 49 | $draft = $this->app['phpdraft.DraftRepository']->Update($draft); |
50 | 50 | |
51 | - if($draft->using_depth_charts == 1) { |
|
51 | + if ($draft->using_depth_charts == 1) { |
|
52 | 52 | $this->app['phpdraft.DepthChartPositionRepository']->DeleteAllDepthChartPositions($draft->draft_id); |
53 | 53 | $depth_charts = $this->app['phpdraft.DepthChartPositionRepository']->Save($depthChartModel, $draft->draft_id); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $response->success = true; |
57 | 57 | $response->draft = $draft; |
58 | - }catch(\Exception $e) { |
|
58 | + } catch (\Exception $e) { |
|
59 | 59 | $response->success = false; |
60 | 60 | $response->errors = array($e->getMessage()); |
61 | 61 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $draft = $this->app['phpdraft.DraftRepository']->UpdateStatus($draft); |
71 | 71 | |
72 | 72 | //If we know we're moving from undrafted to in progress, perform the necessary setup steps: |
73 | - if($draft->draft_status != $old_status && $draft->draft_status == "in_progress") { |
|
73 | + if ($draft->draft_status != $old_status && $draft->draft_status == "in_progress") { |
|
74 | 74 | //Delete all trades |
75 | 75 | $this->app['phpdraft.TradeRepository']->DeleteAllTrades($draft->draft_id); |
76 | 76 | //Delete all picks |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $response->success = true; |
87 | 87 | $response->draft = $draft; |
88 | - }catch(\Exception $e) { |
|
88 | + } catch (\Exception $e) { |
|
89 | 89 | $response->success = false; |
90 | 90 | $response->errors = array($e->getMessage()); |
91 | 91 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $this->app['phpdraft.DraftRepository']->DeleteDraft($draft->draft_id); |
112 | 112 | |
113 | 113 | $response->success = true; |
114 | - } catch(\Exception $e) { |
|
114 | + } catch (\Exception $e) { |
|
115 | 115 | $response->success = false; |
116 | 116 | $response->errors = array($e->getMessage()); |
117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | try { |
126 | 126 | $response->draft_statistics = $this->app['phpdraft.DraftStatsRepository']->LoadDraftStats($draft_id); |
127 | 127 | $response->success = true; |
128 | - } catch(\Exception $e) { |
|
128 | + } catch (\Exception $e) { |
|
129 | 129 | $message = $e->getMessage(); |
130 | 130 | $response->success = false; |
131 | 131 | $response->errors[] = $message; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | $response->success = true; |
26 | 26 | $response->roundTimes = $roundTimes; |
27 | - }catch(\Exception $e) { |
|
27 | + } catch (\Exception $e) { |
|
28 | 28 | $response->success = false; |
29 | 29 | $response->errors = array($e->getMessage()); |
30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $current_pick = $this->app['phpdraft.PickRepository']->GetCurrentPick($draft); |
40 | 40 | $last_pick = $this->app['phpdraft.PickRepository']->GetPreviousPick($draft); |
41 | 41 | $current_round_picktime = $this->app['phpdraft.RoundTimeRepository']->LoadByRound($draft); |
42 | - } catch(\Exception $e) { |
|
42 | + } catch (\Exception $e) { |
|
43 | 43 | $response->success = false; |
44 | 44 | $response->errors = array($e->getMessage()); |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $response->success = true; |
48 | 48 | $response->timer_enabled = $current_round_picktime != null; |
49 | 49 | |
50 | - if(!$response->timer_enabled) { |
|
50 | + if (!$response->timer_enabled) { |
|
51 | 51 | return $response; |
52 | 52 | } |
53 | 53 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | $response->success = true; |
26 | 26 | $response->roundTimes = $roundTimes; |
27 | - }catch(\Exception $e) { |
|
27 | + } catch(\Exception $e) { |
|
28 | 28 | $response->success = false; |
29 | 29 | $response->errors = array($e->getMessage()); |
30 | 30 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $response->success = true; |
23 | 23 | $response->manager = $manager; |
24 | - }catch(\Exception $e) { |
|
24 | + } catch (\Exception $e) { |
|
25 | 25 | $response->success = false; |
26 | 26 | $response->errors = array($e->getMessage()); |
27 | 27 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | $response->success = true; |
39 | 39 | $response->managers = $managers; |
40 | - }catch(\Exception $e) { |
|
40 | + } catch (\Exception $e) { |
|
41 | 41 | $response->success = false; |
42 | 42 | $response->errors = array($e->getMessage()); |
43 | 43 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->app['phpdraft.ManagerRepository']->ReorderManagers($managersIdArray); |
53 | 53 | |
54 | 54 | $response->success = true; |
55 | - }catch(\Exception $e) { |
|
55 | + } catch (\Exception $e) { |
|
56 | 56 | $response->success = false; |
57 | 57 | $response->errors = array($e->getMessage()); |
58 | 58 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $managers = $this->app['phpdraft.ManagerRepository']->GetManagersByDraftOrder($draft_id); |
88 | 88 | $managersIdArray = array(); |
89 | 89 | |
90 | - foreach($managers as $manager) { |
|
90 | + foreach ($managers as $manager) { |
|
91 | 91 | $managersIdArray[] = $manager->manager_id; |
92 | 92 | } |
93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $response->managers = $managers; |
99 | 99 | $response->success = true; |
100 | - } catch(\Exception $e) { |
|
100 | + } catch (\Exception $e) { |
|
101 | 101 | $response->success = false; |
102 | 102 | $response->errors = array($e->getMessage()); |
103 | 103 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $response->success = true; |
23 | 23 | $response->manager = $manager; |
24 | - }catch(\Exception $e) { |
|
24 | + } catch(\Exception $e) { |
|
25 | 25 | $response->success = false; |
26 | 26 | $response->errors = array($e->getMessage()); |
27 | 27 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | $response->success = true; |
39 | 39 | $response->managers = $managers; |
40 | - }catch(\Exception $e) { |
|
40 | + } catch(\Exception $e) { |
|
41 | 41 | $response->success = false; |
42 | 42 | $response->errors = array($e->getMessage()); |
43 | 43 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->app['phpdraft.ManagerRepository']->ReorderManagers($managersIdArray); |
53 | 53 | |
54 | 54 | $response->success = true; |
55 | - }catch(\Exception $e) { |
|
55 | + } catch(\Exception $e) { |
|
56 | 56 | $response->success = false; |
57 | 57 | $response->errors = array($e->getMessage()); |
58 | 58 | } |