<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once 'initClass.php';
require_once 'init.php';
if (isset($_SESSION['idJoueurCourant']) && $_SESSION['idJoueurCourant'] != '') {
    $JoueurManager = new JoueurManager($db);
    $Joueur = new Joueur($JoueurManager->get($_SESSION['idJoueurCourant']));
    $listePersonnage = $JoueurManager->getListePersonnageFromJoueur($Joueur->getId());
    $PersonnageManager = new PersonnageManager($db);
    $Personnages = array();
    $i = 0;
    if (count($listePersonnage) > 0) {
        foreach ($listePersonnage as $key => $item) {
            if (!isset($_SESSION['personnageCourant'])) {
                if ($i == 0) {
                    $_SESSION['personnageCourant'] = $item->id;
                } else {
                    $Personnages[] = new Personnage($PersonnageManager->get($item->id));
                }
            } else {
                if ($item->id != $_SESSION['personnageCourant']) {
                    $Personnages[] = new Personnage($PersonnageManager->get($item->id));
                }
            }
            $i = $i + 1;
        }
    }
    $Personnage = new Personnage($PersonnageManager->get($_SESSION['personnageCourant']));
Example #2
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once 'init.php';
print $stromae;
if (isset($_SESSION['idJoueurCourant']) && $_SESSION['idJoueurCourant'] != '') {
    $JoueurManager = new JoueurManager($db);
    $Joueur = new Joueur($JoueurManager->get($_SESSION['idJoueurCourant']));
    $Privilege = new Privilege($JoueurManager->getPrivilege($Joueur->getId()));
    $listePersonnage = $JoueurManager->getListePersonnageFromJoueur($Joueur->getId());
    //var_dump($listePersonnage);
    $PersonnageManager = new PersonnageManager($db);
    $Personnages = array();
    $i = 0;
    if (count($listePersonnage) > 0) {
        foreach ($listePersonnage as $key => $item) {
            if (!isset($_SESSION['personnageCourant'])) {
                if ($i == 0) {
                    $_SESSION['personnageCourant'] = $item->id;
                } else {
                    $Personnages[] = new Personnage($PersonnageManager->get($item->id));
                }
            } else {
                if ($item->id != $_SESSION['personnageCourant']) {
                    $Personnages[] = new Personnage($PersonnageManager->get($item->id));
                }
            }
            $i = $i + 1;
        }
<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once 'initClass.php';
require_once 'init.php';
if (isset($_SESSION['idJoueurCourant']) && $_SESSION['idJoueurCourant'] != '') {
    // Instance manager
    $PersonnageTypeManager = new PersonnageTypeManager($db);
    $PersonnageManager = new PersonnageManager($db);
    $JoueurManager = new JoueurManager($db);
    $EvolutionManager = new EvolutionManager($db);
    $FormulaireUniqueId = new FormulaireUniqueId();
    $Joueur = new Joueur($JoueurManager->get($_SESSION['idJoueurCourant']));
    $Privilege = new Privilege($JoueurManager->getPrivilege($Joueur->getId()));
    if ($Privilege->hasPermission('personnageCreer')) {
        // Insertion du nouveau personnage.
        if (isset($_POST) && count($_POST) > 0) {
            if ($FormulaireUniqueId->validate()) {
                $insert = true;
                // Si un champ n'a pas été saisie par l'utisateur
                foreach ($_POST as $key => $value) {
                    if ($value == '') {
                        $insert = false;
                    }
                }
                if ($insert) {
                    // Personnagetype avec les données du POST
                    $PersonnageType = new PersonnageType($PersonnageTypeManager->get($_POST['personnageTypeId']));
                    // Création du personnage avec les données POST
     // Le traitement de l'insert
     if ($_POST['action'] == "ajouter") {
         $insert = true;
         // Si un champ n'a pas été saisie par l'utisateur
         foreach ($_POST as $key => $value) {
             if ($value == '') {
                 $insert = false;
             }
         }
         if ($insert) {
             $joueurPost = $JoueurManager->login($_POST['login']);
             if ($joueurPost) {
                 // Instance du joueur saisie par le formulaire
                 $joueurPost = new Joueur($joueurPost);
                 // Suppresion du joueur de son groupe précédent
                 $RoleManager->delete_joueur_role($joueurPost->getId());
                 // Insertion table de liaison
                 $RoleManager->insert_joueur_role($joueurPost->getId(), $_POST['roleId']);
             }
         }
     } elseif ($_POST['action'] == "supprimer") {
         $joueurId = $_POST['joueurId'];
         $RoleManager->delete_joueur_role($joueurId);
         echo true;
         die;
     }
 }
 //Liste des rôles
 $roleGetAll = $RoleManager->getAll();
 $listeRole = array();
 if (count($roleGetAll) > 0) {