Beispiel #1
0
echo  $result ? 1 : 0;
die();  */
if ($_POST['command_id']) {
    $command_id = $_POST['command_id'];
    $avialable_commands = $command_model->get_available_commands($user_id);
    $flag = false;
    foreach ($avialable_commands as $command) {
        if ($command['groupmember_group_id'] == $command_id) {
            $flag = true;
            break;
        }
    }
    if ($flag) {
        $current_command_id = $command_model->get_command_id($user_id, $game_id);
        if ($current_command_id == 0) {
            $command_model->add_request($game, $command_id);
            $smarty->assign('info_mess', "Заявка отправлена.");
            $smarty->assign('game', $game);
            $smarty->assign('game_id', $game_id);
            $smarty->assign('off_div', "style='display: none'");
            $smarty->assign('info_div', "style='display: block'");
            include "footer.php";
            die;
        } else {
            $smarty->assign('info_mess', "Вы уже учасвутете в этой игре.");
            $smarty->assign('game', $game);
            $smarty->assign('game_id', $game_id);
            $smarty->assign('off_div', "style='display: none'");
            $smarty->assign('info_div', "style='display: block'");
            include "footer.php";
            die;
// Get info (post only)
$task = isset($_POST['action']) ? $_POST['action'] : NULL;
// Must be logged in to use tasks below this section
if (!$user->user_exists) {
    //echo json_encode(array('result' => FALSE, 'err' => 1));
    //exit();
}
$command_model = new se_gamecommand();
if ($task == 'add_request') {
    $game_id = isset($_POST['game_id']) ? $_POST['game_id'] : NULL;
    $command_id = isset($_POST['command_id']) ? $_POST['command_id'] : NULL;
    if ($command_model->get_request($game_id, $command_id)) {
        echo "Команда уже участвует в игре";
        die;
    }
    $result = $command_model->add_request($game_id, $command_id, GAME_START_FIXED_TIME);
    if ($result) {
        echo "Заявка отправлена";
    } else {
        echo "Ошибка отправки";
    }
    die;
} else {
    if ($task == 'get_command') {
        $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : NULL;
        $game_id = isset($_POST['game_id']) ? $_POST['game_id'] : NULL;
        $commands = $command_model->get_available_commands($user_id);
        if (count($commands) == 0) {
            echo "Нет команд. Для участия необходимо иметь команду или быть доверенным представителем команды.<br /><a href='/user_group_add.php'>Создать команду!</a>";
        } else {
            foreach ($commands as $command) {