Ejemplo n.º 1
0
 public static function getLstSigned($id_user)
 {
     $lst = array();
     global $db;
     $sel = "SELECT      DISTINCT g.*\n                FROM        " . self::TABLE_NAME . " g\n                INNER JOIN  " . diplo_player_game::TABLE_NAME . " lk\n                ON          g.id = lk.id_game\n                WHERE       lk.id_player = {$id_user}\n                ORDER BY    g.name";
     $res = $db->query($sel);
     $lst = array();
     while ($r = $res->fetchArray()) {
         $game = new diplo_game();
         $game->openFromResultSet($r);
         $lst[] = $game;
     }
     return $lst;
 }
Ejemplo n.º 2
0
</table>
<h3>Rejoindre une partie</h3>
<table cellspacing="0" cellpadding="0" style="width:50%;">
    <tr>
        <th>
            Nom
        </th>
        <th>
            Nb joueurs
        </th>
        <th>
            Actions
        </th>
    </tr>
    <?php 
foreach (diplo_game::getLstDipo($_SESSION['user']['id']) as $game) {
    ?>
        <tr>
            <td>
                <?php 
    echo $game->fields['name'];
    ?>
            </td>
            <td style="text-align:center;">
                <?php 
    echo "/" . $game->fields['max_players'];
    ?>
            </td>
            <td>
                <?php 
    /*if($game->fields['id_user'] == $_SESSION['user']['id']){
Ejemplo n.º 3
0
        break;
    case 'edit_game':
        if (isset($_GET['id']) && $_GET['id'] > 0) {
            $id = $_GET['id'];
            $game = new diplo_game();
            $game->open($id);
            $players = $game->getPlayers();
            if ($game->fields['id_user'] == $_SESSION['user']['id']) {
                include "common/edit_game.php";
            } else {
                redirect('index.php');
            }
        } else {
            redirect('index.php');
        }
        break;
    case 'save_game':
        if (isset($_POST['name_game']) && trim($_POST['name_game']) != '') {
            $diplo_game = new diplo_game();
            if (isset($_POST['id']) && $_POST['id'] != '' && $_POST['id'] > 0) {
                $diplo_game->open($_POST['id']);
            }
            $diplo_game->fields['name'] = trim($_POST['name_game']);
            $diplo_game->fields['max_players'] = $_POST['nb_players'];
            $diplo_game->fields['id_user'] = $_SESSION['user']['id'];
            $diplo_game->save();
            $diplo_game->addPlayer($_SESSION['user']['id'], $_POST['puissance']);
        }
        redirect('index.php');
        break;
}