"; return; } # bad statusvis? unless ($remote->{statusvis} eq 'V') { $body = ""; return; } # get info about the community my $cuserid = $FORM{'cuserid'}+0; my $cu = $FORM{comm} ? LJ::load_user($FORM{comm}) : # they gave us the comm name LJ::load_userid($cuserid); # they gave us the comm id # NOTE: we wrapped this in an eval due to code going live; the library isn't going to go # live at the same time as the BML file, and we don't want weird things happening, so we # verify that this is all good and return an error if it's not okay. my $ci; eval { $ci = LJ::get_community_row($cu); }; if ($@) { $body = ""; return; } $cuserid = $ci->{'userid'}; LJ::text_out(\$ci->{'name'}); my $ecname = LJ::ehtml($ci->{'name'}); # does this community even exit? unless ($cu) { $body .= ""; return; } # make sure a community doesn't join a community (that's confusing # or something) unless ($remote->{'journaltype'} eq "P") { $body .= ""; return; } # ensure this user isn't banned if (LJ::is_banned($remote, $cuserid)) { $body .= ""; return; } # # and make sure they're not already a member # if (LJ::is_friend($cuserid, $remote->{userid})) { # $body .= ""; # return; # } # get the list of maintainers and their usernames my $dbr = LJ::get_db_reader(); my $admins = $dbr->selectcol_arrayref("SELECT u.user FROM useridmap u, reluser r ". "WHERE r.userid=$cuserid AND r.targetid=u.userid AND r.type='A'") || []; my $list = ""; # can't join closed communities # but if invited, go around and finally join my $invited=0; if ($ci->{membership} eq 'closed') { my $inv = LJ::get_sent_invites($cuserid) || []; foreach my $invite (@$inv) { my $id = $invite->{userid}; if (($invited!=1) && ($id == $remote->{'userid'})) {$invited=1;} } if($invited == 0){ $body .= " $list }) . " p?>"; return; } } # now do the join if ($POST{confirm}) { # can members join this community openly? # another case if user is already invited - then we will not make a request if (($ci->{membership} ne 'open') && ($invited == 0)) { # hit up the maintainers to let them know a join was requested LJ::comm_join_request($cu, $remote); $body .= ""; return; } # make remote user a friend of the community LJ::join_community($remote, $cu, $FORM{addfriend}); # success message $body .= " $ci->{user}, commname => $ecname}) . " p?>"; # if community permits it, tell the user they have access if ($ci->{postlevel} eq "members") { $body .= ""; } else { $body .= " $list }) . " p?>"; } } else { if (($ci->{membership} ne 'open') && ($invited == 0)) { $body .= " LJ::ljuser($cu) }) . "
p?>"; $body .= "
"; $body .= ""; $body .= ""; $body .= "
"; return; } $body .= " $ecname }); $body .= "
"; $body .= ""; $body .= "
"; $body .= ""; $body .= BML::ml('.label.addtofriends', { maintainer => $ecname }); $body .= "
p?>"; } return; _code?> body=> page?> link: htdocs/login.bml, htdocs/userinfo.bml post: htdocs/community/join.bml _c?>