From f51c3d89d5118e45914a1de7f6bdb03dd559e32e Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Wed, 26 Jan 2011 03:05:35 +0000 Subject: added mail notifications for talk messages --- h-source/Application/Include/myFunctions.php | 20 ++++++++++++++++++++ h-source/Application/Include/params.php | 27 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'h-source/Application/Include') diff --git a/h-source/Application/Include/myFunctions.php b/h-source/Application/Include/myFunctions.php index 7e509cd..5c64317 100644 --- a/h-source/Application/Include/myFunctions.php +++ b/h-source/Application/Include/myFunctions.php @@ -392,3 +392,23 @@ function goToModeratedItem( $row = array() ) } return 'http://'.DOMAIN_NAME.'/'.$url; } + +function getUrlsFromIdHard($id_hard) +{ + $clean['id_hard'] = (int)$id_hard; + + $urlView = "http://".DOMAIN_NAME; + $urlTalk = "http://".DOMAIN_NAME; + + $hard = new HardwareModel(); + $res = $hard->select('type,model')->where(array('id_hard'=>$clean['id_hard']))->send(); + if (count($res) > 0) + { + $urlView = "http://".DOMAIN_NAME."/".MyStrings::$reverse[$res[0]['hardware']['type']]."/view/".Lang::$current."/".$clean['id_hard']."/".encodeUrl($res[0]['hardware']['model']); + + $urlTalk = "http://".DOMAIN_NAME."/".MyStrings::$reverse[$res[0]['hardware']['type']]."/talk/".Lang::$current."/".$clean['id_hard']; + } + + return array('urlView'=>$urlView,'urlTalk'=>$urlTalk); + +} \ No newline at end of file diff --git a/h-source/Application/Include/params.php b/h-source/Application/Include/params.php index 7547643..1d3533b 100644 --- a/h-source/Application/Include/params.php +++ b/h-source/Application/Include/params.php @@ -141,5 +141,32 @@ class Account } } + + static public function sendTalkNotice($who,$e_mails,$id_hard) + { + require_once (ROOT.'/External/swiftmailer/lib/swift_required.php'); + + $who = sanitizeAll($who); + $id_hard = (int)$id_hard; + + $siteName = Website::$generalName; + $siteMail = Website::$generalMail; + + $urls = getUrlsFromIdHard($id_hard); + + $mess = "$who has added a message to the talk page of a device you have contributed to maintain at $siteName\n\nThe whole conversation is here:\n\n".$urls['urlTalk']."\n\nThe device page is here:\n\n".$urls['urlView']."\n\nBest regards\nthe ".Website::$projectName." team\n\nP.S: you can disable the mail notifications in the profile page of your control panel"; + + $message = Swift_Message::newInstance()->setSubject("$who sent a notice to your attention")->setFrom(array($siteMail => $siteName))->setTo($e_mails)->setBody($mess); + + //Create the Transport + $transport = Swift_SmtpTransport::newInstance(Website::$mailServer, 25)->setUsername(Website::$generalMail)->setPassword(Website::$mailPassword); + + //Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + //Send the message + $result = $mailer->batchSend($message); + + } } \ No newline at end of file -- cgit v1.2.3