[pLog-svn] r4574 - plog/trunk/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Jan 25 08:39:56 EST 2007


Author: oscar
Date: 2007-01-25 13:39:55 +0000 (Thu, 25 Jan 2007)
New Revision: 4574

Modified:
   plog/trunk/class/dao/articlenotifications.class.php
Log:
Small optimization (those global _config and _locale attributes are not needed) and improvement so that the blog locale is used everywhere.

Modified: plog/trunk/class/dao/articlenotifications.class.php
===================================================================
--- plog/trunk/class/dao/articlenotifications.class.php	2007-01-25 08:49:05 UTC (rev 4573)
+++ plog/trunk/class/dao/articlenotifications.class.php	2007-01-25 13:39:55 UTC (rev 4574)
@@ -13,9 +13,6 @@
      */
     class ArticleNotifications extends Model 
 	{
-
-		var $_config;
-        var $_locale;
     	/**
          * Constructor. Does nothing yet.
          */
@@ -23,8 +20,7 @@
         {
         	$this->Model();
 
-            $this->_config =& Config::getConfig();
-            $this->_locale =& Locales::getLocale( $this->_config->getValue( "default_locale" ));
+			$this->table = $this->getPrefix()."article_notifications";
         }
 
         /**
@@ -78,17 +74,19 @@
           * 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, $charset = 'iso-8859-1' )
+         function notifyUser( $notification, $userInfo, $subject, $body, $locale )
          {
             lt_include( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
             lt_include( PLOG_CLASS_PATH."class/mail/emailmessage.class.php" );
-                   
+            lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+
+			$config =& Config::getConfig();
             $message = new EmailMessage();
-            $message->setFrom( $this->_config->getValue( "post_notification_source_address" ));
+            $message->setFrom( $config->getValue( "post_notification_source_address" ));
             $message->addTo( $userInfo->getEmail());
-            $message->setSubject( $this->_locale->tr("notification_subject" ) );
+            $message->setSubject( $locale->tr("notification_subject" ) );
             $message->setBody( $body );
-            $message->setCharset( $charset );
+            $message->setCharset( $locale->getCharset());
 
             $service = new EmailService();
             return $service->sendMessage( $message );
@@ -116,13 +114,12 @@
             
             // 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, $this->_locale->tr("notification_subject" ), $message, $charset );
+            	$this->notifyUser( $notif, $userInfo, $blogLocale->tr("notification_subject" ), $message, $blogLocale );
             }
          }
 



More information about the pLog-svn mailing list