| @@ 216-228 (lines=13) @@ | ||
| 213 | if (isset($data['prizes'])) { |
|
| 214 | foreach ($data['prizes'] as $prize_data) { |
|
| 215 | if (! empty($prize_data['picture']['tmp_name'])) { |
|
| 216 | if ($prize_data['id']) { |
|
| 217 | $prize = $prize_mapper->findById($prize_data['id']); |
|
| 218 | } else { |
|
| 219 | $some_prizes = $prize_mapper->findBy(array( |
|
| 220 | 'game' => $game, |
|
| 221 | 'title' => $prize_data['title'] |
|
| 222 | )); |
|
| 223 | if (count($some_prizes) == 1) { |
|
| 224 | $prize = $some_prizes[0]; |
|
| 225 | } else { |
|
| 226 | return false; |
|
| 227 | } |
|
| 228 | } |
|
| 229 | ErrorHandler::start(); |
|
| 230 | $filename = "game-" . $game->getId() . "-prize-" . $prize->getId() . "-" . $prize_data['picture']['name']; |
|
| 231 | move_uploaded_file($prize_data['picture']['tmp_name'], $path . $filename); |
|
| @@ 444-456 (lines=13) @@ | ||
| 441 | if (isset($data['prizes'])) { |
|
| 442 | foreach ($data['prizes'] as $prize_data) { |
|
| 443 | if (! empty($prize_data['picture_file']['tmp_name']) && ! $prize_data['picture_file']['error']) { |
|
| 444 | if ($prize_data['id']) { |
|
| 445 | $prize = $prize_mapper->findById($prize_data['id']); |
|
| 446 | } else { |
|
| 447 | $some_prizes = $prize_mapper->findBy(array( |
|
| 448 | 'game' => $game, |
|
| 449 | 'title' => $prize_data['title'] |
|
| 450 | )); |
|
| 451 | if (count($some_prizes) == 1) { |
|
| 452 | $prize = $some_prizes[0]; |
|
| 453 | } else { |
|
| 454 | return false; |
|
| 455 | } |
|
| 456 | } |
|
| 457 | // Remove if existing image |
|
| 458 | if ($prize->getPicture() && file_exists($prize->getPicture())) { |
|
| 459 | unlink($prize->getPicture()); |
|