public function insertAction($args)
 {
     if (strlen($_POST['title'] <= 20)) {
         $title = htmlentities(trim($_POST['title']));
     } else {
         echo "Le titre est trop long";
     }
     if (strlen($_POST['description'] <= 100)) {
         $description = htmlentities(trim($_POST['description']));
     } else {
         echo "La description est trop longue";
     }
     $id_member = $_SESSION['idUser'];
     $id_contest = $_SESSION['idContest'];
     $nb_like = 0;
     $id = '0';
     $image_link = $_POST['imgSelected'];
     //On vérifie si l'utilisateur a déjà participé ou pas
     $verifBdd = new pictureModel();
     $verifBdd->getAll(true);
     //$test = $verifBdd->getIdMember();
     $hasParticipate = false;
     foreach ($verifBdd as $obj) {
         if ($obj['id_member'] == $id_member && $obj['id_contest'] == $id_contest) {
             $hasParticipate = true;
         }
     }
     if (!$hasParticipate) {
         //Si non, on enregistre
         $participateObj = new pictureModel($id, $title, $description, $image_link, $id_contest, $id_member, $nb_like);
         $participateObj->save();
         header("Location: /contest");
     } else {
         header("Location: /contest");
     }
 }
Beispiel #2
0
<!-- Page Content -->
<div class="container" id="contest">

    <!-- Page Header -->
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">Contributions</h1>

            <div class="barre"></div>
        </div>
    </div><!-- /.row -->

    <?php 
$participationBdd = new pictureModel();
$participationBdd->getAll(true);
$listLikes = new voteModel();
$listLikes->getAll(true);
$hasParticipate = false;
?>

    <div class="row">
        <!-- Galerie photos -->
        <?php 
foreach ($participationBdd as $userParticipate) {
    if ($userParticipate['id_contest'] == $_SESSION['idContest']) {
        ?>
                <div class="col-lg-4 col-md-4 col-sm-5 col-xs-12 contribution">
                    <div class="img_contest">
                        <?php 
        echo '<img id="img-popup" class="img-responsive" src="' . $userParticipate['image_link'] . '" data-toggle="modal" data-target="#myModal" data-src="' . $userParticipate['image_link'] . '" data-title="' . $userParticipate["title"] . '">';
        ?>