~ubuntu-branches/debian/squeeze/movabletype-opensource/squeeze

« back to all changes in this revision

Viewing changes to lib/MT/CMS/Comment.pm

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves
  • Date: 2008-07-23 22:56:37 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080723225637-zsorczl9nhy0t8ap
Tags: 4.2~rc4-1
* New upstream release
* Include SendMailPath explicitly as in some cases it seems
  to be required (closes: #491618)
* Add versioned Depends on libclass-trigger-perl (>= 0.13-1)
  as the version in etch is not compatible with MT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1214
1214
 
1215
1215
sub do_reply {
1216
1216
    my $app = shift;
 
1217
 
 
1218
    # Save requires POST
 
1219
    return $app->error( $app->translate("Invalid request") )
 
1220
      if $app->request_method() ne 'POST';
 
1221
 
1217
1222
    my $q   = $app->param;
1218
1223
 
1219
1224
    my $param = {
1223
1228
    };
1224
1229
 
1225
1230
    my ( $comment, $parent, $entry ) = _prepare_reply($app);
1226
 
 
1227
 
    $param->{commenter_name} = $parent->author;
 
1231
    return unless $comment;
 
1232
 
 
1233
    my $blog = $parent->blog
 
1234
            || $app->model('blog')->load($q->param('blog_id'));
 
1235
    return $app->error($app->translate('Can\'t load blog #[_1].', $q->param('blog_id'))) unless $blog;
 
1236
 
 
1237
    require MT::Sanitize;
 
1238
    my $spec = $blog->sanitize_spec
 
1239
            || $app->config->GlobalSanitizeSpec;
 
1240
    $param->{commenter_name} = MT::Sanitize->sanitize($parent->author, $spec);
1228
1241
    $param->{entry_title}    = $entry->title;
1229
1242
    $param->{comment_created_on} =
1230
1243
      format_ts( "%Y-%m-%d %H:%M:%S", $parent->created_on, undef, $app->user ? $app->user->preferred_language : undef );
1254
1267
 
1255
1268
sub reply_preview {
1256
1269
    my $app = shift;
 
1270
 
 
1271
    # Preview requires POST
 
1272
    return $app->error( $app->translate("Invalid request") )
 
1273
      if $app->request_method() ne 'POST';
 
1274
 
 
1275
    $app->validate_magic or return;
 
1276
 
1257
1277
    my $q   = $app->param;
1258
1278
    my $cfg = $app->config;
1259
1279
 
1260
1280
    my $param = {
1261
1281
        reply_to    => $q->param('reply_to'),
1262
 
        magic_token => $q->param('magic_token'),
 
1282
        magic_token => $app->current_magic,
1263
1283
        blog_id     => $q->param('blog_id'),
1264
1284
    };
1265
1285
    my ( $comment, $parent, $entry ) = _prepare_reply($app);
 
1286
    return unless $comment;
1266
1287
 
1267
1288
    my $blog = $parent->blog
1268
1289
            || $app->model('blog')->load($q->param('blog_id'));
1289
1310
    $comment->commenter_id( $app->user->id );
1290
1311
    $param->{'comment'} = $comment;
1291
1312
 
1292
 
    require MT::Serialize;
1293
 
    my $ser   = MT::Serialize->new( $cfg->Serializer );
1294
 
    my $state = $comment->column_values;
1295
 
    $state->{static} = $q->param('static');
1296
 
    $param->{'comment_state'} = unpack 'H*', $ser->serialize( \$state );
1297
 
    $param->{'comment_is_static'} = 1;
1298
 
    $param->{'entry'} = $entry;
1299
 
    $param->{'current_timestamp'} = $ts;
1300
 
    $param->{'commenter'} = $app->user;
1301
 
    $param->{'blog_id'} = $parent->blog_id;
1302
 
    $param->{'blog'} = $parent->blog;
 
1313
    my $tmpl = $app->load_tmpl('include/comment_detail.tmpl');
 
1314
    my $ctx  = $tmpl->context;
 
1315
    $ctx->stash( 'comment', $comment );
 
1316
    $ctx->stash( 'entry',   $entry );
 
1317
    $ctx->stash( 'blog',    $parent->blog );
 
1318
    $param->{'preview_html'} = $tmpl->output;
1303
1319
 
1304
1320
    return $app->build_page( 'dialog/comment_reply.tmpl',
1305
1321
        { %$param, text => $q->param('text') } );
1766
1782
    $comment->commenter_id( $app->user->id );
1767
1783
    $comment->blog_id( $entry->blog_id );
1768
1784
    $comment->entry_id( $entry->id );
 
1785
    $comment->parent_id( $parent->id );
1769
1786
    $comment->author( remove_html($nick) );
1770
1787
    $comment->email( remove_html( $app->user->email ) );
1771
1788
    $comment->text($text);