public function insertAction($args)
 {
     require_once APPLICATION_PATH . '/public/facebook-php-sdk-v4-5.0.0/src/Facebook/autoload.php';
     //Variables sans Logo & Banner
     $id = '0';
     $title = $_POST['title'];
     $date_begin = $_POST['begin'];
     $date_ending = $_POST['ending'];
     $description = $_POST['description'];
     $color_theme = $_POST['color-theme'];
     $active_contest = 0;
     $delete_contest = 0;
     if (!empty($_POST['active-contest'])) {
         $active_contest = $_POST['active-contest'];
     }
     //Création de l'album avec le logo et le banner
     $this->createAlbum();
     //Récupération de l'album ID
     $albumId = $this->getAlbum();
     //Récupération des URL du logo et du banner
     $template = $this->getBannerLogo($albumId);
     //Logo & Banner
     $logo = $template[0];
     $banner = $template[1];
     $addContestObj = new contestModel($id, $title, $date_begin, $date_ending, $description, $color_theme, $banner, $logo, $active_contest, $delete_contest);
     $getActiveContest = $this->getActiveContest();
     if (!$getActiveContest == FALSE & isset($_POST['active-contest'])) {
         $this->unsetActiveContest($getActiveContest['id']);
     }
     $addContestObj->save();
     header("Location: /contestList");
 }
 public function updateAction($args)
 {
     require_once APPLICATION_PATH . '/public/facebook-php-sdk-v4-5.0.0/src/Facebook/autoload.php';
     // On récupère nos valeurs
     $id = $args['0'];
     $title = $_POST['update-title'];
     $date_begin = $_POST['update-begin'];
     $date_ending = $_POST['update-ending'];
     $description = $_POST['update-description'];
     $color_theme = $_POST['update-color-theme'];
     $logo = $_FILES['update-logo']['name'];
     $banner = $_FILES['update-banner']['name'];
     if (!empty($_POST['active-contest'])) {
         $active_contest = $_POST['active-contest'];
     } else {
         $active_contest = 0;
     }
     if ($logo != NULL || $banner != NULL) {
         $albumId = $this->getAlbum();
         //Récupération des IDs du logo et du banner
         $IDs = $this->getBannerLogo($albumId);
         //Supprimer les photos existantes dans l'album
         $this->deleteBannerLogo($IDs);
         //Upload banner & logo
         $this->updateAlbum($albumId);
         //Récupération des URL du logo et du banner
         $URLs = $this->getSourceBannerLogo($albumId);
         $logo = $URLs['1'];
         $banner = $URLs['0'];
     } else {
         $oldBannerLogo = $this->getContest($title);
         $logo = $oldBannerLogo['logo'];
         $banner = $oldBannerLogo['banner'];
     }
     // On vérifie si tous les champs ne sont pas null
     if (empty($title) or empty($date_begin) or empty($date_ending) or empty($description)) {
         // Si les champs sont vides, on affiche une erreur
         echo '<font color="red">Attention, les champs doivent être remplis !</font>';
     } else {
         try {
             $updateContestObj = new contestModel($id, $title, $date_begin, $date_ending, $description, $color_theme, $banner, $logo, $active_contest);
             $getActiveContest = $this->getActiveContest();
             if (!$getActiveContest == FALSE & isset($_POST['active-contest'])) {
                 $this->unsetActiveContest($getActiveContest['id']);
             }
             $updateContestObj->save();
         } catch (Exception $e) {
             die('Erreur : ' . $e->getMessage());
         }
         header("Location: /contestList");
     }
 }