@@ -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,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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public function ConvertTimeForClientDisplay($time_value) { |
| 14 | - if(empty($time_value)) { |
|
| 14 | + if (empty($time_value)) { |
|
| 15 | 15 | return null; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $supposed_utc_index = $time_value_length > 3 ? $time_value_length - 3 : 0; |
| 20 | 20 | $utc_index = strstr($time_value, "UTC"); |
| 21 | 21 | |
| 22 | - if($utc_index == $supposed_utc_index) { |
|
| 22 | + if ($utc_index == $supposed_utc_index) { |
|
| 23 | 23 | return $time_value; |
| 24 | 24 | } else { |
| 25 | 25 | return $time_value . " UTC"; |
@@ -30,19 +30,19 @@ |
||
| 30 | 30 | |
| 31 | 31 | $unassignedPicks = array(); |
| 32 | 32 | |
| 33 | - foreach($allManagerPicks as $pick) { |
|
| 34 | - if(is_null($pick->depth_chart_position_id)) { |
|
| 33 | + foreach ($allManagerPicks as $pick) { |
|
| 34 | + if (is_null($pick->depth_chart_position_id)) { |
|
| 35 | 35 | $unassignedPicks[] = $pick; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $response->depthChartPositions[] = new DepthChartDisplayModel(null, 'Unassigned', null, $unassignedPicks); |
| 40 | 40 | |
| 41 | - foreach($depthChartPositions as $position) { |
|
| 41 | + foreach ($depthChartPositions as $position) { |
|
| 42 | 42 | $picks = array(); |
| 43 | 43 | |
| 44 | - foreach($allManagerPicks as $pick) { |
|
| 45 | - if($pick->depth_chart_position_id == $position->id) { |
|
| 44 | + foreach ($allManagerPicks as $pick) { |
|
| 45 | + if ($pick->depth_chart_position_id == $position->id) { |
|
| 46 | 46 | $picks[] = $pick; |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | $this->mailer->Host = MAIL_SERVER; |
| 24 | 24 | $this->mailer->Port = MAIL_PORT; |
| 25 | 25 | |
| 26 | - if(MAIL_DEVELOPMENT != true) { |
|
| 26 | + if (MAIL_DEVELOPMENT != true) { |
|
| 27 | 27 | $this->mailer->SMTPAuth = true; |
| 28 | 28 | $this->mailer->Username = MAIL_USER; |
| 29 | 29 | $this->mailer->Password = MAIL_PASS; |
| 30 | 30 | |
| 31 | - if(MAIL_USE_ENCRYPTION == true) { |
|
| 31 | + if (MAIL_USE_ENCRYPTION == true) { |
|
| 32 | 32 | $this->mailer->SMTPSecure = MAIL_ENCRYPTION; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function SendMail(MailMessage $message) { |
| 41 | - foreach($message->to_addresses as $address => $name) { |
|
| 41 | + foreach ($message->to_addresses as $address => $name) { |
|
| 42 | 42 | $this->mailer->addAddress($address, $name); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $this->mailer->Body = $message->body; |
| 50 | 50 | |
| 51 | - if(!$this->mailer->send()) { |
|
| 51 | + if (!$this->mailer->send()) { |
|
| 52 | 52 | throw new \Exception("Unable to send mail: " . $this->mailer->ErrorInfo); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function GetCurrentUser() { |
| 20 | 20 | $token = $this->app['security.token_storage']->getToken(); |
| 21 | 21 | |
| 22 | - if($token == null) { |
|
| 22 | + if ($token == null) { |
|
| 23 | 23 | //In public actions, this isn't an exception - we're just not logged in. |
| 24 | 24 | return null; |
| 25 | 25 | //throw new \Exception("Username not found."); |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | //This is a hack to make accessing logged in user info from anonymous routes possible: |
| 34 | 34 | public function GetUserFromHeaderToken(Request $request) { |
| 35 | - $request_token = $request->headers->get(AUTH_KEY_HEADER,''); |
|
| 35 | + $request_token = $request->headers->get(AUTH_KEY_HEADER, ''); |
|
| 36 | 36 | |
| 37 | - if(empty($request_token)) { |
|
| 37 | + if (empty($request_token)) { |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $email = $decoded->name; |
| 45 | 45 | |
| 46 | 46 | return $this->app['phpdraft.LoginUserRepository']->Load($email); |
| 47 | - }catch(\Exception $ex) { |
|
| 47 | + } catch (\Exception $ex) { |
|
| 48 | 48 | return null; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | try { |
| 56 | 56 | $response->commissioners = $this->app['phpdraft.LoginUserRepository']->SearchCommissioners($searchTerm); |
| 57 | 57 | $response->success = true; |
| 58 | - } catch(\Exception $ex) { |
|
| 58 | + } catch (\Exception $ex) { |
|
| 59 | 59 | $message = $ex->getMessage(); |
| 60 | 60 | $response->success = false; |
| 61 | 61 | $response->errors[] = $message; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | $response->commissioner = $this->app['phpdraft.LoginUserRepository']->LoadPublicById($commish_id); |
| 72 | 72 | $response->success = true; |
| 73 | - } catch(\Exception $ex) { |
|
| 73 | + } catch (\Exception $ex) { |
|
| 74 | 74 | $message = $ex->getMessage(); |
| 75 | 75 | $response->success = false; |
| 76 | 76 | $response->errors[] = $message; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $response->users = $this->app['phpdraft.LoginUserRepository']->LoadAll(); |
| 87 | 87 | $response->roles = $this->app['phpdraft.LoginUserRepository']->GetRoles(); |
| 88 | 88 | $response->success = true; |
| 89 | - } catch(\Exception $e) { |
|
| 89 | + } catch (\Exception $e) { |
|
| 90 | 90 | $message = $e->getMessage(); |
| 91 | 91 | $response->success = false; |
| 92 | 92 | $response->errors[] = $message; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $message = new MailMessage(); |
| 111 | 111 | |
| 112 | - $message->to_addresses = array ( |
|
| 112 | + $message->to_addresses = array( |
|
| 113 | 113 | $user->email => $user->name |
| 114 | 114 | ); |
| 115 | 115 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $this->app['phpdraft.EmailService']->SendMail($message); |
| 129 | 129 | |
| 130 | 130 | $response->success = true; |
| 131 | - }catch(\Exception $e) { |
|
| 131 | + } catch (\Exception $e) { |
|
| 132 | 132 | //$this->app['db']->rollback(); |
| 133 | 133 | |
| 134 | 134 | $response->success = false; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $user->verificationKey = $this->app['phpdraft.SaltService']->GenerateSalt(); |
| 152 | 152 | |
| 153 | 153 | //Found out that forward slashes are no good for URLs. Go figure. |
| 154 | - while(strpos($user->verificationKey, '/') != 0) { |
|
| 154 | + while (strpos($user->verificationKey, '/') != 0) { |
|
| 155 | 155 | $user->verificationKey = $this->app['phpdraft.SaltService']->GenerateSalt(); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $message = new MailMessage(); |
| 166 | 166 | |
| 167 | - $message->to_addresses = array ( |
|
| 167 | + $message->to_addresses = array( |
|
| 168 | 168 | $user->email => $user->name |
| 169 | 169 | ); |
| 170 | 170 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $response->success = true; |
| 188 | 188 | |
| 189 | 189 | $this->app['db']->commit(); |
| 190 | - }catch(\Exception $e) { |
|
| 190 | + } catch (\Exception $e) { |
|
| 191 | 191 | $this->app['db']->rollback(); |
| 192 | 192 | |
| 193 | 193 | $response->success = false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $response->success = true; |
| 213 | 213 | |
| 214 | 214 | $this->app['db']->commit(); |
| 215 | - }catch(\Exception $e) { |
|
| 215 | + } catch (\Exception $e) { |
|
| 216 | 216 | $this->app['db']->rollback(); |
| 217 | 217 | |
| 218 | 218 | $response->success = false; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $user->name = $name; |
| 235 | 235 | |
| 236 | 236 | //Update user email, invalidate login |
| 237 | - if(!empty($email) && !StringUtils::equals($email, $user->email)) { |
|
| 237 | + if (!empty($email) && !StringUtils::equals($email, $user->email)) { |
|
| 238 | 238 | $user->email = $email; |
| 239 | 239 | $user->enabled = false; |
| 240 | 240 | $invalidateLogin = true; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $sendEmail = true; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if(!empty($newPassword)) { |
|
| 245 | + if (!empty($newPassword)) { |
|
| 246 | 246 | $invalidateLogin = true; |
| 247 | 247 | $user->salt = $this->app['phpdraft.SaltService']->GenerateSalt(); |
| 248 | 248 | $user->password = $this->app['security.encoder.digest']->encodePassword($newPassword, $user->salt); |
@@ -250,15 +250,15 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $response = new PhpDraftResponse(); |
| 252 | 252 | |
| 253 | - try{ |
|
| 253 | + try { |
|
| 254 | 254 | $this->app['db']->beginTransaction(); |
| 255 | 255 | |
| 256 | 256 | $user = $this->app['phpdraft.LoginUserRepository']->Update($user); |
| 257 | 257 | |
| 258 | - if($sendEmail) { |
|
| 258 | + if ($sendEmail) { |
|
| 259 | 259 | $message = new MailMessage(); |
| 260 | 260 | |
| 261 | - $message->to_addresses = array ( |
|
| 261 | + $message->to_addresses = array( |
|
| 262 | 262 | $user->email => $user->name |
| 263 | 263 | ); |
| 264 | 264 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $response->sendEmail = $sendEmail; |
| 283 | 283 | |
| 284 | 284 | $this->app['db']->commit(); |
| 285 | - }catch(\Exception $e) { |
|
| 285 | + } catch (\Exception $e) { |
|
| 286 | 286 | $this->app['db']->rollback(); |
| 287 | 287 | |
| 288 | 288 | $response->success = false; |
@@ -298,16 +298,16 @@ discard block |
||
| 298 | 298 | try { |
| 299 | 299 | //Find all drafts this user owns |
| 300 | 300 | $drafts = $this->app['phpdraft.DraftRepository']->GetAllDraftsByCommish($user->id); |
| 301 | - foreach($drafts as $draft) { |
|
| 301 | + foreach ($drafts as $draft) { |
|
| 302 | 302 | $response = $this->app['phpdraft.DraftService']->DeleteDraft($draft); |
| 303 | - if(!$response->success) { |
|
| 303 | + if (!$response->success) { |
|
| 304 | 304 | throw new \Exception("Unable to recursively delete draft or one of its children."); |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | $this->app['phpdraft.LoginUserRepository']->Delete($user); |
| 308 | 308 | |
| 309 | 309 | $response->success = true; |
| 310 | - } catch(\Exception $e) { |
|
| 310 | + } catch (\Exception $e) { |
|
| 311 | 311 | $message = $e->getMessage(); |
| 312 | 312 | $response->success = false; |
| 313 | 313 | $response->errors[] = $message; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $email = $decoded->name; |
| 45 | 45 | |
| 46 | 46 | return $this->app['phpdraft.LoginUserRepository']->Load($email); |
| 47 | - }catch(\Exception $ex) { |
|
| 47 | + } catch(\Exception $ex) { |
|
| 48 | 48 | return null; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $this->app['phpdraft.EmailService']->SendMail($message); |
| 129 | 129 | |
| 130 | 130 | $response->success = true; |
| 131 | - }catch(\Exception $e) { |
|
| 131 | + } catch(\Exception $e) { |
|
| 132 | 132 | //$this->app['db']->rollback(); |
| 133 | 133 | |
| 134 | 134 | $response->success = false; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $response->success = true; |
| 188 | 188 | |
| 189 | 189 | $this->app['db']->commit(); |
| 190 | - }catch(\Exception $e) { |
|
| 190 | + } catch(\Exception $e) { |
|
| 191 | 191 | $this->app['db']->rollback(); |
| 192 | 192 | |
| 193 | 193 | $response->success = false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $response->success = true; |
| 213 | 213 | |
| 214 | 214 | $this->app['db']->commit(); |
| 215 | - }catch(\Exception $e) { |
|
| 215 | + } catch(\Exception $e) { |
|
| 216 | 216 | $this->app['db']->rollback(); |
| 217 | 217 | |
| 218 | 218 | $response->success = false; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $response->sendEmail = $sendEmail; |
| 283 | 283 | |
| 284 | 284 | $this->app['db']->commit(); |
| 285 | - }catch(\Exception $e) { |
|
| 285 | + } catch(\Exception $e) { |
|
| 286 | 286 | $this->app['db']->rollback(); |
| 287 | 287 | |
| 288 | 288 | $response->success = false; |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public $success; |
| 14 | 14 | public $errors; |
| 15 | 15 | |
| 16 | - public function responseType($successResponse = Response::HTTP_OK){ |
|
| 16 | + public function responseType($successResponse = Response::HTTP_OK) { |
|
| 17 | 17 | return $this->success |
| 18 | 18 | ? $successResponse |
| 19 | 19 | : Response::HTTP_BAD_REQUEST; |