Create pagine per notizie in pending e rifiutate; Creati componenti grafici per mostrare Notizia, Commento e lista commenti; Bugfix e limature su amministrazione
90 lines
2.7 KiB
PHP
90 lines
2.7 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 29/feb/2016
|
|
*/
|
|
|
|
require_once(dirname(__FILE__)."/../load.php");
|
|
|
|
GUIHandler::generateHtmlHeaders(array(),true);
|
|
|
|
if (!AdminLoginManager::isLogged()){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
else if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_COMMENTI_SUPERVISOR)){
|
|
GUIHandler::redirect("admin/index.php");
|
|
}
|
|
|
|
MenuGenerator::generateMenu();
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
try{
|
|
$error = "";
|
|
$id = PostHandler::get("id");
|
|
if (is_null($id) && strcmp("", $id)!=0){
|
|
GUIHandler::redirect("admin/unacceptedCommenti.php");
|
|
}
|
|
|
|
$commento = GlobalVariables::get("dao")->getFirst("CommentoModel",array("id"=>$id));
|
|
if (is_null($commento)){
|
|
GUIHandler::redirect("admin/unacceptedCommenti.php");
|
|
}
|
|
|
|
$action = PostHandler::get("action");
|
|
if (!is_null($action) && strcmp("", $action)!=0){
|
|
if (strcmp("cancel", $action)==0){
|
|
GUIHandler::redirectPost("admin/validateCommento.php",array("id"=>$id));
|
|
}
|
|
else if (strcmp("save", $action)==0){
|
|
$commento->titolo = PostHandler::get("titolo");
|
|
$commento->testo = PostHandler::get("testo");
|
|
|
|
GlobalVariables::get("dao")->save($commento);
|
|
|
|
GUIHandler::redirectPost("admin/validateCommento.php",array("id"=>$id));
|
|
}
|
|
}
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessage();
|
|
}catch (Exception $exec){
|
|
$msg = LogModel::fromException($exec);
|
|
GlobalVariables::get("dao")->save($msg);
|
|
$error = "Si è verificato un errore inatteso durante l'esecuzione della pagina. Contattare il supporto tecnico comunicando il seguente codice di erore '".$msg->getCode()."'";
|
|
}
|
|
|
|
?>
|
|
<div>
|
|
<?php
|
|
if(strcmp($error, "")!=0){
|
|
echo '<div style="font-size: 16px; color:red;">'.$error.'</div>';
|
|
}
|
|
?>
|
|
<form id="commentoForm" method="POST" action="">
|
|
<input type="hidden" name="action" value="" />
|
|
<input type="hidden" name="id" value="<?php echo $id;?>" />
|
|
<div>
|
|
<span class="label">Titolo</span>
|
|
<input type="text" name="titolo" value="<?php echo $commento->titolo; ?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Testo</span>
|
|
<textarea name="testo" rows="3" cols="80" style="resize:none;"><?php echo $commento->testo; ?></textarea>
|
|
</div>
|
|
</form>
|
|
<div class="formBtns">
|
|
<a href="#" id="commentoForm_salva" >Salva</a>
|
|
<a href="#" id="commentoForm_annulla">Annulla</a>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
$("#commentoForm_salva").click(function(event){
|
|
$("form#commentoForm input[type=hidden][name=action]").val("save");
|
|
$("form#commentoForm").submit();
|
|
});
|
|
$("#commentoForm_annulla").click(function(event){
|
|
$("form#commentoForm input[type=hidden][name=action]").val("cancel");
|
|
$("form#commentoForm").submit();
|
|
});
|
|
});
|
|
</script>
|