Ejemplo n.º 1
0
 public function addcommentajaxAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form = new BlogCommentForm();
         //trigger data controls
         $form->setInputFilter(new BlogCommentInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             //$message = new Message();
             $utils = new Utils();
             $to = EmailCommentConfig::$emailAdressForContact;
             $name = $utils->stripTags_replaceHtmlChar_trim($request->getPost('contactnom'), true, true, true);
             $company = $utils->stripTags_replaceHtmlChar_trim($request->getPost('contactentreprise'), true, true, true);
             $subject = "Contact site web de la part de " . $utils->stripTags_replaceHtmlChar_trim($request->getPost('contactnom'), true, true, true);
             $from = $utils->stripTags_replaceHtmlChar_trim($request->getPost('contactemail'), true, true, true);
             $contenuid = (int) $utils->stripTags_replaceHtmlChar_trim($request->getPost('contactcontenuid'), true, true, true);
             $txt = wordwrap($utils->stripTags_replaceHtmlChar_trim($request->getPost('contacttext'), true, true, true), 70);
             $message = new EmailSent();
             $message->setRow1($name);
             $message->setRow2($company);
             $message->setRow3($from);
             $message->setMessage($txt);
             $message->setDate(date("Y-m-d H:i:s", time()));
             $message->setType(TypeMessage::$blog);
             $message->setContenuId($contenuid);
             $message->setCommentaireStatut(0);
             $messageDao = new CommentaireDao();
             $messageDao->saveCommentaire($message);
             //zend message sendmail
             /*$emailMessage = new Message();
                           $emailMessage->addFrom($from, $name)
                             ->addTo($to)
                             ->setSubject($subject)
                             ->setBody($txt);
                        
                           $transport = new SendmailTransport();
                           $transport->send($emailMessage);
             		*/
             //zend message smtp
             $messageToSend = new Message();
             $messageToSend->addFrom($from, $name)->addTo($to)->setSubject($subject);
             $messageToSend->setBody($txt);
             $messageToSend->setEncoding("UTF-8");
             $transport = new SmtpTransport();
             $options = new SmtpOptions(array('name' => EmailCommentConfig::$smtpServerNameForContact, 'host' => EmailCommentConfig::$smtpHostServerForContact, 'port' => EmailCommentConfig::$smtpHostPortForContact, 'connection_class' => EmailCommentConfig::$connectionClassForContact, 'connection_config' => array('username' => EmailCommentConfig::$connectionConfigUsernameForContact, 'password' => EmailCommentConfig::$connectionConfigPwdForContact, 'ssl' => EmailCommentConfig::$connectionConfigSSLForContact)));
             $transport->setOptions($options);
             $transport->send($messageToSend);
             return new JsonModel(array('result' => 'ok'));
         } else {
             return new JsonModel(array('result' => 'failure', 'error' => $form->getMessages()));
         }
     }
 }
Ejemplo n.º 2
0
 public function saveCommentaire(Commentaire $commentaire)
 {
     $id = (int) $commentaire->getId();
     if (!(bool) $commentaire->getRow1()) {
         $commentaire->setRow1("");
     }
     if (!(bool) $commentaire->getRow2()) {
         $commentaire->setRow2("");
     }
     if (!(bool) $commentaire->getRow3()) {
         $commentaire->setRow3("");
     }
     if (!(bool) $commentaire->getRow4()) {
         $commentaire->setRow4("");
     }
     if (!(bool) $commentaire->getMessage()) {
         $commentaire->setMessage("");
     }
     if (!(bool) $commentaire->getType()) {
         $commentaire->setType("blog");
     }
     if (!(bool) $commentaire->getRang()) {
         $commentaire->setRang(0);
     }
     if (!(bool) $commentaire->getDate()) {
         $commentaire->setDate(time());
     }
     if (!(bool) $commentaire->getCommentaireStatut()) {
         $commentaire->setCommentaireStatut(0);
     }
     if (!(bool) $commentaire->getType()) {
         $commentaire->setType("");
     }
     if (!(bool) $commentaire->getContenuId()) {
         $commentaire->setContenuId(0);
     }
     if (!(bool) $commentaire->getCommentaireId()) {
         $commentaire->setCommentaireId(0);
     }
     if ($id > 0) {
         $requete = $this->dbGateway->prepare("\r\n\t\t\t\tUPDATE commentaire \r\n\t\t\t\tSET commentaire_row1 = :row1, \r\n\t\t\t\tcommentaire_row2 = :row2,\r\n\t\t\t\tcommentaire_row3 = :row3,\r\n\t\t\t\tcommentaire_row4 = :row4,\r\n                                commentaire_msg = :msg,\r\n                                commentaire_status = :status,\r\n                                commentaire_contenuid = :contenuid,\r\n                                commentaire_type = :type,\r\n                                commentaire_date = :datemsg\r\n\t\t\t\tWHERE commentaire_id = :id\r\n\t\t\t") or die(print_r($this->dbGateway->errors_info()));
         $requete->execute(array('id' => $id, 'row1' => $commentaire->getRow1(), 'row2' => $commentaire->getRow2(), 'row3' => $commentaire->getRow3(), 'row4' => $commentaire->getRow4(), 'msg' => $commentaire->getMessage(), 'type' => $commentaire->getType(), 'status' => $commentaire->getCommentaireStatut(), 'contenuid' => $commentaire->getContenuId(), 'datemsg' => $commentaire->getDate()));
     } else {
         $requete = $this->dbGateway->prepare("INSERT into commentaire(" . "commentaire_row1, " . "commentaire_row2, " . "commentaire_row3, " . "commentaire_row4,  " . "commentaire_msg, " . "commentaire_type, " . "commentaire_date, " . "commentaire_status, " . "commentaire_contenuid) " . "values(" . ":rowa, " . ":rowb, " . ":rowc, " . ":rowd, " . ":msg, " . ":type, " . ":datemsg, " . ":status, " . ":contenuid)") or die(print_r($this->dbGateway->error_info()));
         $info = $requete->execute(array('rowa' => $commentaire->getRow1(), 'rowb' => $commentaire->getRow2(), 'rowc' => $commentaire->getRow3(), 'rowd' => $commentaire->getRow4(), 'msg' => $commentaire->getMessage(), 'type' => $commentaire->getType(), 'status' => $commentaire->getCommentaireStatut(), 'contenuid' => $commentaire->getContenuId(), 'datemsg' => $commentaire->getDate()));
         //var_dump($info);
         //exit;
     }
 }