Delete_Team_Action.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * File for the team deletion action.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::ACTION . "Action.php");
  12. /**
  13. * Deletes a team.
  14. *
  15. * Reads the POST parameters looking for the following KEYS:
  16. * player: the team owner's player id.
  17. * id: the team id.
  18. *
  19. * @category Action
  20. */
  21. class Delete_Team_Action extends Action{
  22. /**
  23. * Executes the action.
  24. * @todo secure
  25. */
  26. function execute(){
  27. $player = filter_input(INPUT_POST, 'player');
  28. $id = filter_input(INPUT_POST, 'id');
  29. $statement = get_context()->get_db()->prepare('DELETE FROM team WHERE player = :player AND id = :id;');
  30. $statement->bindValue(':player', $player, SQLITE3_TEXT);
  31. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  32. $statement->execute();
  33. $statement = get_context()->get_db()->prepare('DELETE FROM team_unit WHERE team = :id;');
  34. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  35. $statement->execute();
  36. $this->code = 204;
  37. $this->message = "No content.";
  38. return;
  39. }
  40. }