| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * File for changing the game mode.
- *
- * Implements an action function to be called from the {@see Controller}.
- *
- * @category Action
- */
- require_once(PATH::ACTION . "Action.php");
- /**
- * Sets the score for a team.
- *
- * Reads the POST parameters looking for the following KEYS:
- * player
- * team
- * score
- * Validates the data and sets the score.
- */
- class Change_Game_Mode_Action extends Action{
-
- /**
- * Executes the action.
- * @todo: secure
- */
- public function execute(){
- $player = filter_input(INPUT_GET, "player");
- $mode = filter_input(INPUT_GET, "mode");
- if ($mode != GAME_MODE_ID::NORMAL && $mode != GAME_MODE_ID::RTA){
- $this->code = 400;
- $this->message = "POST parameter 'mode' not specified or invalid.";
- return;
- }
- $statement = get_context()->get_db()->prepare("
- UPDATE player
- SET mode = :mode
- WHERE id = :id;
- ");
- $statement->bindValue(":mode", $mode, SQLITE3_TEXT);
- $statement->bindValue(":id", $player, SQLITE3_TEXT);
- $statement->execute();
- $this->code = 204;
- $this->message = "No content.";
- return;
- }
- }
|