Committer: slobin
LJM-1855: I can't comment on the postM htdocs/talkpost_do.bml
M cgi-bin/LJ/Talk.pm
U trunk/cgi-bin/LJ/Talk.pm U trunk/htdocs/talkpost_do.bml
Modified: trunk/cgi-bin/LJ/Talk.pm =================================================================== --- trunk/cgi-bin/LJ/Talk.pm 2011-07-12 06:57:34 UTC (rev 19465) +++ trunk/cgi-bin/LJ/Talk.pm 2011-07-12 07:10:16 UTC (rev 19466) @@ -1646,11 +1646,13 @@ return "You cannot edit this comment." if $editid && !$is_person; + my $filename = $opts->{embedable_form} + ? "$ENV{'LJHOME'}/templates/CommentForm/FormEmbedable.tmpl" + : "$ENV{'LJHOME'}/templates/CommentForm/Form.tmpl"; + my $template = LJ::HTML::Template->new( { use_expr => 1 }, # force HTML::Template::Pro with Expr support - filename => $opts->{embedable_form} - ? "$ENV{'LJHOME'}/templates/CommentForm/FormEmbedable.tmpl" - : "$ENV{'LJHOME'}/templates/CommentForm/Form.tmpl", + filename => $filename, die_on_bad_params => 0, strict => 0, ) @@ -2044,6 +2046,33 @@ return $template->output; } +# mobile commenting form +sub talkform_mobile { + my $opts = shift; + + my @opts = ( + 'read','user',$opts->{form}{journal}, $opts->{form}{itemid}, 'comments', + ); + + push @opts, $opts->{form}{thread} + if $opts->{form}{thread}; + + push @opts, 'reply'; + + # run controller + my $controller = LJ::Mob::Controller::ReadPost->new; + $controller->_user(LJ::get_remote()); + my $res = $controller->reply(\@opts); + + # passing error messages + $res->template->param( + errors => [map { { 'error' => $_ } } @{ $opts->{errors} }], + ); + + # and get ready html code + return $res->output_html; +} + # <LJFUNC> # name: LJ::record_anon_comment_ip # class: web Modified: trunk/htdocs/talkpost_do.bml =================================================================== --- trunk/htdocs/talkpost_do.bml 2011-07-12 06:57:34 UTC (rev 19465) +++ trunk/htdocs/talkpost_do.bml 2011-07-12 07:10:16 UTC (rev 19466) @@ -126,7 +126,6 @@ 'domain=' . LJ::eurl( $POST{'partner_domain'} ) . '&' . 'replyto=' . $replyto; } - # special case here (LJINT-408), only applies to the partners case: # # if the user got logged out after they opened the form, disabling them @@ -140,8 +139,8 @@ ## init. this handles all the error-checking, as well. my $need_captcha = 0; my $init = LJ::Talk::Post::init(\%POST, $remote, \$need_captcha, \@errors); + return if LJ::Request->redirected; - # Report errors in a friendly manner by regenerating the field. # Required for challenge/response login, since we also need to regenerate an auth token. # We repopulate what we can via hidden fields - however the objects (journalu & parpost) must be recreated here. @@ -153,7 +152,6 @@ if ($init && ! $POST{agree_tos} && $commentu && ! $commentu->tosagree_verify) { $require_tos = 1; } - if (! $init || $require_tos) { my ($sth, $parpost); my $dbcr = LJ::get_cluster_def_reader($journalu); @@ -207,10 +205,13 @@ $talkform_opts->{'resources_html'} = $partner->resources_html({only_needed => 1}); $talkform_opts->{'partner_domain'} = $POST{'partner_domain'}; } + + # show mobile form + return LJ::Talk::talkform_mobile($talkform_opts) + if $POST{'mobile_domain'} =~ qr/^\w\.$LJ::DOMAIN$/; return LJ::Talk::talkform($talkform_opts); } - # checked $POST{agree_tos} was checked above if it was necessary, # now we just need to save the userprop if ($commentu && ! $commentu->tosagree_verify && $POST{agree_tos}) { @@ -219,7 +220,6 @@ unless $commentu->tosagree_set(\$err); } - my $talkurl = $init->{talkurl}; my $entryu = $init->{entryu};