[pLog-svn] r2225 - plog/branches/plog-1.0.2/class/action

mark at devel.plogworld.net mark at devel.plogworld.net
Wed Jun 15 03:53:45 GMT 2005


Author: mark
Date: 2005-06-15 03:53:44 +0000 (Wed, 15 Jun 2005)
New Revision: 2225

Modified:
   plog/branches/plog-1.0.2/class/action/viewarticleaction.class.php
Log:
Fixed bug http://bugs.plogworld.net/view.php?id=579

Modified: plog/branches/plog-1.0.2/class/action/viewarticleaction.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/action/viewarticleaction.class.php	2005-06-14 22:22:35 UTC (rev 2224)
+++ plog/branches/plog-1.0.2/class/action/viewarticleaction.class.php	2005-06-15 03:53:44 UTC (rev 2225)
@@ -9,6 +9,7 @@
     include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
 	include_once( PLOG_CLASS_PATH."class/view/viewarticleview.class.php" );
+	include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
 
     /**
      * \ingroup Action
@@ -23,6 +24,7 @@
         var $_articleId;
 		var $_articleName;
 		var $_date;
+		var $_maxDate;
 		var $_userId;
 		var $_userName;
 		var $_categoryId;
@@ -48,6 +50,9 @@
 			$this->_date = $this->_request->getValue( "Date", -1 );
 			$this->_isCommentAdded = ($this->_request->getValue( "op" ) == "AddComment" );
 
+			// Caculate the correct article date period
+			$this->_getArticleCorrectedDatePeriod();
+
             return true;
         }
 		
@@ -99,6 +104,50 @@
 			return( true );
 		}
 
+		/**
+		 * @private
+		 * Caculate the correct article date period
+		 */		        
+        function _getArticleCorrectedDatePeriod()
+        {
+            $blogSettings = $this->_blogInfo->getSettings();
+            $serverTimeOffset = $blogSettings->getValue( "time_offset" );
+            
+            if( $serverTimeOffset == 0)
+            {
+            	$this->_maxDate = -1;
+            }
+            else
+            {
+	            if( strlen($this->_date) == 4 ) 
+	        	{
+	        		$year = $this->_date;
+	        		$this->_date = Timestamp::getDateWithOffset( $year."0101000000", -$serverTimeOffset );
+	        		$this->_maxDate = Timestamp::getDateWithOffset( $year."1231235959", -$serverTimeOffset );
+	        	} 
+	        	elseif ( strlen($this->_date) == 6 ) 
+	        	{
+	                $year = substr( $this->_date, 0, 4 );
+	                $month = substr( $this->_date, 4, 2 );
+	                $dayOfMonth = Date_Calc::daysInMonth( $month, $year );
+	        		$this->_date = Timestamp::getDateWithOffset( $year.$month."01000000", -$serverTimeOffset );
+	        		$this->_maxDate = Timestamp::getDateWithOffset( $year.$month.$dayOfMonth."235959", -$serverTimeOffset );
+	        	}
+	        	elseif ( strlen($this->_date) == 8 )
+	        	{
+	        		$year = substr( $this->_date, 0, 4 );
+	                $month = substr( $this->_date, 4, 2 );
+	                $day = substr( $this->_date, 6, 2 );
+	        		$this->_date = Timestamp::getDateWithOffset( $year.$month.$day."000000", -$serverTimeOffset );
+	        		$this->_maxDate = Timestamp::getDateWithOffset( $year.$month.$day."235959", -$serverTimeOffset );
+	        	}
+	        	else
+	        	{
+	        		$this->_maxDate = -1;
+	        	}
+            }
+        }
+
         function perform()
         {
 
@@ -159,12 +208,12 @@
             if( $this->_articleId ) { 
                 $article  = $this->articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId(), false, 
 				                                       $this->_date, $this->_categoryId, $this->_userId,
-													   POST_STATUS_PUBLISHED );
+													   POST_STATUS_PUBLISHED, $this->_maxDate );
 			}
             else {
                 $article  = $this->articles->getBlogArticleByTitle( $this->_articleName, $this->_blogInfo->getId(), false,
 				                                              $this->_date, $this->_categoryId, $this->_userId,
-															  POST_STATUS_PUBLISHED );
+															  POST_STATUS_PUBLISHED, $this->_maxDate );
 			}
 				
             // if the article id doesn't exist, cancel the whole thing...




More information about the pLog-svn mailing list