public function setTime($id = 0) { Auth::RequireManager(true); $this->Block = new Game_Block($id); if (!$this->Block->exists()) { exit("Block could not be found."); } if ($this->Block->fixture->get()->owner != Auth::Get("id")) { exit("You cannot manage this Fixture."); } if ($this->input->post()) { $this->Block->time = strtotime($this->input->post("date") . " " . $this->input->post("hour") . ":" . $this->input->post("minute")); if ($this->Block->setDate()) { $this->json->success(); } else { $this->json->error($this->Block->error->string); } } $this->load->view("game_blocks/setTime"); $this->template->disable(); }
public function Payment($id = 0, $status = 0) { Auth::RequireManager(true); $this->Payment = new Payment(); // Try finding the payment $this->Payment->include_related("fixture", array("owner"))->where("id", $id)->get(); // Make sure the payment exists if (!$this->Payment->exists()) { $this->json->error("Payment could not be found."); } // Make sure the payment has right status if (!in_array(strtolower($this->Payment->status), array("active"))) { $this->json->error("Payment has invalid status."); } // Make sure you are the owner of paid fixture if ($this->Payment->fixture_owner != Auth::Get("id")) { $this->json->error("Payment could not be found."); } // Make sure status is valid if (!in_array($status, array(0, 1))) { $this->json->error("Invalid payment status."); } // Set and save the status $this->Payment->paid = $status; $this->Payment->save(); // Send success response $this->json->success(); }
public function SaveTeamName($block = 0, $team = 0) { // Require Manager Login Auth::RequireManager(true); // Get Block $this->Block = new Game_Block($block); if (!$this->Block->exists()) { $this->json->error("Block could not be found."); } // Get Fixture $this->Fixture = $this->Block->fixture->get(); if (!$this->Fixture->exists()) { $this->json->error("Fixture could not be found."); } // Check ownership if ($this->Fixture->owner != Auth::Get("id")) { $this->json->error("You are not owner of this fixture."); } // Make sure the team is ok if (!in_array($team, array(1, 2))) { $this->json->error("Team could not be found."); } $this->Block->{"team_" . $team} = $this->input->post("name"); // Try saving if ($this->Block->save()) { $this->json->success(); } else { $this->json->error(strip_tags($this->Block->error->string)); } }
public function enter($player = 0, $block = 0) { Auth::RequireManager(); $this->Block = new Game_Block($block); if (!$this->Block->exists()) { Session::GoBack("Game could not be found."); } // Try Getting Fixture if (!$this->Block->fixture->get()->exists()) { Session::GoBack("Fixture could not be found."); } if ($this->Block->fixture->owner != Auth::Get("id")) { Session::GoBack("You cannot manage this block."); } $this->Account = new Account($player); if (!$this->Account->exists()) { Session::GoBack("Player could not be found."); } if (!$this->Block->is_related_to($this->Account)) { Session::GoBack("This player is not playing in this game."); } // Check the limit of this block $this->PlayersCount = $this->Block->account->include_join_fields()->where(array("active" => 1))->count(); if ($this->PlayersCount >= (int) $this->Block->fixture->type * 2) { Session::GoBack("This game is already full!"); } $this->Block->set_join_field($this->Account, "active", 1); Session::GoBack("Player has joined."); }
public function __construct() { parent::__construct(); // Require Manager Access Auth::RequireManager(); }