Skip to content

Commit

Permalink
removeing comments from posts in favor of a commentable behavior. fix…
Browse files Browse the repository at this point in the history
…es issue core.1
  • Loading branch information
dogmatic69 committed Dec 28, 2009
1 parent 36c40db commit 6055ca5
Show file tree
Hide file tree
Showing 7 changed files with 512 additions and 27 deletions.
3 changes: 3 additions & 0 deletions app/app_model.php
Expand Up @@ -57,6 +57,9 @@ function save( $data = null, $validate = true, $fieldList = array() )
$data[$this->name]['locked_by'] = null;
$data[$this->name]['locked_since'] = null;

pr( $fieldList );
exit;

return parent::save( $data, $validate, $fieldList );
}

Expand Down
2 changes: 1 addition & 1 deletion app/plugins/blog/blog_app_controller.php
Expand Up @@ -58,7 +58,7 @@ function beforeFilter()
$this->set( 'postPending', ClassRegistry::init( 'Blog.Post' )->getPending() );
$this->set( 'postPopular', ClassRegistry::init( 'Blog.Post' )->getPopular() );

$this->set( 'commentCount', ClassRegistry::init( 'Blog.Comment' )->getCounts() );
$this->set( 'commentCount', ClassRegistry::init( 'Core.Comment' )->getCounts( 'Blog.Post' ) );
}

/**
Expand Down
29 changes: 9 additions & 20 deletions app/plugins/blog/controllers/comments_controller.php
Expand Up @@ -21,19 +21,7 @@ class CommentsController extends BlogAppController
{
var $name = 'Comments';

function add()
{
if ( !empty( $this->data ) )
{
$this->Comment->create();

if ( $this->Comment->save( $this->data ) )
{
$this->Session->setFlash( 'Your comment has been submitted for review.' );
$this->redirect( $this->referer() );
}
}
}
var $uses = array( 'Core.Comment' );

function admin_index( $active = null )
{
Expand All @@ -51,7 +39,7 @@ function admin_index( $active = null )
'Comment.website',
'Comment.comment',
'Comment.active',
'Comment.post_id',
'Comment.foreign_id',
'Comment.created',
),
'conditions' => $conditions,
Expand All @@ -60,11 +48,13 @@ function admin_index( $active = null )
'Comment.created' => 'ASC',
),
'limit' => 20,
'contain' => array(
'Post' => array(
'fields' => array(
'Post.title',
'Post.slug',
'Comment' => array(
'contain' => array(
'Post' => array(
'fields' => array(
'Post.title',
'Post.slug'
)
)
)
)
Expand Down Expand Up @@ -114,6 +104,5 @@ function admin_perge( $date = null )

$this->Session->setFlash( sprintf( '%s %s', $i, __( 'Comments deleted', true ) ) );
}

}
?>
6 changes: 3 additions & 3 deletions app/plugins/blog/controllers/posts_controller.php
Expand Up @@ -153,9 +153,9 @@ function admin_dashboard()
'Post.created'
),
'feed' => array(
'Blog.Comment' => array(
'Core.Comment' => array(
'setup' => array(
'plugin' => 'Blog',
'plugin' => 'Core',
'controller' => 'comments',
'action' => 'view',
),
Expand All @@ -177,7 +177,7 @@ function admin_dashboard()

$this->set( 'dashboardPostCount', $this->Post->getCounts() );
$this->set( 'dashboardPostLatest', $this->Post->getLatest() );
$this->set( 'dashboardCommentsCount', $this->Post->Comment->getCounts() );
$this->set( 'dashboardCommentsCount', $this->Post->Comment->getCounts( 'Blog.Post' ) );
}

function admin_index( $active = null )
Expand Down
6 changes: 3 additions & 3 deletions app/plugins/blog/models/post.php
Expand Up @@ -70,8 +70,8 @@ class Post extends BlogAppModel

var $hasMany = array(
'Comment' => array(
'className' => 'Blog.Comment',
'foreignKey' => 'post_id',
'className' => 'Core.Comment',
'foreignKey' => 'foreign_id',
'dependent' => true
)
);
Expand Down Expand Up @@ -239,7 +239,7 @@ function getLatest( $limit = 10, $active = 1 )
return $posts;
}

function getCounts()
function getCounts( $model = null )
{
$counts = Cache::read( 'posts_count' );
if ( $counts !== false )
Expand Down

0 comments on commit 6055ca5

Please sign in to comment.