public function register($loginUser, $passwordUser, $emailUser, $nameUser, $firstNameUser, $idFormation) { $getDoublon = new UserDAO(); $doublonEmail = $getDoublon->getDoublonByEmail($emailUser, ''); $doublonLogin = $getDoublon->getDoublonByLogin($loginUser, ''); if ($doublonEmail) { $_SESSION['error'] = 'Un utilisateur avec le même email existe déjà !'; $_SESSION['display_msg_error'] = true; } elseif ($doublonLogin) { $_SESSION['error'] = 'Un utilisateur avec le même login existe déjà !'; $_SESSION['display_msg_error'] = true; } else { if (!(isset($_SESSION['error']) and $_SESSION['error'] != null and isset($_SESSION['display_msg_error']) and $_SESSION['display_msg_error'])) { $registerUser = new UserDAO(); $registerUser->register($loginUser, $passwordUser, $emailUser, $nameUser, $firstNameUser, $idFormation); $managerFormation = new FormationDAO(); $nameFormation = $managerFormation->getNameAndDescriptionFormation($idFormation); //Mail d'inscription $to = $emailUser; $subject = "Inscription CloseClassroom"; $message = "Bonjour " . $_POST['loginUser'] . ",\n\n\t\t\t\tTu viens de t'inscrire sur CloseClassroom à la formation " . $nameFormation['name'] . " ! \n\n\t\t\t\tVoici tes identifiants : \n\n\t\t\t\tLogin : "******" \n\n\t\t\t\tAdresse mail : " . $_POST['emailUser'] . "\n\n\t\t\t\tMot de passe : " . $_POST['passwordUser'] . "\n\t\t\t\t\n"; $headers = 'From: contact@laurent-toson.fr\\n" Reply-To: contact@laurent-toson.fr \\n" X-Mailer: PHP/' . phpversion(); // On n'envoie pas le mail car on est en local //$sendMail = mail($to, $subject, $message, $headers); $sendMail = true; if (!$sendMail) { $_SESSION['error'] = 'Inscription réussie mais une erreur est survenue lors d\'envoi du mail !'; $_SESSION['display_msg_error'] = true; } else { $_SESSION['success'] = 'Votre compte <b>' . $loginUser . '</b> (' . $emailUser . ') a été crée et inscrit à la formation ' . $nameFormation['name'] . '. Vous allez reçevoir un mail avec vos infos.'; $_SESSION['display_msg_success'] = true; } } else { $_SESSION['error'] = 'L\'inscription n\'a pas été réalisée'; $_SESSION['display_msg_error'] = true; } } }
public function showFormation() { if (isset($_GET['idFormation'])) { $infosUser = new UserDAO(); $infos = $infosUser->getInfoUser($_SESSION['idUser']); $managerFormation = new FormationDAO(); $haveRight = false; if ($infos['type'] != 'Admin') { $formations = $managerFormation->getFormationsByUser($infos['id']); foreach ($formations as $formation) { if ($formation['id'] == $_GET['idFormation']) { $haveRight = true; } } } if ($haveRight || $infos['type'] == 'Admin') { $verifFormation = new FormationDAO(); $isFormationExist = $verifFormation->verifFormation($_GET['idFormation']); if (!$isFormationExist) { $_SESSION['error'] = 'La formation n\'existe pas'; $_SESSION['display_msg_error'] = true; $this->profile(); } else { $managerModule = new ModuleDAO(); $mesModules = $managerModule->getModulesByFormation($_GET['idFormation']); $infosFormation = $managerFormation->getNameAndDescriptionFormation($_GET['idFormation']); $moduleView = new ModuleView(); echo $moduleView->getView($mesModules, $infos['type'], $infosFormation['name']); } } else { $_SESSION['error'] = 'Vous n\'avez pas les droits requis pour accéder à cette page'; $_SESSION['display_msg_error'] = true; $this->profile(); } } else { $_SESSION['error'] = '[11] La page n\'existe pas'; $_SESSION['display_msg_error'] = true; $this->profile(); } }