1 _info?> body<= {'used'} eq 'Y'; my $arg = {}; LJ::decode_url_string($aa->{'arg1'}, $arg); ### perform actions according to the action type # invite users to communities if ($aa->{'action'} eq 'comm_invite') { my $dbh = LJ::get_db_writer(); my $targetid = $arg->{'targetid'}; return LJ::bad_input($ML{'.error.internerr.invalidaction'}) unless $targetid; # add to community if ($arg->{'member'}) { LJ::add_friend($aa->{userid}, $targetid); } # set up rels with this community my @rels = (); push @rels, 'A' if $arg->{'admin'}; push @rels, 'P' if $arg->{'post'}; push @rels, 'M' if $arg->{'moderate'}; push @rels, 'N' if $arg->{'preapprove'}; if (@rels) { LJ::set_rel_multi( map { [$aa->{userid}, $targetid, $_] } @rels ); } # mark this authaction as used $dbh->do("UPDATE authactions SET used='Y' WHERE aaid=?", undef, $aa->{'aaid'}); # return success my $username = LJ::get_username($aa->{'userid'}); return "". 'LJ::ljuser($username, { 'type' => 'C' }), 'aopts'=>'href="'.$LJ::SITEROOT.'/friends/add.bml?user='.$username.'"'}). ' p?>'; } # invite users to shared journals if ($aa->{'action'} eq 'shared_invite') { my $dbh = LJ::get_db_writer(); my $targetid = $arg->{'targetid'}; return LJ::bad_input($ML{'.error.internerr.invalidaction'}) unless $targetid; LJ::set_rel($aa->{'userid'}, $targetid, 'P'); # mark this authaction as used $dbh->do("UPDATE authactions SET used='Y' WHERE aaid=?", undef, $aa->{'aaid'}); my $username = LJ::get_username($aa->{'userid'}); return "". 'LJ::ljuser($username, { 'type' => 'S' }), 'aopts'=>'href="'.$LJ::SITEROOT.'/friends/add.bml?user='.$username.'"'}). ' p?>'; } # approve someone joining a community if ($aa->{action} eq 'comm_join_request') { my $dbh = LJ::get_db_writer(); # get user we're adding my $targetid = $arg->{targetid}; return LJ::bad_input($ML{'.error.internerr.invalidaction'}) unless $targetid; # add to community return "" unless LJ::approve_pending_member($aa->{userid}, $targetid); # return success my $commname = LJ::get_username($aa->{userid}); my $username = LJ::get_username($targetid); return "". ' LJ::ljuser($username, { type => 'P' }), comm => LJ::ljuser($commname, { type => 'C' }), aopts => "href=\"$LJ::SITEROOT/community/members.bml?comm=$commname\"", }) . ' p?>'; } # not other action types right now return LJ::bad_input($ML{'.error.unknownactiontype'}); } _code?> <=body page?>