[pLog-svn] r4467 - plog/branches/lifetype-1.1.4/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Tue Jan 2 21:48:13 GMT 2007


Author: oscar
Date: 2007-01-02 21:48:11 +0000 (Tue, 02 Jan 2007)
New Revision: 4467

Modified:
   plog/branches/lifetype-1.1.4/class/dao/commentscommon.class.php
   plog/branches/lifetype-1.1.4/class/dao/usercomment.class.php
Log:
dirty fix for mantis issue 1144 (http://bugs.lifetype.net/view.php?id=1144)


Modified: plog/branches/lifetype-1.1.4/class/dao/commentscommon.class.php
===================================================================
--- plog/branches/lifetype-1.1.4/class/dao/commentscommon.class.php	2007-01-02 04:40:29 UTC (rev 4466)
+++ plog/branches/lifetype-1.1.4/class/dao/commentscommon.class.php	2007-01-02 21:48:11 UTC (rev 4467)
@@ -338,7 +338,17 @@
          * @return true if update successful or false otherwise.
          */
         function updateComment( $comment )
-        {    
+        {
+			// we need to undo the time offset before updating the comment, or else the comment will be saved
+			// with the time offset applied
+			$blogInfo = $comment->getBlogInfo();
+			$blogOffset = $blogInfo->getValue( "time_offset" );
+			if( $blogOffset != 0 ) {
+				// if there's an offset...
+				$newDate = Timestamp::getDateWithOffset( $comment->getDate(), -$blogOffset );
+				$comment->setDate( $newDate );
+			}
+	
         	if(($result = $this->update( $comment ))) {
 	        	// reset the cache
                 $this->_cache->removeData( $comment->getArticleId(), CACHE_ARTICLE_COMMENTS_BYARTICLE_NEWEST_TO_OLDEST );
@@ -365,6 +375,12 @@
     			}
     			$articles->updateArticle( $article );
         	}
+
+			// this is not the cleanest solution but it will do the trick for now...
+			if( $blogOffset != 0 ) {
+				$newDate = Timestamp::getDateWithOffset( $comment->getDate(), $blogOffset );
+				$comment->setDate( $newDate );
+			}
         	
         	return( $result );
         }

Modified: plog/branches/lifetype-1.1.4/class/dao/usercomment.class.php
===================================================================
--- plog/branches/lifetype-1.1.4/class/dao/usercomment.class.php	2007-01-02 04:40:29 UTC (rev 4466)
+++ plog/branches/lifetype-1.1.4/class/dao/usercomment.class.php	2007-01-02 21:48:11 UTC (rev 4467)
@@ -33,6 +33,7 @@
 		var $_normalizedText;
 		var $_normalizedTopic;
 		var $_article;
+		var $_blogInfo;
 
         /**
          * Creates a new user comment.
@@ -78,6 +79,8 @@
 			
 			$this->setProperties( $properties );
 			
+			$this->_blogInfo = null;
+			
 			$this->_fields = Array(
 			   "article_id" => "getArticleId",
 			   "blog_id" => "getBlogId",
@@ -272,7 +275,7 @@
 		{ 
 			return $this->_timeStamp;
 		}
-
+		
         /**
          * Returns the identifier of the comment to which this one was replying.
          *
@@ -486,6 +489,22 @@
         {
         	return( $this->getUserName());
         }
+
+		/**
+		 * Returns the BlogInfo object to which this comment/trackback is linked
+		 *
+		 * @param return A BlogInfo object
+		 */
+		function getBlogInfo()
+		{
+			if( $this->_blogInfo === null ) {
+				include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
+				$blogs = new Blogs();
+				$this->_blogInfo = $blogs->getBlogInfo( $this->getBlogId());
+			}
+			
+			return( $this->_blogInfo );
+		}
 		
 		/**
 		 * sets the normalized text



More information about the pLog-svn mailing list