/** * Edit this player's character name */ function edit_name($player_id = 0) { $page = $this->page; // Player must exist $this->load->model('playermodel'); $player = $this->playermodel->get_by_id($player_id); validate_exists($player->player_id, 'No such player.', 'home/dashboard'); // Player must be owned by the currently logged in user validate_matches($player->user_id, $page['user']->id, 'You don\'t own that ', 'home/dashboard'); // Validate form $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Name', 'required|max_length[200]'); if ($this->form_validation->run() == FALSE) { // Show the form $page['player'] = $player; $page['content'] = 'player_edit_name_form'; $this->load->view('template', $page); } else { // Update the player $playerupdate = new stdClass(); $playerupdate->name = $this->input->post('name'); $this->playermodel->update($player_id, $playerupdate); $this->session->set_flashdata('notice', 'Player Name Updated.'); redirect('player/view/' . $player_id, 'refresh'); } }
/** * Delete an order */ function delete($command_id = 0, $order_id = 0) { $page = $this->page; // Command and orders must exist $this->load->model('commandmodel'); $command = $this->commandmodel->get_by_id($command_id); validate_exists($command->command_id, 'No such command.', 'home/dashboard'); $this->load->model('ordermodel'); $order = $this->ordermodel->get_by_id($order_id); validate_exists($order->order_id, 'No such order.', 'command/view/' . $command_id); // Must be playing on the commands faction and have permission $this->load->model('gamemodel'); $game = $this->gamemodel->get_by_id($command->game_id); $this->load->model('playermodel'); $player = $this->playermodel->get_by_user_game($page['user']->id, $game->game_id); validate_matches($command->faction_id, $player->faction_id, 'Not authorized.', 'game/view/' . $game->game_id); $this->load->model('ordermodel'); $this->ordermodel->delete($order_id); $this->session->set_flashdata('notice', 'Order deleted.'); redirect('command/view/' . $command_id, 'refresh'); }
/** * Update chat */ function chat_update($faction_id = 0) { $page = $this->page; $this->load->model('factionmodel'); $faction = $this->factionmodel->get_by_id($faction_id); validate_exists($faction->faction_id, 'No such faction.', 'home/dashboard'); // Must be part of this faction to join chat $this->load->model('playermodel'); $player = $this->playermodel->get_by_user_game($page['user']->id, $faction->game_id); validate_exists($player->player_id, 'Access Denied...', 'faction/view/' . $faction_id); $time = $this->input->post('chattime'); $this->load->model('chatmodel'); $page['chats'] = $this->chatmodel->get_new($faction_id, $time); $this->load->view('chatupdate', $page); }
/** * Update the game turn */ function update_turn($game_id = 0, $value = 0) { $page = $this->page; $this->load->model('gamemodel'); $page['game'] = $this->gamemodel->get_by_id($game_id); validate_exists($page['game']->game_id, 'No such game.', 0, 'templatexml'); // Away we go $page['game']->turn += $value; $this->gamemodel->update($game_id, $page['game']); $this->session->set_flashdata('notice', 'Game updated.'); redirect('game/view/' . $game_id, 'refresh'); }