[pLog-svn] r1689 - plog/branches/plog-1.0.1/class/summary/dao
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sun Apr 3 17:00:24 GMT 2005
Author: oscar
Date: 2005-04-03 17:00:24 +0000 (Sun, 03 Apr 2005)
New Revision: 1689
Modified:
plog/branches/plog-1.0.1/class/summary/dao/summarystats.class.php
Log:
fixed issue 387 (http://bugs.plogworld.net/view.php?id=387) -- fixed the queries for the 'most commented articles', 'latest posts' and 'most read articles' which were not taking into account the status of the blog to which they belonged.
Modified: plog/branches/plog-1.0.1/class/summary/dao/summarystats.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/summary/dao/summarystats.class.php 2005-04-03 16:37:34 UTC (rev 1688)
+++ plog/branches/plog-1.0.1/class/summary/dao/summarystats.class.php 2005-04-03 17:00:24 UTC (rev 1689)
@@ -38,10 +38,16 @@
{
$prefix = $this->getPrefix();
$query = " SELECT COUNT(*) as total_comments, a.*
- FROM {$prefix}articles_comments AS c, {$prefix}articles AS a, {$prefix}articles_text t
- WHERE c.article_id = a.id AND t.article_id = a.id AND
- a.status = ".POST_STATUS_PUBLISHED." AND
- c.status = ".COMMENT_STATUS_NONSPAM;
+ FROM {$prefix}articles_comments AS c,
+ {$prefix}articles AS a,
+ {$prefix}articles_text t,
+ {$prefix}blogs b
+ WHERE c.article_id = a.id
+ AND t.article_id = a.id
+ AND a.status = ".POST_STATUS_PUBLISHED."
+ AND c.status = ".COMMENT_STATUS_NONSPAM."
+ AND b.id = a.blog_id
+ AND b.status = ".BLOG_STATUS_ACTIVE;
// ignore certain topics and/or certain texts
/*if( $ignoreTopic != "" )
@@ -82,6 +88,7 @@
*/
function getMostReadArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "", $date = 0 )
{
+ $prefix = $this->getPrefix();
$query = " SELECT
a.id as id,
a.properties as properties,
@@ -97,10 +104,11 @@
t.normalized_text as normalized_text,
t.normalized_topic as normalized_topic,
t.mangled_topic as mangled_topic
- FROM ".$this->getPrefix()."articles a, ".$this->getPrefix()."articles_text t
+ FROM {$prefix}articles a, {$prefix}articles_text t, {$prefix}blogs b
WHERE a.id = t.article_id
- AND status = ".POST_STATUS_PUBLISHED."
- AND TO_DAYS(NOW()) - TO_DAYS(date) < 7 ";
+ AND a.status = ".POST_STATUS_PUBLISHED."
+ AND TO_DAYS(NOW()) - TO_DAYS(date) < 7
+ AND a.blog_id = b.id AND b.status = ".BLOG_STATUS_ACTIVE;
// ignore certain topics and/or certain texts
if( $ignoreTopic != "" )
@@ -252,9 +260,19 @@
$query = "SELECT a.id as id, a.id,t.topic,t.text,a.date,
a.user_id,a.blog_id, a.status, a.properties,
a.num_reads, a.slug
- FROM {$prefix}articles a, {$prefix}articles_categories c, {$prefix}article_categories_link l,{$prefix}articles_text t
- WHERE t.article_id = a.id AND TO_DAYS(NOW()) - TO_DAYS(a.date) < 7 AND l.article_id = a.id AND l.category_id = c.id AND
- c.in_main_page = 1 AND a.status = ".POST_STATUS_PUBLISHED;
+ FROM {$prefix}articles a,
+ {$prefix}articles_categories c,
+ {$prefix}article_categories_link l,
+ {$prefix}articles_text t,
+ {$prefix}blogs b
+ WHERE t.article_id = a.id
+ AND TO_DAYS(NOW()) - TO_DAYS(a.date) < 7
+ AND l.article_id = a.id
+ AND l.category_id = c.id
+ AND c.in_main_page = 1
+ AND a.blog_id = b.id
+ AND b.status = ".BLOG_STATUS_ACTIVE."
+ AND a.status = ".POST_STATUS_PUBLISHED;
// in case we'd like to ignore certain posts based on a topic (like the registration message!)
More information about the pLog-svn
mailing list