Permalink
Browse files

code clean up

  • Loading branch information...
nibsirahsieu committed Apr 5, 2011
1 parent 784fddf commit f32ebcc0c4335cd530259af689b83f8e66e0e89f
@@ -22,6 +22,7 @@ public function findAndCreateRoot($scope)
public function preSave(PropelPDO $con = null)
{
+ //save sfNestedCommentableModel first
if ($this->asfNestedCommentableModel && $this->sf_commentable_model_id == null)
{
$this->asfNestedCommentableModel->save($con);
@@ -32,7 +33,7 @@ public function preSave(PropelPDO $con = null)
$root = $this->findAndCreateRoot($this->getSfCommentableModelId());
if ($this->isNew())
{
- $this->setLeftValue(0);
+ $this->setLeftValue(0); //just to make sure that it is not inTree
$this->insertAsLastChildOf($root);
}
}
@@ -108,4 +109,4 @@ public function getCommentableTitle()
{
return $this->getCommentableObject()->__toString();
}
-}
+}
@@ -28,19 +28,19 @@ public function level($level)
public function model($object)
{
- return $this->join('sfNestedComment.sfNestedCommentableModel')->
- useQuery('sfNestedCommentableModel')->
- model($object)->
- endUse();
+ return $this->join('sfNestedComment.sfNestedCommentableModel')
+ ->useQuery('sfNestedCommentableModel')
+ ->model($object)
+ ->endUse();
}
public function isAuthorApproved($name, $email)
{
- $comment = $this->
- filterByAuthorName($name)->
- filterByAuthorEmail($email)->
- approved()->
- findOne();
+ $comment = $this
+ ->filterByAuthorName($name)
+ ->filterByAuthorEmail($email)
+ ->approved()
+ ->findOne();
return $comment;
}
@@ -1,5 +1,8 @@
<?php
class PluginsfNestedCommentableModel extends BasesfNestedCommentableModel
{
-
+ public function getNbModeratedComments()
+ {
+ return $this->getNbComments() - $this->getNbApprovedComments();
+ }
}

0 comments on commit f32ebcc

Please sign in to comment.