102 lines
3.4 KiB
PHP
102 lines
3.4 KiB
PHP
<?php
|
|
|
|
|
|
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_EDITORE_SUPERVISOR) &&
|
|
!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE)){
|
|
GUIHandler::redirect("admin/index.php");
|
|
}
|
|
|
|
$edit = false;
|
|
$notiziaId = PostHandler::get("id");
|
|
|
|
$notizia = new NotiziaModel();
|
|
// var_dump($notizia);
|
|
if(!is_null($notiziaId)){
|
|
$edit = true;
|
|
$notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>$notiziaId));
|
|
// echo "pene";
|
|
// var_dump($notizia);
|
|
if(is_null($notizia)){
|
|
GUIHandler::redirect("admin/myNotizie.php");
|
|
}
|
|
|
|
if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE_SUPERVISOR) &&
|
|
AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE)){
|
|
if(strcmp($notizia->about->owner, AdminLoginManager::getLogged()->id) != 0){
|
|
GUIHandler::redirect("admin/myNotizie.php");
|
|
}
|
|
}
|
|
}
|
|
|
|
MenuGenerator::generateMenu();
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
if(!is_null(PostHandler::get("action")) && strcmp(PostHandler::get("action"), "")!=0){
|
|
$save = PostHandler::get("action");
|
|
if(strcmp($save, "save")==0){
|
|
$saveable = new stdClass();
|
|
|
|
$saveable->id = PostHandler::get("id");
|
|
$saveable->titolo = PostHandler::get("titolo");
|
|
$saveable->sottotitolo = PostHandler::get("sottotitolo");
|
|
$saveable->testo = PostHandler::get("testo");
|
|
$mongoDate = new MongoDate(PostHandler::get("date")->getTimeStamp());
|
|
$saveable->about->date = $mongoDate;
|
|
|
|
if(!$edit){
|
|
$saveable->about->author = AdminLoginManager::getLogged()->nome." ".AdminLoginManager::getLogged()->nome;
|
|
$saveable->about->owner = AdminLoginManager::getLogged()->id;
|
|
}
|
|
else{
|
|
$saveable->about->author = PostHandler::get("nome")." ".PostHandler::get("cognome");
|
|
$saveable->about->owner = PostHandler::get("owner");
|
|
}
|
|
|
|
GlobalVariables::get("dao")->save($saveable);
|
|
}
|
|
}
|
|
|
|
?>
|
|
<div>
|
|
<form action="" method="POST" id="notiziaForm">
|
|
<input type="hidden" value="<?php echo $notiziaId;?>" name="id"/>
|
|
<input type="hidden" value="<?php echo $notizia->about->nome;?>" name="nome"/>
|
|
<input type="hidden" value="<?php echo $notizia->about->cognome;?>" name="cognome"/>
|
|
<input type="hidden" value="<?php echo $notizia->about->owner;?>" name="owner"/>
|
|
|
|
<div style="padding:10px;">
|
|
<div style="padding:5px; display:inline-block;">Titolo:
|
|
<textarea name="titolo" rows="2" cols="30" style="resize:none;"><?php echo $notizia->titolo;?></textarea>
|
|
</div>
|
|
<div style="padding:5px;display:inline-block;">Sottotitolo:
|
|
<textarea name="sottotitolo" rows="2" cols="30" style="resize:none;"><?php echo $notizia->sottotitolo;?></textarea>
|
|
</div>
|
|
</div>
|
|
<textarea name="testo" id="editore_testo" rows="10" cols="80"><?php echo $notizia->testo;?></textarea>
|
|
<div>Data: <input type="text" id="datepicker" name="date" value="<?php echo $notizia->about->date;?>"></div>
|
|
|
|
<input type="hidden" name="action" value=""/>
|
|
</form>
|
|
|
|
<a href="#" id="submit" >Submit</a>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
CKEDITOR.replace( 'editore_testo');
|
|
$(document).ready(function(event){
|
|
$("#submit").click(function(event){
|
|
$("form#notiziaForm input[type=hidden][name=action]").val("save");
|
|
$("form#notiziaForm").submit();
|
|
});
|
|
|
|
$("#datepicker").datepicker({dateFormat:"dd-mm-yy"});
|
|
});
|
|
</script>
|