diff --git a/lib/email/Email.inc b/lib/email/Email.inc index f8939c3..ee34c33 100644 --- a/lib/email/Email.inc +++ b/lib/email/Email.inc @@ -8,31 +8,31 @@ * Document Management Made Simple * Copyright (C) 2008, 2009 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original + * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ */ @@ -49,7 +49,7 @@ class Email { * with default system information * * @param string the sender's email address (optional) - * @param string the sender's name (optional) + * @param string the sender's name (optional) */ function Email($sFromEmail = "", $sFromName = "") { global $default; @@ -66,8 +66,8 @@ class Email { $this->oMailer->IsHTML(true); $this->oMailer->SetLanguage('en', KT_DIR . '/thirdparty/phpmailer/language/'); $this->bEmailDisabled = false; - - $oConfig =& KTConfig::getSingleton(); + + $oConfig =& KTConfig::getSingleton(); $sEmailServer = $oConfig->get('email/emailServer'); if ($sEmailServer == 'none') { $this->bEmailDisabled = true; @@ -90,7 +90,7 @@ class Email { $this->oMailer->Password = $sEmailPass; } } - + /** * Sends an email to a specified recipient. * @@ -98,7 +98,7 @@ class Email { * @param string the subject of the email * @param string the body of the email * @param string the sender's email address (optional) - * @param string the sender's name (optional) + * @param string the sender's name (optional) * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] */ function send($mToEmail, $sSubject, $sBody) { @@ -106,9 +106,9 @@ class Email { return PEAR::raiseError(_kt("Email is not configured.")); } global $default; - - if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || - (is_array($mToEmail) && (count($mToEmail) > 0)) ) { + + if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || + (is_array($mToEmail) && (count($mToEmail) > 0)) ) { $aEmailAddresses = array(); // just one email address, add it @@ -118,7 +118,7 @@ class Email { // if we're passed an array, then use it if (is_array($mToEmail)) { $aEmailAddresses = $mToEmail; - // if there are multiple addresses (; separated), explode it + // if there are multiple addresses (; separated), explode it } elseif (strpos($mToEmail, ";") > 0) { $aEmailAddresses = explode(";", $mToEmail); } @@ -128,9 +128,11 @@ class Email { } } + $body = $this->makeEmailTemplate(stripslashes($sBody)); $this->oMailer->Subject = stripslashes($sSubject); - $this->oMailer->Body = stripslashes($sBody); - +// $this->oMailer->Body = stripslashes($sBody); + $this->oMailer->Body = $body; + //send the email if(!$this->oMailer->Send()) { $default->log->error("Error sending mail to $mToEmail; mailer error code=" . $this->oMailer->ErrorInfo); @@ -160,9 +162,9 @@ class Email { return PEAR::raiseError(_kt("Email is not configured.")); } global $default; - - if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || - (is_array($mToEmail) && (count($mToEmail) > 0)) ) { + + if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || + (is_array($mToEmail) && (count($mToEmail) > 0)) ) { // just one email address, add it if (is_string($mToEmail) && (strpos($mToEmail, ";") === false)) { @@ -172,7 +174,7 @@ class Email { // if we're passed an array, then use it if (is_array($mToEmail)) { $aEmailAddresses = $mToEmail; - // if there are multiple addresses (; separated), explode it + // if there are multiple addresses (; separated), explode it } elseif (strpos($mToEmail, ";") > 0) { $aEmailAddresses = explode(";", $mToEmail); } @@ -182,10 +184,12 @@ class Email { } } + $body = $this->makeEmailTemplate(stripslashes($sBody)); $this->oMailer->Subject = stripslashes($sSubject); - $this->oMailer->Body = stripslashes($sBody); +// $this->oMailer->Body = stripslashes($sBody); + $this->oMailer->Body = $body; $this->oMailer->AddAttachment($sDocumentPath, $sDocumentName); - + //send the email if(!$this->oMailer->Send()) { $default->log->error("Error sending mail to $mToEmail; mailer error code=" . $this->oMailer->ErrorInfo); @@ -211,7 +215,7 @@ class Email { * @param The hyperlink that should be sent * * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] - * + * * @todo check for special characters (including encoding the link correctly???) * @todo need to test this on multiple mail clients, not just Outlook */ @@ -221,12 +225,15 @@ class Email { } global $default; + $body = $this->makeEmailTemplate(stripslashes($EmailBody).'

'.$hyperlink); + //get info from relevant fields. $this->oMailer->From = $FromEmail; $this->oMailer->FromName = $FromName; $this->oMailer->AddAddress($ToEmail); $this->oMailer->Subject = stripslashes($Subj); - $this->oMailer->Body = stripslashes($EmailBody) . ' ' . $hyperlink; +// $this->oMailer->Body = stripslashes($EmailBody) . ' ' . $hyperlink; + $this->oMailer->Body = $body; //send the email if(!$this->oMailer->Send()) { @@ -236,7 +243,7 @@ class Email { return true; } /** - * Sends an email ment for administration, + * Sends an email ment for administration, * * @param The sender's email address * @param The sender's Name @@ -246,7 +253,7 @@ class Email { * @param The hyperlink that should be sent * * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] - * + * * @todo check for special characters (including encoding the link correctly???) * @todo need to test this on multiple mail clients, not just Outlook */ @@ -256,12 +263,15 @@ class Email { } global $default; + $body = $this->makeEmailTemplate(stripslashes($EmailBody) . "
" . _kt("This bug can be found on this page") . ": " . "". $hyperlink .""); + //get info from relevant fields. $this->oMailer->From = $FromEmail; $this->oMailer->FromName = $FromName; $this->oMailer->AddAddress($ToEmail); $this->oMailer->Subject = stripslashes($Subj) . ' ' . $hyperlink; //only difference from above - $this->oMailer->Body = stripslashes($EmailBody) . "
" . _kt("This bug can be found on this page") . ": " . "". $hyperlink .""; +// $this->oMailer->Body = stripslashes($EmailBody) . "
" . _kt("This bug can be found on this page") . ": " . "". $hyperlink .""; + $this->oMailer->Body = $body; //send the email if(!$this->oMailer->Send()) { @@ -277,12 +287,14 @@ class Email { } global $default; + $body = $this->makeEmailTemplate(stripslashes($EmailBody)); + //get info from relevant fields. $this->oMailer->From = $FromEmail; $this->oMailer->FromName = $FromName; $this->oMailer->AddAddress($ToEmail); $this->oMailer->Subject = stripslashes($Subj); - $this->oMailer->Body = stripslashes($EmailBody); + $this->oMailer->Body = $body; //send the email if(!$this->oMailer->Send()) { @@ -291,6 +303,48 @@ class Email { } return true; } -} -?> + /* + * This method builds the email template + * + * @author KnowledgeTree Team + * @access public + * @param string $email The email to be sent + * @return string $str The html string that will be sent via email + */ + public function makeEmailTemplate($email) + { + $rootUrl = KTUtil::kt_url(); + + $oKTConfig =& KTConfig::getSingleton(); + $mainLogo = $oKTConfig->get('mainLogo'); + $appName = $oKTConfig->get('appName'); + $companyLogoTitle = $oKTConfig->get('companyLogoTitle'); + $mainLogoTitle = $oKTConfig->get('mainLogoTitle'); + + if($mainLogo != ''){ + $logo = ''.$companyLogoTitle.''; + }else{ + $logo = ''; + } + + $str = ' + + + + + + + + +
+ '.$logo.' +
+ '.$email.' +
+ + '; + return $str; + } +} +?> \ No newline at end of file