[pLog-svn] r2080 - plog/branches/plog-1.0.2/class/dao
Oscar Renalias
oscar at renalias.net
Wed May 25 18:02:35 GMT 2005
This is a change that we should monitor closely... please report
anything strange with this, please.
Oscar
On 25 May 2005, at 20:27, jondaley at devel.plogworld.net wrote:
> Author: jondaley
> Date: 2005-05-25 17:27:49 +0000 (Wed, 25 May 2005)
> New Revision: 2080
>
> Modified:
> plog/branches/plog-1.0.2/class/dao/articles.class.php
> Log:
> time offset is now taken into consideration. http://
> bugs.plogworld.net/view.php?id=541
>
> Modified: plog/branches/plog-1.0.2/class/dao/articles.class.php
> ===================================================================
> --- plog/branches/plog-1.0.2/class/dao/articles.class.php
> 2005-05-25 13:26:02 UTC (rev 2079)
> +++ plog/branches/plog-1.0.2/class/dao/articles.class.php
> 2005-05-25 17:27:49 UTC (rev 2080)
> @@ -247,8 +247,13 @@
> $postStatus = $status;
> $prefix = $this->getPrefix();
> $query = "a.blog_id = ".Db::qstr($blogid);
> - if( $date != -1 )
> - $query .= " AND a.date+0 LIKE '$date%'";
> + if( $date != -1 ) {
> + // consider the time difference
> + $blogSettings = $this->blogs->getBlogSettings
> ( $blogid );
> + $timeDifference = $blogSettings->getValue
> ( "time_offset" );
> + $SecondsDiff = $timeDifference * 3600;
> + $query .= " AND FROM_UNIXTIME(UNIX_TIMESTAMP
> (a.date)+$SecondsDiff)+0 LIKE '$date%'";
> + }
>
> // the common part "c.id = a.category_id" is needed so
> that
> // we don't get one article row as many times as the
> amount of categories
> @@ -376,8 +381,7 @@
> $start = (($page - 1) * $amount);
> $query .= " LIMIT $start, $amount";
> }
> -
> -
> +
> // execute the query
> $result = $this->Execute( $query );
>
> @@ -508,9 +512,8 @@
> {
> // query to get the earliest post
> // this must be my longest and most complex SQL query
> ever :)
> - $blogs = new Blogs();
> - $blogSettings = $blogs->getBlogSettings( $blogId );
> -
> + // $blogs = new Blogs();
> + $blogSettings = $this->blogs->getBlogSettings( $blogId );
> if( $blogSettings->getValue
> ( "show_future_posts_in_calendar" ))
> $numPostsPerMonthQuery = "SELECT COUNT(*) AS
> 'count',YEAR(date) AS 'year',MONTH(date) AS 'month',DAYOFMONTH
> (date) AS 'daymonth' FROM ".$this->getPrefix()."articles WHERE
> status = 1 AND blog_id = ".$blogId." GROUP BY YEAR(date),MONTH
> (date) ORDER BY YEAR(date) DESC,MONTH(date) DESC;";
> else
> @@ -578,13 +581,16 @@
>
> // another long sql query :) the id and date fields
> are there just in case we need to debug
> // but they're not included in the resulting array
> - $blogs = new Blogs();
> - $blogSettings = $blogs->getBlogSettings( $blogId );
> + // $blogs = new Blogs();
> + $blogSettings = $this->blogs->getBlogSettings( $blogId );
> + // consider the time difference
> + $timeDifference = $blogSettings->getValue
> ( "time_offset" );
> + $SecondsDiff = $timeDifference * 3600;
> // check whether we're supposed to show posts that
> happen in the future or not
> - if( $blogSettings->getValue
> ( "show_future_posts_in_calendar" ))
> - $numPostsPerDayQuery = "SELECT COUNT(*) AS
> 'count', DAYOFMONTH(date) AS 'day', id AS 'id', date AS 'date' FROM
> ".$this->getPrefix()."articles WHERE status = 1 AND blog_id = ".
> $blogId." AND MONTH(date) = ".$month." AND YEAR(date) = ".$year."
> GROUP BY DAYOFMONTH(date);";
> + if( $blogSettings->getValue
> ( "show_future_posts_in_calendar" ))
> + $numPostsPerDayQuery = "SELECT COUNT(*) AS
> 'count', DAYOFMONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(date) +
> $SecondsDiff)) AS 'day', id AS 'id', date AS 'date' FROM ".$this-
> >getPrefix()."articles WHERE status = 1 AND blog_id = ".$blogId."
> AND MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(date) + $SecondsDiff)) = ".
> $month." AND YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(date) +
> $SecondsDiff)) = ".$year." GROUP BY DAYOFMONTH(FROM_UNIXTIME
> (UNIX_TIMESTAMP(date) + $SecondsDiff));";
> else
> - $numPostsPerDayQuery = "SELECT COUNT(*) AS
> 'count', DAYOFMONTH(date) AS 'day', id AS 'id', date AS 'date' FROM
> ".$this->getPrefix()."articles WHERE status = 1 AND blog_id = ".
> $blogId." AND date <= NOW() AND MONTH(date) = ".$month." AND YEAR
> (date) = ".$year." GROUP BY DAYOFMONTH(date);";
> + $numPostsPerDayQuery = "SELECT COUNT(*) AS
> 'count', DAYOFMONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(date) +
> $SecondsDiff)) AS 'day', id AS 'id', date AS 'date' FROM ".$this-
> >getPrefix()."articles WHERE status = 1 AND blog_id = ".$blogId."
> AND date <= NOW() AND MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(date) +
> $SecondsDiff)) = ".$month." AND YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP
> (date) + $SecondsDiff)) = ".$year." GROUP BY DAYOFMONTH
> (FROM_UNIXTIME(UNIX_TIMESTAMP(date) + $SecondsDiff));";
>
> $result = $this->Execute( $numPostsPerDayQuery );
>
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-svn
>
>
More information about the pLog-svn
mailing list