4 title=><?_ml .title _ml?>
11 my $remote = LJ::get_remote();
12 return "<?needlogin?>" unless $remote;
14 my $qs = BML::get_query_string();
15 return LJ::bad_input($ML{'.error.invalidargument'})
16 unless $qs && $qs =~ /^(\d+)\.(.+)\.(\d+)$/;
18 my ($aaid, $auth, $mnt) = ($1, $2, $3);
19 my $aa = LJ::is_valid_authaction($aaid, $auth);
20 return LJ::bad_input($ML{'.error.invalidargument'})
22 return LJ::bad_input($ML{'.error.actionperformed'})
23 if $aa->{'used'} eq 'Y';
26 LJ::decode_url_string($aa->{'arg1'}, $arg);
28 ### perform actions according to the action type
30 # reject someone joining a community
31 if ($aa->{action} eq 'comm_join_request') {
33 #create list of users which can do it.
34 my @all_which_allowed;
35 my $maintainers = LJ::load_rel_user_cache($aa->{userid}, 'A') || [];
36 my $moderators = LJ::load_rel_user_cache($aa->{userid}, 'M') || [];
37 my $owner = LJ::load_rel_user_cache($aa->{userid}, 'S') || [];
38 push @all_which_allowed, (@$maintainers, @$moderators, @$owner);
40 #find remote user in allow list
41 unless (grep $_ eq $remote->{userid}, @all_which_allowed) {
42 return LJ::bad_input($ML{'.error.nopermission'});
45 my $dbh = LJ::get_db_writer();
47 # get user we're adding
48 my $targetid = $arg->{targetid};
49 return LJ::bad_input($ML{'.error.internerr.invalidaction'}) unless $targetid;
51 return "<?h1 $ML{'Error'} h1?><?p $ML{'.error.rejecting'} p?>"
52 unless LJ::reject_pending_member($aa->{userid}, $targetid, $mnt, 0);
55 my $commname = LJ::get_username($aa->{userid});
56 my $username = LJ::get_username($targetid);
57 return "<?h1 $ML{'.comm.success'} h1?>".
58 '<?p ' . BML::ml('.commreject.text', {
59 user => LJ::ljuser($username),
60 comm => LJ::ljuser($commname),
61 aopts => "href=\"$LJ::SITEROOT/community/members.bml?authas=$commname\"",
65 # not other action types right now
66 return LJ::bad_input($ML{'.error.unknownactiontype'});