mailing refactored

This commit is contained in:
Quitta 2013-08-26 05:37:55 +02:00
parent d147cc681c
commit c6ce0a188a
2 changed files with 67 additions and 31 deletions

View file

@ -21,16 +21,19 @@ class Mail_Handler{
$sendingId = NULL; $sendingId = NULL;
} }
$variables = Helpers::handle_language();
$mailText = array();
foreach ( $variables['email'] as $key => $value ){
$mailText[$key] = $value;
}
switch($type){ switch($type){
case "REPLY": case "REPLY":
$webUser = new WebUsers($receiver); $webUser = new WebUsers($receiver);
if($webUser->getReceiveMail()){ if($webUser->getReceiveMail()){
$txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n You received a new reply on your ticket: " . $ticketObj->getTitle() . $subject = $mailText['email_subject_new_reply'] . $ticketObj->getTId() ."]";
"\n --------------------\n\n"; $txt = $mailText['email_body_new_reply_1']. $ticketObj->getTId() . $mailText['email_body_new_reply_2'] . $ticketObj->getTitle() .
$subject = "New reply on [Ticket #" . $ticketObj->getTId() ."]"; $mailText['email_body_new_reply_3'] . $content . $mailText['email_body_new_reply_4'];
$endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!";
$txt = $txt . $content . $endTxt;
self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(),$sendingId); self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(),$sendingId);
} }
break; break;
@ -38,22 +41,30 @@ class Mail_Handler{
case "NEW": case "NEW":
$webUser = new WebUsers($receiver); $webUser = new WebUsers($receiver);
if($webUser->getReceiveMail()){ if($webUser->getReceiveMail()){
$txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n Your ticket: " . $ticketObj->getTitle() . " is newly created"; $subject = $mailText['email_subject_new_ticket'] . $ticketObj->getTId() ."]";
$txt = $txt . "\n --------------------\n\n"; $txt = $mailText['email_body_new_ticket_1'] . $ticketObj->getTId() . $mailText['email_body_new_ticket_2'] . $ticketObj->getTitle() . $mailText['email_body_new_ticket_3']
$subject = "New ticket created [Ticket #" . $ticketObj->getTId() ."]"; . $content . $mailText['email_body_new_ticket_4'];
$endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!";
$txt = $txt . $content . $endTxt;
self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(), $sendingId); self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(), $sendingId);
} }
break; break;
case "WARNAUTHOR": case "WARNAUTHOR":
$subject = $mailText['email_subject_warn_author'] . $ticketObj->getTId() ."]";
$txt = $mailText['email_body_warn_author_1'] . $ticket->getTitle() .$mailText['email_body_warn_author_2'].$fromEmail.$mailText['email_body_warn_author_3'].
$fromEmail. $mailText['email_body_warn_author_4'] ;
self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(), $sendingId);
break; break;
case "WARNSENDER": case "WARNSENDER":
$subject = $mailText['email_subject_warn_sender'];
$txt = $mailText['email_body_warn_sender'];
self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(), $sendingId);
break; break;
case "WARNUNKNOWNSENDER": case "WARNUNKNOWNSENDER":
$subject = $mailText['email_subject_warn_unknown_sender'];
$txt = $mailText['email_body_warn_unknown_sender'];
self::send_mail($receiver,$subject,$txt, $ticketObj->getTId(), $sendingId);
break; break;
} }
@ -288,16 +299,7 @@ class Mail_Handler{
}else{ }else{
//if user has no access to it //if user has no access to it
//Warn real ticket owner + person that send the mail //Warn real ticket owner + person that send the mail
/*$subject_warnAuthor = "Someone tried to reply to your ticket: [Ticket #" . $ticket->getTId() ."]";
$body_warnAuthor = "Someone tried to reply at your ticket: " . $ticket->getTitle() ."by sending an email from ".$fromEmail."! Please use the email address matching to your account if you want to auto reply!\n\n
If ". $fromEmail. " isn't one of your email addresses, please contact us by replying to this ticket!" ;
Mail_Handler::send_mail($ticket->getAuthor(), $subject_warnAuthor , $body_warnAuthor, $ticket->getTId(), NULL);*/
Mail_Handler::send_ticketing_mail($ticket->getAuthor(),$ticket, NULL , "WARNAUTHOR" , NULL); Mail_Handler::send_ticketing_mail($ticket->getAuthor(),$ticket, NULL , "WARNAUTHOR" , NULL);
/*$subject_warnSender = "You tried to reply to someone elses ticket!";
$body_warnSender = "It seems you tried to reply to someone elses ticket, please use the matching email address to that account!\n\n
This action is notified to the real ticket owner!" ;
Mail_Handler::send_mail($from, $subject_warnSender , $body_warnSender, $ticket->getTId(), NULL);*/
Mail_Handler::send_ticketing_mail($from ,$ticket, NULL , "WARNSENDER" , NULL); Mail_Handler::send_ticketing_mail($from ,$ticket, NULL , "WARNSENDER" , NULL);
error_log("Email found that was a reply to a ticket, though send by another user to ".$group->getGroupEmail()."\n", 3, $MAIL_LOG_PATH); error_log("Email found that was a reply to a ticket, though send by another user to ".$group->getGroupEmail()."\n", 3, $MAIL_LOG_PATH);
@ -308,16 +310,7 @@ class Mail_Handler{
//if a reply to a ticket is being sent by a non-user! //if a reply to a ticket is being sent by a non-user!
//Warn real ticket owner + person that send the mail //Warn real ticket owner + person that send the mail
/*$subject_warnAuthor = "Someone tried to reply to your ticket: [Ticket #" . $ticket->getTId() ."]";
$body_warnAuthor = "Someone tried to reply at your ticket:' " . $ticket->getTitle() ."' by sending an email from ".$fromEmail." ! Please use the email address matching to your account if you want to auto reply!\n\n
If ". $fromEmail. " isn't one of your email addresses, please contact us by replying to this ticket!" ;
Mail_Handler::send_mail($ticket->getAuthor(), $subject_warnAuthor , $body_warnAuthor, $ticket->getTId(), NULL);*/
Mail_Handler::send_ticketing_mail($ticket->getAuthor() ,$ticket, NULL , "WARNAUTHOR" , NULL); Mail_Handler::send_ticketing_mail($ticket->getAuthor() ,$ticket, NULL , "WARNAUTHOR" , NULL);
/*$subject_warnSender = "You tried to reply to someone's ticket!";
$body_warnSender = "It seems you tried to reply to someone's ticket, However this email address isn't linked to any account, please use the matching email address to that account!\n\n
This action is notified to the real ticket owner!" ;
Mail_Handler::send_mail($fromEmail, $subject_warnSender , $body_warnSender, $ticket->getTId(), NULL);*/
Mail_Handler::send_ticketing_mail($fromEmail ,$ticket, NULL , "WARNUNKNOWNSENDER" , NULL); Mail_Handler::send_ticketing_mail($fromEmail ,$ticket, NULL , "WARNUNKNOWNSENDER" , NULL);
error_log("Email found that was a reply to a ticket, though send by an unknown email address to ".$group->getGroupEmail()."\n", 3, $MAIL_LOG_PATH); error_log("Email found that was a reply to a ticket, though send by an unknown email address to ".$group->getGroupEmail()."\n", 3, $MAIL_LOG_PATH);

View file

@ -137,3 +137,46 @@ tac_tag1= "YES, I agree to the "
tac_tag2="terms of service" tac_tag2="terms of service"
tac_message = "You must accept the Terms of Service." tac_message = "You must accept the Terms of Service."
[email]
email_subject_new_reply = "New reply on [Ticket #"
email_body_new_reply_1 = "---------- Ticket #"
email_body_new_reply_2 = " ----------
You received a new reply on your ticket: "
email_body_new_reply_3 = "
--------------------
Reply Content:
"
email_body_new_reply_4 = "
--------------------
You can reply on this message to answer directly on the ticket!"
email_subject_new_ticket = "New ticket created [Ticket #"
email_body_new_ticket_1 = "---------- Ticket #"
email_body_new_ticket_2 = " ----------
Your ticket: "
email_body_new_ticket_3 = " is newly created
----------
"
email_body_new_ticket_4 = "
----------
You can reply on this message to answer directly on the ticket!"
email_subject_warn_author = "Someone tried to reply to your ticket: [Ticket #"
email_body_warn_author_1 = "Someone tried to reply at your ticket: "
email_body_warn_author_2 = " by sending an email from "
email_body_warn_author_3 = " ! Please use the email address matching to your account if you want to auto reply
If "
email_body_warn_author_4 = " isn't one of your email addresses, please contact us by replying to this ticket!"
email_subject_warn_sender = "You tried to reply to someone elses ticket!"
email_body_warn_sender = "It seems you tried to reply to someone elses ticket, please use the matching email address to that account!
This action is notified to the real ticket owner!"
email_subject_warn_unknown_sender = "You tried to reply to someone's ticket!"
email_body_warn_unknown_sender = "It seems you tried to reply to someone's ticket, However this email address isn't linked to any account, please use the matching email address to that account!
This action is notified to the real ticket owner!"