[pLog-svn] r690 - in plog/trunk: class/dao templates/admin
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sat Jan 8 16:57:01 GMT 2005
Author: oscar
Date: 2005-01-08 16:57:00 +0000 (Sat, 08 Jan 2005)
New Revision: 690
Modified:
plog/trunk/class/dao/article.class.php
plog/trunk/class/dao/articles.class.php
plog/trunk/templates/admin/editposts.template
Log:
there was a problem with the admin interface, that was only taking into account the number of non-spam comments when displaying the number of comments that a post had. I have modified the methods Article::getComments and Article::getTotalComments to include a parameter to show only those active ones. The public side shows the correct number (only the non-spam ones) while the admin interface shows all of them.
Modified: plog/trunk/class/dao/article.class.php
===================================================================
--- plog/trunk/class/dao/article.class.php 2005-01-08 16:41:35 UTC (rev 689)
+++ plog/trunk/class/dao/article.class.php 2005-01-08 16:57:00 UTC (rev 690)
@@ -40,6 +40,7 @@
var $_blogInfo;
var $_status;
var $_totalComments;
+ var $_totalRealComments;
var $_numReads;
var $_numTrackbacks;
var $_properties;
@@ -248,12 +249,25 @@
* Returns an array of UserComment objects, with all the comments that have been received for
* this article.
*
+ * @param onlyActive return only those comments that are not marked as spam
* @return An array of UserComment objects.
* @see UserComment
*/
- function getComments()
+ function getComments( $onlyActive = true )
{
- return $this->_comments;
+ // if we only want to return the active ones, then we have to loop through
+ // the array once more
+ if( $onlyActive ) {
+ $comments = Array();
+ foreach( $this->_comments as $comment ) {
+ if( $comment->getStatus() == COMMENT_STATUS_NONSPAM )
+ $comments[] = $comment;
+ }
+ }
+ else
+ $comments = $this->_comments;
+
+ return( $comments );
}
/**
@@ -476,13 +490,22 @@
/**
* Returns the number of comments that this post has (only the number!!)
*
+ * @param onlyActive return only the number of active (as in non-spam, etc)
* @return An integer containing the number of comments that this post has.
*/
- function getTotalComments()
+ function getTotalComments( $onlyActive = true )
{
- //if( $this->_comments != null )
- // return $this->_comments->getTotalComments();
- return $this->_totalComments;
+ if( $onlyActive ) {
+ $num = 0;
+ foreach( $this->_comments as $comment ) {
+ if( $comment->getStatus() == COMMENT_STATUS_NONSPAM )
+ $num++;
+ }
+ }
+ else
+ $num = $this->_totalComments;
+
+ return( $num );
}
/**
@@ -505,13 +528,15 @@
}
/**
+ * sets the total number of active comments
+ *
* @private
*/
function setTotalComments( $totalComments )
{
$this->_totalComments = $totalComments;
}
-
+
/**
* @private
*/
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2005-01-08 16:41:35 UTC (rev 689)
+++ plog/trunk/class/dao/articles.class.php 2005-01-08 16:57:00 UTC (rev 690)
@@ -403,7 +403,7 @@
}
$ids = substr($ids, 0, -1);
- $articleComments = $this->comments->getPostCommentsByIds( $ids, COMMENT_ORDER_NEWEST_FIRST, COMMENT_STATUS_NONSPAM );
+ $articleComments = $this->comments->getPostCommentsByIds( $ids, COMMENT_ORDER_NEWEST_FIRST, COMMENT_STATUS_ALL );
$articleTrackbacks = $this->trackbacks->getArticleTrackbacksByIds( $ids );
$articleCategories = $this->categories->getArticleCategoriesByIds( $ids );
$articleTexts = $this->getArticlesText( $ids );
@@ -1101,7 +1101,7 @@
$article->setTimeOffset( $timeDiff );
// get information about the categories of the article
$articleTrackbacks = $this->trackbacks->getArticleTrackbacks( $query_result['id'] );
- $articleComments = $this->comments->getPostComments( $article->getId(), $blogSettings->getValue( 'comments_order' ), COMMENT_STATUS_NONSPAM );
+ $articleComments = $this->comments->getPostComments( $article->getId(), $blogSettings->getValue( 'comments_order' ), COMMENT_STATUS_ALL );
$article->setCategories( $articleCategories );
$article->setUserInfo( $this->users->getUserInfoFromId( $query_result['user_id'] ));
$article->setNumTrackbacks( count($articleTrackbacks));
Modified: plog/trunk/templates/admin/editposts.template
===================================================================
--- plog/trunk/templates/admin/editposts.template 2005-01-08 16:41:35 UTC (rev 689)
+++ plog/trunk/templates/admin/editposts.template 2005-01-08 16:57:00 UTC (rev 690)
@@ -119,8 +119,8 @@
{/foreach}
</td>
<td style="text-align: center;">
- {if $post->getTotalComments() > 0}
- <a href="?op=editComments&articleId={$post->getId()}">({$post->getTotalComments()})</a>
+ {if $post->getTotalComments(false) > 0}
+ <a href="?op=editComments&articleId={$post->getId()}">({$post->getTotalComments(false)})</a>
{else}
0
{/if}
More information about the pLog-svn
mailing list