body<= "; return $ret; } my $mode = $POST{'mode'}; my ($saved_comm, $saved_modid) = ("", 0); if (LJ::did_post() && ($mode eq 'approve_do' || $mode eq 'reject_do')) { my $cid = $POST{'cid'}+0; my $modid = $POST{'modid'}+0; my $c = LJ::load_userid($cid); unless ($c) { $ret .= ""; return $ret; } my $dbcm = LJ::get_cluster_master($c); unless (LJ::check_rel($c, $remote, 'M')) { $ret .= ""{'user'} ljcomm?>"}) . " p?>"; return $ret; } # use dbcm to read to minimize collisions between moderators due to replication lag my $entry = $dbcm->selectrow_hashref("SELECT * FROM modlog WHERE journalid=? AND modid=?", undef, $c->{'userid'}, $modid); my $frozen = $dbcm->selectrow_array("SELECT request_stor FROM modblob WHERE journalid=? AND modid=?", undef, $c->{'userid'}, $modid); my $req = Storable::thaw($frozen) if $frozen; unless ($frozen && $entry && $req->{'_moderate'}->{'authcode'} && $req->{'_moderate'}->{'authcode'} eq $POST{'auth'}) { $ret .= ""; return $ret; } my $poster = LJ::load_userid($entry->{'posterid'}); my ($success, $do_mail) = (0, 0); my $why_mail; my $prot_err; my $posturl; if ($mode eq 'approve_do') { my $res = LJ::Protocol::do_request('postevent', $req, \$prot_err, {'nomod'=>1, 'noauth'=>1}); if ($res) { # succeeded $success = 1; $ret .= ""; # does the poster want to know? if they have working email and notification on ($do_mail, $why_mail) = (1, 'success') if ($poster->{'opt_gettalkemail'} eq "Y" && $poster->{'status'} eq "A"); $posturl = LJ::item_link($c, $res->{'itemid'}, $res->{'anum'}) . "\n\n"; } else { $prot_err = LJ::Protocol::error_message($prot_err) if $prot_err; $ret .= ""$prot_err"}) . " p?>"; ($do_mail, $why_mail) = (1, 'proterror') if $poster->{'status'} eq "A"; } if ($POST{'preapprove'}) { LJ::set_rel($c, $poster, 'N'); $ret .= ""{'user'} ljuser?>"}) . " p?>"; } } if ($mode eq 'reject_do') { $success = 1; $ret .= ""; ($do_mail, $why_mail) = (1, 'reject') if $poster->{'status'} eq 'A'; } $do_mail = 1 unless $poster->{'statusvis'} eq 'V'; # mail the poster if ($do_mail) { my $subject="Moderated submission notification"; my $to = $poster->{'email'}; my $body = "Your message submitted to the moderated community $c->{'user'} "; if ($why_mail eq 'success') { $body .= "has been approved and successfully posted.\n\n$posturl"; } elsif ($why_mail eq 'proterror') { $body .= "has been approved, but failed to be posted due to the following protocol error:\n$prot_err\n\n"; } elsif ($why_mail eq 'reject') { $body .= "has been rejected by a moderator of that community.\n\nPlease note that replies to this email are not sent to the community's moderator(s). If you would like to discuss the reasons for your entry's rejection, you will need to contact a moderator directly.\n\n"; } if ($why_mail eq 'reject' && $POST{'why'}) { $body .= "Here are the reasons for the rejection as provided by the moderator: \n\n" . $POST{'why'} . "\n\n"; } unless ($why_mail eq 'success') { $body .= "This is the message you submitted:\n\n"; my $etime = sprintf("%04d-%02d-%02d %02d:%02d", $req->{'year'}, $req->{'mon'}, $req->{'day'}, $req->{'hour'}, $req->{'min'}); $body .= "Time: $etime\n"; $body .= "Subject: " . $req->{'subject'} . "\n"; if ($req->{'props'}->{'current_music'}) { $body .= "Current Music: " . $req->{'props'}->{'current_music'} . "\n"; } if ($req->{'props'}->{'current_mood'}) { $body .= "Current Mood: " . $req->{'props'}->{'current_mood'} . "\n"; } if ($req->{'props'}->{'picture_keyword'}) { $body .= "Picture Keyword: " . $req->{'props'}->{'picture_keyword'} . "\n"; } $body .= "Text:\n" . $req->{'event'} . "\n\n"; $body .= "Regards,\n$LJ::SITENAME Team\n\n$LJ::SITEROOT/\n"; } LJ::send_mail({ 'to' => $to, 'from' => $LJ::BOGUS_EMAIL, 'charset' => 'utf-8', 'subject' => $subject, 'body' => $body, }); } if ($success) { $saved_comm = $c->{'user'}; $saved_modid = 0; # Delete this moderated entry from the list $c->do("DELETE FROM modlog WHERE journalid=? AND modid=?", undef, $c->{'userid'}, $modid); $c->do("DELETE FROM modblob WHERE journalid=? AND modid=?", undef, $c->{'userid'}, $modid); # FALL THROUGH to showing the list of entries in this community } else { $ret .= "

"; $ret .= BML::ml('Backlink', { 'link'=>'/community/manage.bml', 'text'=>$ML{'.manage'}, }) . "
"; $ret .= BML::ml('Backlink', { 'link'=>"/community/moderate.bml?comm=$c->{'user'}", 'text'=>$ML{'.moderate'}, }) . "
"; $ret .= "

"; return $ret; } } my $comm = $saved_comm || ($mode eq 'action' ? $POST{'comm'} : $GET{'comm'}); my $modid = $saved_modid || ($mode eq 'action' ? $POST{'modid'} : $GET{'modid'}); $modid += 0; # redirect to community/manage if a GET request with no arg return BML::redirect("manage.bml") unless $comm; my $c = LJ::load_user($comm); unless ($c) { $ret .= ""; return $ret; } my $dbcr = LJ::get_cluster_def_reader($c); unless (LJ::check_rel($c, $remote, 'M')) { $ret .= """}) . " p?>"; return $ret; } if ($mode eq 'action' && $POST{'action:approve'}) { my ($posterid, $frreq); if ($modid) { ($posterid, $frreq) = $dbcr->selectrow_array ("SELECT l.posterid, b.request_stor FROM modlog l, modblob b " . "WHERE l.journalid=? AND l.modid=? AND l.journalid=b.journalid AND l.modid=b.modid", undef, $c->{'userid'}, $modid); } unless ($posterid) { $ret .= ""; return $ret; } my $req = Storable::thaw($frreq); my $poster = LJ::load_userid($posterid); $ret .= ""; $ret .= "

"; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= "{'authcode'} . "'>"; $ret .= ""; $ret .= "
"; $ret .= "

" . BML::ml('.approve.preapprove', {'user'=>"{'user'} ljuser?>"}); $ret .= "

"; return $ret; } if ($mode eq 'action' && $POST{'action:reject'}) { my ($posterid, $frreq); if ($modid) { ($posterid, $frreq) = $dbcr->selectrow_array ("SELECT l.posterid, b.request_stor FROM modlog l, modblob b " . "WHERE l.journalid=? AND l.modid=? AND l.journalid=b.journalid AND l.modid=b.modid", undef, $c->{'userid'}, $modid); } unless ($posterid) { $ret .= ""; return $ret; } my $req = Storable::thaw($frreq); my $poster = LJ::load_userid($posterid); $ret .= ""; $ret .= "

"; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= "{'authcode'} . "'>"; $ret .= ""; $ret .= "
"; if ($poster->{'status'} eq 'A') { $ret .= ""; $ret .= " p?>"; } $ret .= "
"; return $ret; } # browse either the list of entries or an entry unless ($modid) { # present a list of entries $ret .= """}) . " p?>"; $ret .= "
"; my @entries; my $sth = $dbcr->prepare("SELECT * FROM modlog WHERE journalid=$c->{'userid'}"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { push @entries, $_; } unless (@entries) { $ret .= "$ML{'.browse.empty'}"; } else { $ret .= "" . "" . ""; my %users; LJ::load_userids_multiple([ map { $_->{'posterid'}, \$users{$_->{'posterid'}} } @entries ]); foreach (sort { $a->{'logtime'} lt $b->{'logtime'} } @entries) { my $link = "/community/moderate.bml?comm=$comm&modid=" . $_->{'modid'}; my $subject = $_->{'subject'} ? LJ::eall($_->{'subject'}) : "[No Subject]"; $ret .= "" . "" . "" . ""; } $ret .= "
$ML{'.brlist.time'}$ML{'.brlist.poster'}$ML{'.brlist.subject'}$ML{'.brlist.actions'}
$_->{'logtime'}{'posterid'}}->{'user'} . " ljuser?>$subject" . BML::ml('Actionlink', { 'link'=>"$ML{'.brlist.view'}" }) . "
"; } $ret .= "
"; $ret .= BML::ml('Backlink', { 'link'=>'/community/manage.bml', 'text'=>$ML{'.manage'}, }) . "
"; } else { # view an entry my $frozen = $dbcr->selectrow_array("SELECT request_stor FROM modblob WHERE journalid=? AND modid=?", undef, $c->{'userid'}, $modid); unless ($frozen) { $ret .= ""; return $ret; } my $req = Storable::thaw($frozen); # cleaning my $event = $req->{'event'}; $event =~ s/^\s+//; $event =~ s/\s+$//; if ($req->{'lineendings'} eq "mac") { $event =~ s/\r/\n/g; } else { $event =~ s/\r//g; } my $etime = sprintf("%04d-%02d-%02d %02d:%02d", $req->{'year'}, $req->{'mon'}, $req->{'day'}, $req->{'hour'}, $req->{'min'}); my $subject = $req->{'subject'}; my $props = $req->{'props'}; my $up = LJ::load_user($req->{'username'}); my $posterid = $up->{'userid'}; my $error; my @polls = LJ::Poll::parse(\$event, \$error, { 'journalid' => $c->{'userid'}, 'posterid' => $posterid, }); $event =~ s//LJ::Poll::preview(shift @polls);/eg; LJ::CleanHTML::clean_event(\$event, {'preformatted' => $req->{'props'}->{'opt_preformatted'}, 'cutpreview' => 1, 'cuturl' => '#', }); BML::ebml(\$event); $ret .= "

"; $ret .= BML::ml('Backlink', { 'link'=>'/community/manage.bml', 'text'=>$ML{'.manage'}, }) . "
"; $ret .= BML::ml('Backlink', { 'link'=>"/community/moderate.bml?comm=$comm", 'text'=>$ML{'.moderate'}, }) . "
"; $ret .= "

"; $ret .= "

"; $ret .= ""; my $picid = LJ::get_picid_from_keyword($up, $props->{'picture_keyword'}); my %userpics; if ($picid) { LJ::load_userpics(\%userpics, [ $up, $picid ]); my $alt = $up->{'name'}; if ($props->{'picture_keyword'}) { $alt .= ": $props->{'picture_keyword'}"; } $alt = LJ::ehtml($alt); $ret .= ""; } $ret .= "
"; $ret .= BML::ml("talk.somebodywrote_comm", { 'realname' => BML::eall($up->{'name'}), 'userlink' => LJ::ljuser($up->{'user'}), 'commlink' => "{'user'} ljcomm?>" }); $etime =~ s!(\d\d\d\d)-(\d\d)-(\d\d)!LJ::date_to_view_links($c, $&)!e; $ret .= "
@ $etime"; $ret .= "
"; my $actions .= ""; $actions .= ""; $actions .= ""; $actions .= ""; $actions .= "  "; $ret .= "

"; $ret .= BML::fill_template("standout", {'DATA'=> $actions}); $ret .= "
"; my %current; if ($props->{'current_mood'} || $props->{'current_moodid'}) { $current{'Mood'} = $props->{'current_mood'}; LJ::CleanHTML::clean_subject(\$current{'Mood'}); my $mid = $props->{'current_moodid'}; if ($mid) { my $theme = $up->{'moodthemeid'}; my %pic; my $name = LJ::mood_name($mid); if (LJ::get_mood_picture($theme, $mid, \%pic)) { $current{'Mood'} = " $name"; } else { $current{'Mood'} = $name; } } } if ($props->{'current_music'}) { $current{'Music'} = $props->{'current_music'}; LJ::CleanHTML::clean_subject(\$current{'Music'}); } $ret .= "
"; if (%current) { $ret .= "\n"; foreach (sort keys %current) { my $curkey = "talk.curname_" . $_; my $curname = BML::ml($curkey); $curname = "Current $_:" unless $curname; $ret .= "\n"; } $ret .= "
$curname$current{$_}

\n"; } ### security indicator my $sec = ""; if ($req->{'security'} eq "private") { $sec = ""; } elsif ($req->{'security'} eq "usemask") { $sec = ""; } $sec .= "
\n" unless $sec eq "" or $subject; $ret .= $sec; if ($subject) { LJ::CleanHTML::clean_subject(\$subject); BML::ebml(\$subject); $ret .= "$subject
\n"; } $ret .= $event; $ret .= "

"; $ret .= "

"; } return $ret; } _code?> <=body page?>