body<= {'head'}; my $bodyopts = \$_[1]->{'bodyopts'}; LJ::set_active_crumb('editentries'); my $remote = LJ::get_remote(); return LJ::bad_input($ML{'error.noremote'}) unless $remote; if ($remote->underage) { return BML::redirect("$LJ::SITEROOT/agecheck/?s=1"); } my $mode = $GET{'mode'} || $POST{'mode'} || "init"; if ($GET{'itemid'} || $POST{'itemid'}) { $mode = "edit"; } my $ret; my $getextra = "?authas=$GET{'authas'}" if $GET{'authas'}; # are they asking to be authed as someone else? my $authas = $GET{'authas'} || $remote->{'user'}; my $u = LJ::get_authas_user($authas); return LJ::bad_input("You could not be authenticated as the specified user.") unless $u; return LJ::bad_input("You must be authenticated as a person.") unless $u->{'journaltype'} eq 'P'; if ($mode eq "edit") { # are we modify a community post? my $usejournal = $GET{'usejournal'} || $POST{'usejournal'} || $GET{'journal'}; undef $usejournal if $usejournal eq $u->{'user'}; # ignore if it's the user # user object for community if we're modifying one my $usejournal_u; if ($usejournal) { $usejournal_u = LJ::load_user($usejournal); return LJ::bad_input("The community you selected does not exist.") unless $usejournal_u; } # extra get arguments my $getextra; $getextra .= "authas=$authas&" if $authas ne $u->{'user'}; $getextra .= "usejournal=$usejournal&" if $usejournal; chop $getextra; $getextra = "?$getextra" if $getextra; ### ### HAVE AN ITEMID TO EDIT ### if ($GET{'itemid'} || $POST{'itemid'}) { # the 'itemid' form element is really an 'itemid' my $ditemid = $GET{'itemid'} || $POST{'itemid'}; my $anum = $ditemid % 256; my $itemid = $ditemid >> 8; # do getevents request my %res = (); LJ::do_request({ 'mode' => 'getevents', 'selecttype' => 'one', 'ver' => $LJ::PROTOCOL_VER, 'user' => $u->{'user'}, 'usejournal' => $usejournal, 'itemid' => $itemid }, \%res, { "noauth" => 1, 'u' => $u } ); # was there a protocol error? return "" unless $res{'success'} eq 'OK'; # does the requested entry exist? return "" unless $res{'events_count'} && $res{'events_1_anum'} == $anum; # are we authorized to edit other peoples' posts in this community? my $disabled_save = 0; my $disabled_delete = 0; my $disabled_spamdelete = 0; if ($usejournal && $res{'events_1_poster'} ne $u->{'user'}) { $disabled_delete = ! LJ::can_delete_journal_item($u, $usejournal_u); $disabled_save++; } $disabled_spamdelete = $disabled_delete || !$usejournal || ($res{'events_1_poster'} eq $u->{'user'}); ### ### SAVE EDITS ### # are we spellchecking before we post? my $spellcheck_html; my $did_spellcheck; if ($LJ::SPELLER && $POST{'action:spellcheck'}) { $did_spellcheck++; my $s = new LJ::SpellCheck { 'spellcommand' => $LJ::SPELLER, 'color' => '', }; my $event = LJ::ehtml($POST{'event'}); $spellcheck_html = $s->check_html(\$event); $spellcheck_html = "" unless $spellcheck_html ne ""; } # they clicked the save or delete button if (!$spellcheck_html && ($POST{'action:save'} || $POST{'action:delete'} || $POST{'action:deletespam'})) { return LJ::bad_input($ML{'error.invalidform'}) unless LJ::check_form_auth(); my %req = ( 'mode' => 'editevent', 'ver' => $LJ::PROTOCOL_VER, 'user' => $u->{'user'}, 'usejournal' => $usejournal, 'itemid' => $itemid, ); LJ::entry_form_decode(\%req, \%POST); # Delete $req{'event'} = '' if $POST{'action:delete'} || $POST{'action:deletespam'}; # mark as spam, if need be LJ::mark_entry_as_spam($usejournal_u, $itemid) if $POST{'action:deletespam'}; # if the action is to delete it, then let's note that if ($POST{'action:delete'} || $POST{'action:deletespam'}) { # now log the event created above ($usejournal ? $usejournal_u : $u)->log_event('delete_entry', { remote => $remote, actiontarget => $ditemid, method => 'web', }); } # do editevent request LJ::do_request(\%req, \%res, { 'noauth' => 1, 'u' => $u }); # check response unless ($res{'success'} eq "OK") { return "
"; $ret .= ""; $ret .= " | ";
$ret .= " ";
$ret .= " (Posted by: " . LJ::ljuser($res{"events_${i}_poster"}) . ")" if $usejournal;
### security indicator
my $sec = ' ';
if ($res{"events_${i}_security"} eq "private") {
$sec .= BML::fill_template("securityprivate");
} elsif ($res{"events_${i}_security"} eq "usemask") {
$sec .= BML::fill_template("securityprotected");
}
$ret .= $sec;
if (my $subj = $res{"events_${i}_subject"}) {
LJ::CleanHTML::clean_subject_all(\$subj);
$ret .= " " . LJ::ehtml($subj) . "";
}
$ret .= " \n"; my $event = LJ::ehtml(LJ::durl($res{"events_${i}_event"})); $event =~ s!\n! !g; $ret .= $event; $ret .= " |