body<= '/community/manage.bml', 'text' => $ML{'/community/members.bml.manage2'}, }); # get remote my $remote = LJ::get_remote(); unless ($remote) { $ret .= ""; return $ret; } my $cname = $GET{comm}; return BML::redirect("$LJ::SITEROOT/community/manage.bml") unless $cname; # get $c object my $c = LJ::load_user($cname); unless ($c) { $ret .= ""; return $ret; } my $cid = $c->{'userid'}; # is $remote an admin? unless (LJ::can_manage_other($remote, $c)) { $ret .= " LJ::ljuser($cname, { 'type' => 'C' }) }); $ret .= " p?>"; return $ret; } # columns of our table, excluding username my @attribs = ('post'); my @titleattribs = ('P'); LJ::load_user_props($c, 'moderated'); if ($c->{moderated}) { push @attribs, ('preapprove', 'moderate'); push @titleattribs, ('U', 'M'); } push @attribs, 'admin'; push @titleattribs, 'A'; # now get sent invites and the users involved my $sent = LJ::get_sent_invites($c) || []; my @ids; push @ids, ($_->{userid}, $_->{maintid}) foreach @$sent; my $us = LJ::load_userids(@ids); # populate %users hash my %users = (); foreach my $invite (@$sent) { my $id = $invite->{userid}; next if $GET{show} && $GET{show} ne 'all' && $invite->{status} ne $GET{show}; $users{$id}{userid} = $id; $users{$id}{maintainer} = $us->{$invite->{maintid}}{user}; $users{$id}{user} = $us->{$id}{user}; $users{$id}{$_} = 1 foreach keys %{$invite->{args}}; $users{$id}{status} = $invite->{status}; $users{$id}{date} = LJ::mysql_time($invite->{recvtime}); $users{$id}{date} =~ s/\s.+$//; # we just want the date, ignore time } # hop out if there were no invites unless (%users) { return "$ret "href='/community/members.bml?comm=$c->{user}'" }) . " p?>"; } # sorting method; my $method = $GET{'sort'}; my $cmp = sub {$a->{'user'} cmp $b->{'user'}}; $cmp = sub {$b->{'admin'} <=> $a->{'admin'}} if $method eq 'A'; $cmp = sub {$b->{'post'} <=> $a->{'post'}} if $method eq 'P'; $cmp = sub {$b->{'moderate'} <=> $a->{'moderate'}} if $method eq 'M'; $cmp = sub {$b->{'preapprove'} <=> $a->{'preapprove'}} if $method eq 'U'; $cmp = sub {$a->{'status'} cmp $b->{'status'}} if $method eq 'status'; $cmp = sub {$b->{'date'} cmp $a->{'date'}} if $method eq 'date'; $cmp = sub {$b->{'maintainer'} cmp $a->{'maintainer'}} if $method eq 'maint'; my @users = sort $cmp values %users; my $page_size = 100; # change to adjust page size # are we going to jump to a specific user ? my $jumppage; my $jumpuser; if (@users > $page_size && $POST{'jumpto'} =~ /^\w+$/) { my $ct; foreach (@users) { $jumppage++ if $ct % $page_size == 0; if ($POST{'jumpto'} eq $_->{'name'}) { $jumpuser = $_->{'name'}; last; } $ct++; } undef $jumppage unless $jumpuser; } # how to make links back to this page my $self_link = sub { my $sort = "&sort=$GET{'sort'}" if $GET{'sort'}; my $filter = "&show=$GET{'show'}" if $GET{'show'}; return "sentinvites.bml?comm=$cname&page=$_[0]$sort$filter"; }; my %items = BML::paging(\@users, $jumppage || $GET{'page'}, $page_size); my $navbar = LJ::paging_bar($items{'page'}, $items{'pages'}, { 'self_link' => $self_link }); @users = @{$items{'items'}}; # output starts here $ret .= " LJ::ljuser($cname, { 'type' => 'C' }) }); $ret .= " " . BML::ml('/community/members.bml.settings', { 'link' => "settings.bml?comm=$cname"}) . " p?>"; # jump to user if ($items{'pages'} > 1) { $ret .= "
"; $ret .= "
Jump to user: "; $ret .= LJ::html_text({ 'name' => 'jumpto', 'value' => $POST{'jumpto'}, 'size' => '10', 'maxlength' => '15' }) . " "; $ret .= LJ::html_submit(undef, 'Go') . "
"; $ret .= "
"; $ret .= $navbar; } # setup showlinks my $showlinks = "
"; $showlinks .= LJ::html_hidden('comm', $c->{user}); $showlinks .= "Filter to: "; $showlinks .= LJ::html_select({ name => 'show', selected => $GET{show} }, map { $_, $_ } qw(all accepted outstanding rejected)); $showlinks .= LJ::html_submit(undef, 'Refresh'); $showlinks .= "
"; my $filter = "&show=$GET{show}" if $GET{show}; my $sortlink = BML::get_uri() . "?comm=$cname$filter&sort="; $ret .= "
$showlinks"; $ret .= < P Posting Access U Unmoderated M Moderator A Maintainer
END $ret .= "\n" . ""; $ret .= "" foreach @titleattribs; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= "\n"; # checkboxes and such my $yes = ''; my $no = '-'; # rows for existing users my $rc = 0; foreach(@users) { my $rstyle = ($rc++ & 1) ? "" : ""; $ret .= ""; foreach my $key (@attribs) { $ret .= ""; } $ret .= ""; $ret .= ""; $ret .= ""; $ret .= "\n"; } $ret .= "
$ML{'/community/members.bml.key.user'}$_$ML{'.key.sentby'}$ML{'.key.date'}$ML{'.key.status'}
" . LJ::ljuser($_->{user}) . ""; $ret .= $_->{$key} ? $yes : $no; $ret .= "" . LJ::ljuser($_->{maintainer}, { type => 'P' }) . "$_->{date}$_->{status}
\n"; $ret .= "
$ML{'.send'}"; $ret .= "
\n\n"; $ret .= $navbar; return $ret; } _code?> <=body page?>