Files
fdn2/app/public/sendCommentoBackend.php
2022-08-30 13:33:35 +02:00

41 lines
1.2 KiB
PHP

<?php
require_once(dirname(__FILE__)."/load.php");
try {
// if(UserLoginManager::isLogged()){
// var_dump($_POST);
$id = PostHandler::get("id");
$titolo = PostHandler::get("titolo");
$commento = PostHandler::get("commento");
if(!is_null($id)){
$articolo = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>$id,"status"=>NotiziaModel::STATUS_ACCEPTED));
if(!is_null($articolo)){
$news = new stdClass();
$news->notizia = $articolo->id;
$news->user = UserLoginManager::getLogged();
$commento = new CommentoModel($news);
$commento->titolo = strip_tags($titolo);
$commento->testo = strip_tags($testo);
$commento->status = CommentoModel::STATUS_PENDING;
GlobalVariables::get("dao")->save($commento);
echo '<div class="commentoSent">Il tuo commento è stato inviato ed è in attesa di apporvazione.</div>';
}
}
// }
else{
echo '<div class="commentoSent redError">Un errore ha impedito l\'invio del commento.</div>';
}
}catch (Exception $exec){
var_dump($exec);
// echo '<div class="commentoSent redError">Un errore ha impedito l\'invio del commento.(Ex)</div>';
$msg = LogModel::fromException($exec);
GlobalVariables::get("dao")->save($msg);
}
?>