Aggiunti nuovi task per mail server Creato metodo in guihandler per aprire le pagine con richiesta post Aggiunta possibilità di passare callback ai backend delle datatables Modificati alcuni url Modificato HTMLInclusion per non utilizzare i path assoluti in fase di creazione ma solo in fase di stampa degli header (per evitare problemi sugli script) Creato mailserver e mail template Creata interfaccia mail per salvataggio mail in database, gestione coda. Creata interfaccia grafica per la gestione delle mail e delle code Incluse librerie PHP_Mailer Inserite pagine di creazione e cancellazione manuale utenti Bugfix su alcune pagine di edit
106 lines
3.5 KiB
PHP
106 lines
3.5 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::redirect("admin/pendingNewsletters.php");
|
|
}
|
|
}
|
|
}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.";
|
|
}
|
|
|
|
?>
|
|
<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>Titolo:<input type="text" name="subject" value="<?php echo $mail->subject; ?>" /></div>
|
|
<div>Corpo:
|
|
<textarea name="body" id="body_editor" rows="10" cols="80"><?php echo $mail->body;?></textarea>
|
|
</div>
|
|
<div>Data: <input type="text" id="datepicker" name="data" value="<?php echo ($edit)? date("d-m-Y",$mail->date->sec):date("d-m-Y");?>"></div>
|
|
<div>Time: <input type="text" id="timepicker" name="time" value="<?php echo ($edit)? date("H:i",$mail->date->sec):date("H:i");?>"></div>
|
|
</form>
|
|
<a href="#" id="mailForm_salva" >Salva</a>
|
|
<a href="#" id="mailForm_annulla">Annulla</a>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
CKEDITOR.replace('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>
|