137 lines
5.3 KiB
PHP
137 lines
5.3 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 25/gen/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_NEWSLETTER)){
|
|
GUIHandler::redirect("admin/index.php");
|
|
}
|
|
|
|
MenuGenerator::generateMenu();
|
|
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
try {
|
|
$id = PostHandler::get("id");
|
|
|
|
$config = GlobalVariables::get("config");
|
|
|
|
$tmp = new stdClass();
|
|
$tmp->from = $config->emails->newsletter;
|
|
$tmp->fromName = "I Fatti di Napoli - Newsletter";
|
|
$tmp->subject = "";
|
|
$tmp->body = "";
|
|
$tmp->date = new MongoDate();
|
|
$mail = new MailTemplateModel($tmp);
|
|
|
|
|
|
if (!is_null($id) && strcmp("", $id)!=0){
|
|
$mail = GlobalVariables::get("dao")->getFirst("MailTemplateModel",array("id"=>$id));
|
|
if (is_null($mail)){
|
|
GUIHandler::redirect("admin/pendingNewsletters.php");
|
|
}
|
|
}
|
|
|
|
$action = PostHandler::get("action");
|
|
if (!is_null($action) && strcmp("", $action)!=0){
|
|
if (strcmp("cancel", $action)==0){
|
|
GUIHandler::redirect("admin/pendingNewsletters.php");
|
|
}
|
|
else if (strcmp("save", $action)==0){
|
|
$mail->subject = PostHandler::get("subject");
|
|
$mail->body = PostHandler::get("body");
|
|
|
|
$dateString = PostHandler::get("data")." ".PostHandler::get("time");
|
|
if(!preg_match("/^[0-9]{2}[-][0-9]{2}[-][0-9]{4} [0-9]{2}[:][0-9]{2}$/", $dateString)){
|
|
throw new GUIException("Il formato della data inserita non è corretto. Per favore segui il seguente formato Date: dd-mm-yyyy hh:ii");
|
|
}
|
|
$tmp->date = new MongoDate(strtotime($dateString));
|
|
|
|
GlobalVariables::get("dao")->save($mail);
|
|
|
|
GUIHandler::redirectPost("admin/confirmNewsletter.php",array("id"=>$mail->id));
|
|
}
|
|
}
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessage();
|
|
}catch (Exception $exec){
|
|
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
|
|
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
|
|
}
|
|
|
|
$mailBody = $mail->body;
|
|
if (strcmp($mailBody, "")==0){
|
|
$mailBody = '<div style="margin:auto;width:1024px;"><div style="text-align:center;"><img src="http://www.ifattidinapoli.it/images/logo_uff.png"></div><div >Testo di prova</div><div></div>'.
|
|
'<div style="background-color:#14477c;margin-top:10px;">
|
|
<div style="text-align:center;color:#2e91d4;padding:10px;">
|
|
<a style="color:#2e91d4;margin:10px;" href="http://www./index.php">Home</a> | <a style="color:#2e91d4;margin:10px;" href="http://www./categorySummary.php?category=1">Politica</a> | <a style="color:#2e91d4;margin:10px;" href="http://www./categorySummary.php?category=2">Cronaca</a> | <a style="color:#2e91d4;margin:10px;" href="http://www./categorySummary.php?category=3">Sport</a> | <a style="color:#2e91d4;margin:10px;" href="http://www./categorySummary.php?category=4">Cultura&Spettacolo</a>
|
|
</div>
|
|
<div style="text-align:center;color:white;margin-top:25px;">TESTATA REGISTRATA PRESSO IL TRIBUNALE DI NAPOLI AUT. NR. 8 DEL 27 GENNAIO 2006</div>
|
|
<div style="text-align:center;color:white;margin-top:20px;">COPYRIGHT © 2016 <a href="http://www.ifattidinapoli.it" style="color:white;">www.ifattidinapoli.it</a> - Giornale della Terza Metropoli Italiana</div>
|
|
<div style="text-align:center;color:white;margin-top:20px;">
|
|
<a href="http://www./redazione.php" style="color:white;">REDAZIONE</a> | <a href="http://www./archivio.php" style="color:white;">ARCHIVIO STORICO</a>
|
|
</div>
|
|
</div></div>';
|
|
}
|
|
?>
|
|
<div>
|
|
<?php
|
|
if(strcmp($error, "")!=0){
|
|
echo '<div style="font-size: 16px; color:red;">'.$error.'</div>';
|
|
}
|
|
?>
|
|
<form id="mailForm" method="POST" action="">
|
|
<input type="hidden" name="action" value="" />
|
|
<input type="hidden" name="id" value="<?php echo $id;?>" />
|
|
<div>
|
|
<span class="label">Oggetto</span>
|
|
<input type="text" name="subject" value="<?php echo $mail->subject; ?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Giorno</span>
|
|
<input type="text" id="datepicker" name="data" value="<?php echo ($edit)? date("d-m-Y",$mail->date->sec):date("d-m-Y");?>">
|
|
</div>
|
|
<div>
|
|
<span class="label">Ora</span>
|
|
<input type="text" id="timepicker" name="time" value="<?php echo ($edit)? date("H:i",$mail->date->sec):date("H:i");?>">
|
|
</div>
|
|
<div>
|
|
<!-- <div style="margin:auto;width:1024px;" contenteditable="true"><?php echo $mailBody;?></div>-->
|
|
<!-- <span class="label">Corpo</span> -->
|
|
<textarea id="body_editor" name="body" rows="10" cols="80"><?php echo $mailBody;?></textarea>
|
|
</div>
|
|
</form>
|
|
<div class="formBtns">
|
|
<a href="#" id="mailForm_salva" >Salva</a>
|
|
<a href="#" id="mailForm_annulla">Annulla</a>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
CKEDITOR.disableAutoInline = true;
|
|
CKEDITOR.config.allowedContent = true;
|
|
CKEDITOR.inline('body_editor');
|
|
|
|
$("#datepicker").datepicker({dateFormat:"dd-mm-yy"});
|
|
$("#timepicker").datetimepicker({datepicker:false,format:'H:i'});
|
|
|
|
|
|
$("#mailForm_salva").click(function(event){
|
|
$("form#mailForm input[type=hidden][name=action]").val("save");
|
|
$("form#mailForm").submit();
|
|
});
|
|
$("#mailForm_annulla").click(function(event){
|
|
$("form#mailForm input[type=hidden][name=action]").val("cancel");
|
|
$("form#mailForm").submit();
|
|
});
|
|
});
|
|
</script>
|