body<=
";
}
return ""
unless $remote->{journaltype} eq 'P';
$ret .= "";
$ret .= "
";
my %show;
# what communities does remote
my $cids = LJ::load_rel_target($remote, 'A');
my %admin;
if ($cids) { foreach (@$cids) { $admin{$_} = $show{$_} = 1; } }
# keep track of what communities remote moderates
my $mods = LJ::load_rel_target($remote, 'M');
my %mods;
my %modcount;
if ($mods) { foreach (@$mods) { $mods{$_} = $show{$_} = 1; } }
my %names = ();
my %pending = ();
if (%show) {
my $in = join(',', keys %show);
my $us = LJ::load_userids(keys %show);
my $sth = $dbr->prepare("SELECT userid, membership FROM community ".
"WHERE userid IN ($in)");
$sth->execute;
my $udbr;
while (my ($uid, $membership) = $sth->fetchrow_array) {
my $cu = $us->{$uid};
next unless $cu && $cu->{statusvis} eq "V";
$names{$uid} = [ $cu->{user}, $cu->{name}, -1 ];
if ($mods{$uid}) {
$udbr = LJ::get_cluster_reader($cu);
my $sql = "SELECT COUNT(*) FROM modlog WHERE journalid=$uid";
$modcount{$uid} = $names{$uid}[2] = $udbr->selectrow_array($sql) || 0;
}
if ($membership eq 'moderated') {
my $ids = LJ::get_pending_members($uid) || [];
$pending{$uid} = scalar @$ids;
}
}
}
# deleted and expunged communities won't show up in this
if (%names) {
# Make up the first table row, linking to the other sort methods
my @snames;
$ret .= "
";
if (!defined $GET{'sortby'} || $GET{'sortby'} eq 'username') {
$ret .= "$ML{'.commlist.username'} | ";
@snames = sort { $names{$a}->[0] cmp $names{$b}->[0] } keys %names;
} else {
$ret .= " 'username'}) . "'>$ML{'.commlist.username'} | ";
}
if ($GET{'sortby'} eq 'title') {
$ret .= "$ML{'.commlist.title'} | ";
@snames = sort { $names{$a}->[1] cmp $names{$b}->[1] } keys %names;
} else {
$ret .= " 'title'}) . "'>$ML{'.commlist.title'} | ";
}
$ret .= "$ML{'.commlist.actions'} | ";
if ($GET{'sortby'} eq 'mod') {
$ret .= "$ML{'.commlist.moderation'} | ";
@snames = sort { $names{$b}->[2] <=> $names{$a}->[2] } keys %names;
} elsif (@$mods) {
$ret .= " 'mod'}) . "'>$ML{'.commlist.moderation'} | ";
}
foreach my $id (@snames) {
my $user = $names{$id}->[0];
my $name = $names{$id}->[1];
$ret .= "
| " . LJ::eall($name) . " | ";
if ($admin{$id}) {
$ret .= BML::ml('Actionlink', {
'link'=>"$ML{'.commlist.actinfo'}"}) . " ";
$ret .= BML::ml('Actionlink', {
'link'=>"$ML{'.commlist.actsettings2'}"}) . " ";
$ret .= BML::ml('Actionlink', {
'link'=>"$ML{'.commlist.actinvites'}"}) . " ";
my $pend = $pending{$id} ? BML::ml('.commlist.actpending', { num => $pending{$id},
aopts => "href=\"/community/pending.bml?comm=$user\"" }) : '';
$ret .= BML::ml('Actionlink', {
'link'=>"$ML{'.commlist.actmembers2'}$pend"}) . " ";
}
$ret .= " | ";
if ($mods{$id}) {
my $num = $modcount{$id} || "0"; # relying on this to be -wrapped
$ret .= BML::ml('.commlist.moderation.num', { num => $num,
link => "/community/moderate.bml?comm=$user" });
}
$ret .= " |
";
}
$ret .= "
";
} else {
$ret .= "$ML{'.commlist.none'}";
}
$ret .= "
";
# save any changes
if (LJ::did_post()) {
my $op = $POST{email};
$op = '' if $op && $op !~ /[N]/; # add D back in here when Digest goes live
LJ::set_userprop($remote, 'opt_communityjoinemail', $op);
my $mod_emails = $POST{modemail} ? 1 : 0;
LJ::set_userprop($remote, 'opt_nomodemail', $mod_emails ? undef : 1);
}
# load up our userprop
LJ::load_user_props($remote, 'opt_communityjoinemail', 'opt_nomodemail');
my $op = $remote->{opt_communityjoinemail};
$op ||= 'Y';
my $mod_emails = $remote->{opt_nomodemail} ? 0 : 1;
# form for setting email option
$ret .= "";
$ret .= "";
$ret .= "";
$ret .= "";
$ret .= "'/community/create.bml'}) . " p?>";
return $ret;
_code?>
<=body
page?>