/** * Get the form for comment * * * @param unknown $idEvenement * @param unknown $fields * @param string $ty : type of comment * @return string */ public function getFormComment($idEvenement, $fields, $ty = '') { $t = new Template('modules/archi/templates/'); $labelButton = "Ajouter un commentaire"; $type = $ty == '' ? 0 : $ty; $classButton = 'addCommentButtonWrapper'; $auth = new ArchiAuthentification(); if ($auth->estConnecte()) { $t->set_filenames(array('formComment' => 'comment/comment.tpl')); $url = ""; $userId = $auth->getIdUtilisateur(); $utilisateur = new archiUtilisateur(); $utilisateur->setUserId($userId); $nom = $utilisateur->getNom(); $prenom = $utilisateur->getPrenom(); $email = $utilisateur->getEmail(); $urlProfilePic = $utilisateur->getImageAvatar(array('idUtilisateur' => $userId)); $profileAlt = $prenom . " " . $nom; if ($ty == '') { $array_type = array(); $url = $this->creerUrl('enregistreCommentaire', '', array()); $labelButton .= " sur l'adresse"; $classButton .= " addCommentAdresseButtonWrapper"; } else { $array_type = array('type' => array('id' => 'type', 'type' => 'hidden', 'value' => $type)); $url = $this->creerUrl('enregistreCommentaireEvenement', '', array()); } $inputs = array('nom' => array('id' => 'nom', 'type' => 'hidden', 'value' => $nom), 'prenom' => array('id' => 'prenom', 'type' => 'hidden', 'value' => $prenom), 'email' => array('id' => 'email', 'type' => 'hidden', 'value' => $email), 'idEvenementGroupeAdresse' => array('id' => 'idEvenementGroupeAdresse', 'type' => 'hidden', 'value' => $idEvenement)); $inputs = array_merge($inputs, $array_type); foreach ($inputs as $input) { $t->assign_block_vars('input', $input); } $t->assign_vars(array('urlRedirect' => $url, 'name' => 'formAjoutCommentaire', 'urlProfilePic' => $urlProfilePic, 'profileAlt' => $profileAlt, 'labelButton' => $labelButton, 'classButton' => $classButton, 'idEvenement' => $idEvenement)); } else { $t->set_filenames(array('formComment' => 'comment/notconnected.tpl')); $urlConnexion = $this->creerUrl('', 'authentification'); $urlInscription = $this->creerUrl('', 'inscription'); if ($ty == '') { $labelButton .= " sur l'adresse"; $classButton .= " addCommentAdresseButtonWrapper"; } $t->assign_vars(array('urlInscription' => $urlInscription, 'urlConnexion' => $urlConnexion, 'labelButton' => $labelButton, 'classButton' => $classButton, 'idEvenement' => $idEvenement)); } //Setting CSS class for opening the form if (isset($this->variablesGet['commentFormActive']) && $this->variablesGet['commentFormActive']) { if ($this->variablesGet['commentFormActive'] == $idEvenement) { $t->assign_var('classWrappingDiv', 'active'); } } ob_start(); $t->pparse('formComment'); $html .= ob_get_contents(); ob_end_clean(); return $html; }