public function profilView($id) { $manager = new ProfilManager(); $manager2 = new Wusers_tagManager(); $profil = $manager->getUserProfil($id); $badges = $manager2->getUserLevel($id); //$this->allowTo('user'); $this->show('default/profil', ['profil' => $profil, 'badges' => $badges]); }
public function vote($qid, $aid, $vote) { $manager = new ReponseManager(); $manager2 = new Questions_tagManager(); $manager3 = new Wusers_tagManager(); $manager->setVote($aid, $vote); $wid = $manager->getAnswer($aid); $tags = $manager2->getQuestionTags($qid); $manager3->setWusersTagsModif($wid, $tags, $vote); $this->redirectToRoute('question', ['id' => $qid]); }
public function register() { $errors = array(); $flag = 0; //debug($_POST); if (isset($_POST['registerform'])) { //debug($_POST['registerform']); // indication du role par défaut de l'utilisateur $_POST['myform']['role'] = 'user'; //nom $nom = $_POST['nom']; //prénom $prenom = $_POST['prenom']; // Hashage du mot de passe $_POST['myform']['mdp'] = password_hash($_POST['myform']['mdp'], PASSWORD_DEFAULT); $manager = new UserManager(); $manager2 = new ProfilManager(); $manager3 = new WuserManager(); $manager4 = new TagManager(); $manager5 = new Wusers_tagManager(); // Si le mail et sa confirmation sont différents if ($_POST['myform']['mail'] != $_POST['remail']) { $errors[] = 'Les adresses mail entrées sont différentes.'; } else { // Si l'adresse mail existe en bdd if ($manager->getUserByUsernameOrEmail($_POST['myform']['mail'])) { $errors[] = '<br />Cette adresse mail est déjà utilisée, veuillez en choisir une autre ou vous connecter à ce compte.'; } else { if (!preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\\.[a-z]{2,4}\$#", $_POST['myform']['mail'])) { $errors[] = '<br />L\'adresse mail ne respecte pas les critères de validité.'; } else { $_POST['myform']['mail']; } } } //mail // Si le mot de passe fait moins de 8 caractères // A FAIRE // Si le mot de passe et sa confirmation sont diférents if ($_POST['myform']['mdp'] != password_verify($_POST['remdp'], $_POST['myform']['mdp'])) { $errors[] = 'Les mots de passe entrés sont différents.'; } //mdp // Création du token pour validation du compte par mail $token = md5(uniqid($_POST['myform']['pseudo'], true)); if (count($errors) === 0) { // error = 0 = insertion user //$this->redirectToRoute('login'); try { $manager->insert($_POST['myform']); $manager2->insertUserData($_POST['myform']['mail'], $nom, $prenom, $token); //debug('compte en bdd'); $flag = 1; $wuser_id = $manager3->getWuserId($_POST['myform']['mail']); // debug($wuser_id); $tags = $manager4->getAllTags(); $manager5->setWusersTags($wuser_id, $tags); $this->show('default/home', ['flag' => $flag]); } catch (Exception $e) { $this->show('default/home', ['errors' => $errors->getMessage()]); } } else { $this->show('default/home', ['errors' => $errors], ['flag' => $flag]); } } $this->show('default/home', ['flag' => $flag]); }