[pLog-svn] r1868 - in plog/branches/plog-1.0.1/class: dao mail
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Mon Apr 18 18:57:16 GMT 2005
Author: oscar
Date: 2005-04-18 18:57:16 +0000 (Mon, 18 Apr 2005)
New Revision: 1868
Modified:
plog/branches/plog-1.0.1/class/dao/articlenotifications.class.php
plog/branches/plog-1.0.1/class/mail/emailmessage.class.php
plog/branches/plog-1.0.1/class/mail/emailservice.class.php
Log:
this solves issue 414 (http://bugs.plogworld.net/view.php?id=414), by taking the character set from the current locale and passing it to the EmailMessage class (who will eventually pass this information onto the PHPMailer class)
Modified: plog/branches/plog-1.0.1/class/dao/articlenotifications.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/dao/articlenotifications.class.php 2005-04-18 18:22:18 UTC (rev 1867)
+++ plog/branches/plog-1.0.1/class/dao/articlenotifications.class.php 2005-04-18 18:57:16 UTC (rev 1868)
@@ -75,9 +75,11 @@
* mainly will need the email address!)
* @param subject Subject of the message that will be sent to the user.
* @param body Message that will be sent to the user.
+ * @param charset the encoding that will be used in the message (it should be based
+ * on the locale of the blog who is sending this message) It defaults to iso-8859-1
* @return Returns true if the user was correctly notified or false otherwise.
*/
- function notifyUser( $notification, $userInfo, $subject, $body )
+ function notifyUser( $notification, $userInfo, $subject, $body, $charset = 'iso-8859-1' )
{
//print( "sending notification to ".$userInfo->getEmail()."<br/>");
$message = new EmailMessage();
@@ -85,6 +87,7 @@
$message->addTo( $userInfo->getEmail());
$message->setSubject( "pLog Notification system" );
$message->setBody( $body );
+ $message->setCharset( $charset );
$service = new EmailService();
return $service->sendMessage( $message );
@@ -111,12 +114,16 @@
$articles = new Articles();
$article = $articles->getBlogArticle( $postId, $blogId );
+
+ // get the correct character set
+ $blogLocale =& $blogInfo->getLocale();
+ $charset = $blogLocale->getCharset();
$users = new Users();
foreach( $artNotifs as $notif ) {
$userInfo = $users->getUserInfoFromId( $notif->getUserId());
$message = $this->renderMessageTemplate( $article, $blogInfo );
- $this->notifyUser( $notif, $userInfo, "pLog Notification", $message );
+ $this->notifyUser( $notif, $userInfo, "pLog Notification", $message, $charset );
}
}
Modified: plog/branches/plog-1.0.1/class/mail/emailmessage.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/mail/emailmessage.class.php 2005-04-18 18:22:18 UTC (rev 1867)
+++ plog/branches/plog-1.0.1/class/mail/emailmessage.class.php 2005-04-18 18:57:16 UTC (rev 1868)
@@ -21,6 +21,7 @@
var $_mimeType;
var $_from;
var $_fromName;
+ var $_charset;
/**
@@ -33,6 +34,8 @@
$this->_toAddrs = Array();
$this->_ccAddrs = Array();
$this->_bccAddrs = Array();
+ // use iso-8859-1 as the default character set
+ $this->_charset = "iso-8859-1";
$this->_mimeType = "text/plain";
}
@@ -195,6 +198,27 @@
function getFromName()
{
return $this->_fromName;
- }
+ }
+
+ /**
+ * Sets the character set of the message
+ *
+ * @param charset The new character set
+ */
+ function setCharset( $charset )
+ {
+ $this->_charset = $charset;
+ }
+
+ /**
+ * Retrieves the character set that was set for this message. Returns
+ * by default 'iso-8859-1' if no other has been set
+ *
+ *Ê@return the character set
+ */
+ function getCharset()
+ {
+ return( $this->_charset );
+ }
}
?>
Modified: plog/branches/plog-1.0.1/class/mail/emailservice.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/mail/emailservice.class.php 2005-04-18 18:22:18 UTC (rev 1867)
+++ plog/branches/plog-1.0.1/class/mail/emailservice.class.php 2005-04-18 18:57:16 UTC (rev 1868)
@@ -105,6 +105,9 @@
$mail->AddCC( $cc );
foreach( $message->getBcc() as $bcc )
$mail->AddBCC( $bcc );
+
+ // set the character set of the message
+ $mail->CharSet = $message->getCharset();
//
// phpmailer supports
More information about the pLog-svn
mailing list