2
2
# This program is distributed under the terms of the
3
3
# GNU General Public License, version 2.
5
# $Id: Comments.pm 3742 2009-05-26 15:13:38Z jmarcotte $
5
# $Id: Comments.pm 4075 2009-07-23 15:22:27Z plim $
7
7
package MT::App::Comments;
889
891
$app->translate( "An error occurred: [_1]", $app->errstr() ) )
892
$app->run_callbacks( 'api_post_save.comment', $app, $comment, $commenter );
894
894
my $remember = $q->param('bakecookie') || 0;
895
895
$remember = 0 if $remember eq 'Forget Info'; # another value for '0'
896
896
if ( $commenter && $remember ) {
976
976
if ( $comment->id && !$comment->is_junk ) {
978
$app->run_callbacks( 'api_post_save.comment', $app, $comment, $commenter );
978
981
{ message => $app->translate(
979
982
'Comment on "[_1]" by [_2].', $entry->title,
1479
sub comment_listing {
1481
$app->{no_print_body} = 1;
1482
$app->response_code(200);
1483
$app->response_message('OK');
1484
$app->send_http_header('text/javascript');
1487
require MT::Comment;
1488
require MT::Template;
1489
require MT::Template::Context;
1491
my $entry_id = $app->param('entry_id');
1492
return '1;' if ( !$entry_id );
1493
my $entry = MT::Entry->load($entry_id);
1494
return '1;' if ( !$entry );
1495
my $offset = $app->param('offset');
1498
if ( $offset !~ /^\d+$/ ) {
1501
my $limit = $app->param('limit');
1503
if ( $limit !~ /^\d+$/ ) {
1506
my $direction = 'ascend';
1507
if ( $app->param('direction') eq 'descend' ) {
1508
$direction = 'descend';
1510
my $method = $app->param('method');
1511
$method ||= 'displayComments';
1512
my $tmpl = MT::Template->load(
1513
{ name => 'Comment Listing',
1514
blog_id => $entry->blog_id
1517
return '1;' if ( !$tmpl );
1518
my $total = MT::Comment->count( { entry_id => $entry_id, visible => 1 } );
1519
my @comments = MT::Comment->load( { entry_id => $entry_id, visible => 1 },
1520
{ limit => $limit, offset => $offset, direction => $direction } );
1521
my $ctx = MT::Template::Context->new;
1522
$ctx->stash( 'entry', $entry );
1523
$ctx->stash( 'entry_id', $entry->id );
1524
$ctx->stash( 'comments', \@comments );
1525
$ctx->var( 'commentTotal', $total );
1526
$ctx->var( 'commentLimit', $limit );
1527
$ctx->var( 'commentOffset', $offset );
1528
$ctx->var( 'commentDirection', $direction );
1529
$app->print( $tmpl->build($ctx) );
1477
1535
sub _commenter_status {
1478
1536
my $app = shift;