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
92 lines
2.3 KiB
PHP
92 lines
2.3 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 25/gen/2016
|
|
*/
|
|
|
|
class FDN_Mailer {
|
|
|
|
public static function generateTemplateQueue(MailTemplateModel $mailTemplate){
|
|
$users = GlobalVariables::get("dao")->query("UserModel",array("newsletter"=>true));
|
|
|
|
foreach ($users as $user){
|
|
$tmp = new stdClass();
|
|
$tmp->from = $mailTemplate->from;
|
|
if ($mailTemplate->hasProperty("fromName")){
|
|
$tmp->fromName = $mailTemplate->fromName;
|
|
}
|
|
|
|
$tmp->recipient = $user->email;
|
|
|
|
$tmp->subject = $mailTemplate->subject;
|
|
$tmp->body = $mailTemplate->body;
|
|
if ($mailTemplate->hasProperty("altBody")){
|
|
$tmp->altBody = $mailTemplate->altBody;
|
|
}
|
|
|
|
if ($mailTemplate->hasProperty("attachment")){
|
|
$tmp->attachment = $mailTemplate->attachment;
|
|
}
|
|
|
|
$tmp->priority = MailModel::PRIORITY_LOW;
|
|
|
|
$mail = new MailModel($tmp);
|
|
GlobalVariables::get("dao")->save($mail);
|
|
}
|
|
|
|
}
|
|
|
|
public static function processQueue(){
|
|
$mails = GlobalVariables::get("dao")->query("MailModel",array("status"=>MailModel::STATUS_PENDING),array("order"=>array("priority","desc"),"limit"=>50));
|
|
|
|
if (sizeof($mails)>0){
|
|
foreach($mails as $mail){
|
|
self::sendMail($mail);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static function sendMail(MailModel $mail){
|
|
$mailObj = $mail->getMailObject();
|
|
|
|
if(!$mailObj->send()) {
|
|
LoggingFacilityManager::getLogger("mail")->log(LoggingFacility::$LEVEL_ERROR,"Impossible to send email with id '".$mail->id."' to recipient '".$mail->recipient."' (".$mailObj->ErrorInfo.")");
|
|
$mail->status = MailModel::STATUS_PAUSED;
|
|
}
|
|
else {
|
|
$mail->status = MailModel::STATUS_SENT;
|
|
}
|
|
GlobalVariables::get("dao")->save($mail);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function queueAdminWarningMail($subj,$text){
|
|
$admins = GlobalVariables::get("dao")->query("AdminModel",array('$where'=>"obj.roles%(".AdminModel::ADMIN_TYPE_SUPERADMIN."*2) >= ".AdminModel::ADMIN_TYPE_SUPERADMIN));
|
|
if (sizeof($admins)>0){
|
|
foreach ($admins as $admin){
|
|
$tmp = new stdClass();
|
|
$tmp->from = GlobalVariables::get("config")->emails->system;
|
|
$tmp->fromName = "SYSTEM - I Fatti di Napoli";
|
|
|
|
$tmp->recipient = $admin->email;
|
|
|
|
$tmp->subject = $subj;
|
|
$tmp->body = $text;
|
|
|
|
$tmp->priority = MailModel::PRIORITY_HIGH;
|
|
|
|
$mail = new MailModel($tmp);
|
|
GlobalVariables::get("dao")->save($mail);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|