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 .= $navbar; } # setup showlinks my $showlinks = ""; my $filter = "&show=$GET{show}" if $GET{show}; my $sortlink = BML::get_uri() . "?comm=$cname$filter&sort="; $ret .= "$ML{'/community/members.bml.key.user'} | "; $ret .= "$_ | " foreach @titleattribs; $ret .= "$ML{'.key.sentby'} | "; $ret .= "$ML{'.key.date'} | "; $ret .= "$ML{'.key.status'} | "; $ret .= "
---|---|---|---|---|
" . LJ::ljuser($_->{user}) . " | "; foreach my $key (@attribs) { $ret .= ""; $ret .= $_->{$key} ? $yes : $no; $ret .= " | "; } $ret .= "" . LJ::ljuser($_->{maintainer}, { type => 'P' }) . " | "; $ret .= "$_->{date} | "; $ret .= "$_->{status} | "; $ret .= "