[pLog-svn] r2972 - plugins/branches/lifetype-1.0/blogtimes

pwestbro at devel.lifetype.net pwestbro at devel.lifetype.net
Mon Feb 20 19:12:08 GMT 2006


Author: pwestbro
Date: 2006-02-20 19:12:07 +0000 (Mon, 20 Feb 2006)
New Revision: 2972

Modified:
   plugins/branches/lifetype-1.0/blogtimes/pluginblogtimes.class.php
Log:
Fixed bug http://bugs.lifetype.net/view.php?id=843.  Now the blogtimes plugin takes into account the time zone offset when generating the image.

Modified: plugins/branches/lifetype-1.0/blogtimes/pluginblogtimes.class.php
===================================================================
--- plugins/branches/lifetype-1.0/blogtimes/pluginblogtimes.class.php	2006-02-18 23:13:34 UTC (rev 2971)
+++ plugins/branches/lifetype-1.0/blogtimes/pluginblogtimes.class.php	2006-02-20 19:12:07 UTC (rev 2972)
@@ -3,6 +3,7 @@
     include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
     include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+    include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
     include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
 
     /**
@@ -84,35 +85,34 @@
             return $this->pluginEnabled;
         }        
 
-        /**
-         * process the events that we have registered
-         *
-         * @see PluginBase::process
-         * @see PluginManager
-         */
-        function process( $eventType, $params )
-        {
-            // make sure we're processing the right event!
-            if( $eventType != EVENT_POST_POST_ADD ) 
-            {
-                return true;
-            }
-            
-            // Load all of the settings for this blog
-            $this->register();
-            
-            // make sure that the plugin is enabled
-			if( !$this->isEnabled())
-            {
-                return true;
-            }
-                        
-            // Update the Blogtime png
+        /**
+         * process the events that we have registered
+         *
+         * @see PluginBase::process
+         * @see PluginManager
+         */
+        function process( $eventType, $params )
+        {
+            // make sure we're processing the right event!
+            if( $eventType != EVENT_POST_POST_ADD )
+            {
+             return true;
+            }
+            
+            // Load all of the settings for this blog
+            $this->register();
+            
+            // make sure that the plugin is enabled
+            if( !$this->isEnabled())
+            {
+             return true;
+            }
+            
+            // Update the Blogtime png
             $this->updateBlogTimePNG();
-
-            return true;
-        }
-        
+            return true;
+        }
+        
         function show() {
             $saveFile = $this->cacheFolder."/blogtimes.png";
             $rg =& RequestGenerator::getRequestGenerator( $this->blogInfo );
@@ -234,8 +234,15 @@
         function getPostTimes($lastDays = 30)
         {
             $blogId = $this->blogInfo->getId();
+            
+            //
+            // if there's a time difference applied to all dates, then we'd better
+            // calculate it here!!
+            //
+            $blogSettings = $this->blogInfo->getSettings();
+            $timeDiff = $blogSettings->getValue( 'time_offset' );
 
-            $query = "SELECT HOUR(date)*60+MINUTE(date) AS totmins FROM ".$this->prefix."articles";
+            $query = "SELECT date FROM ".$this->prefix."articles";
             $query .= " WHERE blog_id = ".$blogId." AND status = 1";
             $query .= " AND (TO_DAYS(CURRENT_DATE) - TO_DAYS(date)) <= '$lastDays'";
             $query .= " ORDER BY date ASC";
@@ -247,7 +254,12 @@
 
             $postTimes = Array();
             while( $row = $result->FetchRow()) {
-                array_push( $postTimes, $row["totmins"]);
+                // we can use this auxiliary function to help us...
+                $date = new Timestamp( Timestamp::getDateWithOffset( 
+                                           $row['date'], 
+                                           $timeDiff ));
+                
+               array_push( $postTimes, ($date->getHour()*60)+$date->getMinute());
             }
             
             return $postTimes;



More information about the pLog-svn mailing list