1 _info?>"; return; }; my $bad_input = sub { return $error->("Bad input: $_[0]") if $jsmode; $body = LJ::bad_input($_[0]); return; }; LJ::set_active_crumb('delcomment'); my $remote = LJ::get_remote(); return $bad_input->($ML{'error.noremote'}) unless $remote; return $error->("Missing parameters.") unless $GET{'journal'} ne "" && $GET{'id'}; # $u is user object of journal that owns the talkpost my $u = LJ::load_user($GET{'journal'}); return $bad_input->($ML{'error.nojournal'}) unless $u; # can't delete if you're suspended return $bad_input->($ML{'.error.suspended'}) if $remote->{statusvis} eq 'S'; return $error->($LJ::MSG_READONLY_USER) if LJ::get_cap($u, "readonly"); my $dbcr = LJ::get_cluster_def_reader($u); return $error->($ML{'error.nodb'}) unless $dbcr; # $tp is a hashref of info about this individual talkpost row my $tpid = $GET{'id'} >> 8; my $tp = $dbcr->selectrow_hashref("SELECT jtalkid AS 'talkid', nodetype, state, " . "nodeid AS 'itemid', parenttalkid, journalid, posterid " . "FROM talk2 ". "WHERE journalid=? AND jtalkid=?", undef, $u->{'userid'}, $tpid); return $bad_input->($ML{'.error.nocomment'}) unless $tp; return $bad_input->($ML{'.error.invalidtype'}) unless $tp->{'nodetype'} eq 'L'; return $bad_input->($ML{'.error.alreadydeleted'}) if $tp->{'state'} eq "D"; # get username of poster $tp->{'userpost'} = LJ::get_username($tp->{'posterid'}); # userid of user who posted journal entry my $jposterid = $dbcr->selectrow_array("SELECT posterid FROM log2 WHERE " . "journalid=? AND jitemid=?", undef, $u->{'userid'}, $tp->{'itemid'}); my $jposter = LJ::load_userid($jposterid); # can $remote delete this comment? unless (LJ::Talk::can_delete($remote, $u, $jposter, $tp->{'userpost'})) { my $err = $u->{'journaltype'} eq 'C' ? $ML{'.error.cantdelete.comm'} : $ML{'.error.cantdelete'}; return $error->($err); } my $can_manage = LJ::can_manage($remote, $u); # can ban if can manage and the comment is by someone else and not anon my $can_ban = $can_manage && $tp->{'posterid'} && $remote && $remote->{'userid'} != $tp->{'posterid'}; my $can_delthread = $can_manage || $jposterid == $remote->{userid}; ### perform actions if (LJ::did_post() && $POST{'confirm'}) { # mark this as spam? LJ::Talk::mark_comment_as_spam($u, $tp->{talkid}) if $POST{spam}; # delete entire thread? or just the one comment? if ($POST{delthread} && $can_delthread) { # delete entire thread ... LJ::Talk::delete_thread($u, $tp->{'itemid'}, $tpid); } else { # delete single comment... LJ::Talk::delete_comments($u, "L", $tp->{'itemid'}, [$tpid]); } # ban the user, if selected my $msg; if ($POST{'ban'} && $can_ban) { LJ::set_rel($u->{'userid'}, $tp->{'posterid'}, 'B'); $msg = BML::ml('.success.andban', { 'user' => LJ::ljuser($tp->{'userpost'}) }); } $msg ||= $ML{'.success.noban'}; $msg .= "" if $POST{spam}; if ($jsmode) { BML::finish(); return "1;"; } else { $body = ""; return; } } ### show confirmation form $body .= ""; $body .= ""; $body .= "
\n"; return; } _code?> body=> page?> link: htdocs/editinfo.bml post: htdocs/delcomment.bml _c?>