2 title=><?_ml .title _ml?>
9 LJ::set_active_crumb('joincomm');
13 my $remote = LJ::get_remote();
14 return "<?needlogin?>"
18 return "<?h1 $ML{'.error.statusvis.title'} h1?><?p $ML{'.error.statusvis.body'} p?>"
19 unless $remote->{statusvis} eq 'V';
21 # make sure a community doesn't join a community
22 return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.commlogged'} p?>"
23 unless $remote->is_personal || $remote->is_identity;
25 # get info about the community
27 my $cu = LJ::load_user($GET{comm});
29 # does this community even exist?
30 return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.errorcomminfo'} p?>"
33 return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.notcomm'} p?>"
34 unless $cu->is_community;
36 return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.locked'} p?>"
37 if $cu->{statusvis} eq "L";
39 # ensure this user isn't banned
40 return "<?h1 $ML{'Sorry'} h1?><?p $ML{'.label.banned'} p?>"
41 if LJ::is_banned($remote, $cu);
43 # and make sure they're not already a member
44 return "<?h1 $ML{'Error'} h1?><?p $ML{'.error.already.member'} p?>"
45 if LJ::is_friend($cu, $remote);
48 unless ($remote->is_validated()) {
49 return "<?h1 $ML{'Error'} h1?><?p $ML{'.error.email.notvalid'} p?>";
52 # make sure underage users can't join adult communities
54 unless ($remote->can_join_adult_comm( comm => $cu, adultref => \$adult_content )) {
56 if ($adult_content eq "concepts") {
57 $adult_err = BML::ml('.error.ischild', {'comm' => $cu->ljuser_display});
58 } elsif ($adult_content eq "explicit") {
59 $adult_err = BML::ml('.error.isminor', {'comm' => $cu->ljuser_display});
62 unless ($remote->best_guess_age) {
63 $adult_err .= " " . BML::ml('.error.setage', {'aopts' => "href='$LJ::SITEROOT/manage/profile/'"});
66 return "<?h1 $ML{'Error'} h1?><?p $adult_err p?>";
69 my $ci = LJ::get_community_row($cu);
70 my $cuserid = $ci->{'userid'};
72 LJ::text_out(\$ci->{'name'});
73 my $ecname = LJ::ehtml($ci->{'name'});
75 # get the list of maintainers and their usernames
76 my $dbr = LJ::get_db_reader();
77 my $admins = $dbr->selectcol_arrayref("SELECT u.user FROM useridmap u, reluser r ".
78 "WHERE r.userid=$cuserid AND r.targetid=u.userid AND r.type='A'") || [];
80 foreach (sort @$admins) { $list .= "<li><?ljuser $_ ljuser?></li>"};
83 my $next_links = "<?p $ML{'.label.you_can'} p?><ul>";
84 $next_links .= "<li><a href=\'" . $cu->journal_base . "'>". BML::ml('.label.read_recent_entries', {'user' => $cu->user}) . "</a></li>";
85 $next_links .= "<li><a href=\'" . $cu->profile_url . "'>" . BML::ml('.label.read_comm_info', {'user' => $cu->user}) . "</a></li>";
86 $next_links .= "<li><a href='$LJ::SITEROOT/site/search.bml'>".BML::ml('.label.search_other') . "</a></li>";
87 $next_links .= LJ::run_hook("join_comm_extra")
88 if LJ::are_hooks("join_comm_extra");
89 $next_links .= "</ul>";
91 # can't join closed communities
92 if ($ci->{membership} eq 'closed') {
93 $ret .= "<?h1 $ML{'Sorry'} h1?><?p " . BML::ml('.error.closed', { admins => $list }) . " p?>";
100 return "<?h1 $ML{'Error'} h1?><?p $ML{'error.invalidform'} p?>"
101 unless LJ::check_form_auth();
103 my ($code, $message) = LJ::join_community($remote, $cu);
106 return "<?h1 $ML{'Error'} h1?><?p $message p?>";
108 $ret = "<?h1 $ML{'.reqsubmitted.title'} h1?><?p $message p?> ";
113 # add community as a friend if selected
114 if ($POST{addfriend}) {
115 BML::redirect("$LJ::SITEROOT/friends/add.bml?user=$cu->{user}");
118 # success message -- only shows if user didn't add the community as a friend
119 my $profile_url = $cu->profile_url;
120 $ret .= "<?h1 $ML{'.success'} h1?><?p " . BML::ml('.label.membernow6',
121 { 'commname' => LJ::ljuser($cu) }) . " p?>";
123 my $commuser = $cu->{user};
124 my $cancel_text = $ML{'.btn.cancel'};
126 my $cancel_btn = "<script type='text/javascript' language='Javascript'> \n <!-- \n
127 document.write(\"<input type='button' value='$cancel_text' onclick='history.go(-1); return false;'>\");
128 \n // -->\n </script>";
130 if ($ci->{membership} ne 'open') {
131 $ret .= "<?h1 $ML{'.request.title'} h1?><?p ";
132 $ret .= BML::ml('.request.body', { comm => LJ::ljuser($cu) }) . "<br /> p?>";
133 $ret .= "<form method='post' action='join.bml?comm=$commuser'>";
134 $ret .= LJ::form_auth();
135 $ret .= "<?standout <input type='submit' value=\"$ML{'.button.join2'}\" /> ";
136 $ret .= "$cancel_btn standout?></form>";
140 $ret .= "<?h1 " . BML::ml('.label.sure2', {'comm' => LJ::ljuser($cu)}) . " h1?>";
141 $ret .= "<?p " . BML::ml('.label.expls2', {'commname' => $ecname}) . " p?>";
142 $ret .= $ci->{postlevel} eq "members" ?
143 "<?p " . BML::ml('.label.allowposting2', {'sitename' => $LJ::SITENAMESHORT}) . " p?>" :
144 "<?p " . BML::ml('.label.auth2', {'admins' => $list}) . " p?>";
146 $ret .= "<form method='post' action='join.bml?comm=$commuser'>";
147 $ret .= LJ::form_auth();
148 $ret .= "<table cellpadding='0' cellspacing='1' border='0'><tr>";
149 $ret .= "<td><input type='checkbox' name='addfriend' checked='checked'></td><td>";
150 $ret .= LJ::is_friend($remote, $cu) ? BML::ml('.label.addtofriends2.modify', {'comm' => LJ::ljuser($cu)}) : BML::ml('.label.addtofriends3', {'comm' => LJ::ljuser($cu)});
151 $ret .= "</td></tr><tr>";
152 $ret .= "<td> </td><td><span style='font-size: smaller;'>$ML{'.label.addtofriends.note2'}</span></td>";
153 $ret .= "</tr></table>";
154 $ret .= "<?standout <input type='submit' value=\"$ML{'.button.join2'}\" /> ";
155 $ret .= "$cancel_btn standout?></form>";
164 link: htdocs/login.bml, htdocs/userinfo.bml
165 post: htdocs/community/join.bml