1 package LJ
::Event
::CommunityJoinRequest
;
3 use Class
::Autouse
qw(LJ::Entry);
8 my ($class, $u, $requestor, $comm) = @_;
10 foreach ($u, $requestor, $comm) {
11 LJ
::errobj
('Event::CommunityJoinRequest', u
=> $_)->throw unless LJ
::isu
($_);
14 # Shouldn't these be method calls? $requestor->id, etc.
15 return $class->SUPER::new
($u, $requestor->{userid
}, $comm->{userid
});
22 return LJ
::load_userid
($self->arg2);
27 return LJ
::load_userid
($self->arg1);
33 # we need to force the authaction from the master db; otherwise, replication
34 # delays could cause this to fail initially
35 my $arg = "targetid=". $self->requestor->id;
36 my $auth = LJ
::get_authaction
($self->comm->id, "comm_join_request", $arg, { force
=> 1 })
37 or die "Unable to fetch authcode";
39 return "$LJ::SITEROOT/approve/" . $auth->{aaid
} . "." . $auth->{authcode
};
44 return sprintf("The user %s has <a href=\"$LJ::SITEROOT/community/pending.bml?authas=%s\">requested to join</a> the community %s.",
45 $self->requestor->ljuser_display, $self->comm->user,
46 $self->comm->ljuser_display);
52 my $lang = $u->prop('browselang') || $LJ::DEFAULT_LANG
;
55 body
=> LJ
::Lang
::get_text
($lang, 'esn.comm_join.params.body', undef, {
56 user
=> $self->requestor->ljuser_display,
57 community
=> $self->comm->ljuser_display,
58 url
=> "$LJ::SITEROOT/community/pending.bml?authas=" . $self->comm->user,
60 userpic
=> $self->requestor->userpic ?
$self->requestor->userpic->url : '',
61 subject
=> LJ
::Lang
::get_text
($lang, 'esn.comm_join.params.subject'),
63 action_url
=> $self->requestor->profile_url,
64 action
=> LJ
::Lang
::get_text
($lang, 'esn.comm_join.actions.view.profile'),
66 action_url
=> "$LJ::SITEROOT/community/pending.bml?authas=" . $self->comm->user,
67 action
=> LJ
::Lang
::get_text
($lang, 'esn.comm_join.actions.manage.members'),
75 my $ret .= "<div class='actions'>";
76 $ret .= " <a href='" . $self->requestor->profile_url . "'>View Profile</a>";
77 $ret .= " <a href='$LJ::SITEROOT/community/pending.bml?authas=" . $self->comm->user . "'>Manage Members</a>";
84 my ($self, $target) = @_;
86 return $self->as_html_actions;
91 return sprintf("The user %s has requested to join the community %s.",
92 $self->requestor->display_username,
93 $self->comm->display_username);
96 my @_ml_strings_en = (
97 'esn.community_join_requst.alert', # [[who]] requests membership in [[comm]]. Visit community settings to approve.
98 'esn.community_join_requst.subject', # '[[comm]] membership request by [[who]]!',
99 'esn.manage_membership_reqs', # '[[openlink]]Manage [[communityname]]\'s membership requests[[closelink]]',
100 'esn.manage_community', # '[[openlink]]Manage your communities[[closelink]]',
101 'esn.community_join_requst.email_text', # 'Hi [[maintainer]],
103 #[[username]] has requested to join your community, [[communityname]].
107 'esn.comm_join.actions.view.profile', # View Profile
108 'esn.comm_join.actions.manage.members', # Manage Members
109 'esn.comm_join.params.body', # The user [[user]] has <a href="[[url]]">requested to join</a> the community [[community]].
110 'esn.comm_join.params.subject', # Someone has requested to join the community
113 sub as_email_subject
{
115 return LJ
::Lang
::get_text
($u->prop('browselang'), 'esn.community_join_requst.subject', undef,
117 comm
=> $self->comm->display_username,
118 who
=> $self->requestor->display_username,
123 my ($self, $u, $is_html) = @_;
125 my $maintainer = $is_html ?
($u->ljuser_display) : ($u->user);
126 my $username = $is_html ?
($self->requestor->ljuser_display) : ($self->requestor->display_username);
127 my $user = $self->requestor->user;
128 my $communityname = $self->comm->user;
129 my $community = $is_html ?
($self->comm->ljuser_display) : ($self->comm->display_username);
130 my $auth_url = $self->authurl;
131 my $rej_url = $auth_url.".".$u->userid;
132 $rej_url =~ s/approve/reject/;
133 my $lang = $u->prop('browselang');
136 LJ
::Lang
::get_text_multi
($lang, undef, \
@_ml_strings_en);
139 maintainer
=> $maintainer,
140 username
=> $username,
141 communityname
=> $community,
144 return LJ
::Lang
::get_text
($lang, 'esn.community_join_requst.email_text', undef, $vars) .
145 $self->format_options($is_html, $lang, $vars,
147 'esn.manage_request_approve' => [ 1, $auth_url ],
148 'esn.manage_request_reject' => [ 2, $rej_url ],
149 'esn.manage_membership_reqs' => [ 3, "$LJ::SITEROOT/community/pending.bml?authas=$communityname&jumpto=$user" ],
150 'esn.manage_community' => [ 4, "$LJ::SITEROOT/community/manage.bml" ],
155 sub as_email_string
{
157 return _as_email
($self, $u, 0);
162 return _as_email
($self, $u, 1);
167 my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG
;
169 # [[requestor]] requests membership in [[comm]]. Visit community settings to approve.
170 return LJ
::Lang
::get_text
($lang, 'notification.sms.communityjoinrequest', undef, {
171 requestor
=> $self->requestor->display_username(1),
172 comm
=> $self->comm->display_username(1),
179 return LJ
::Lang
::get_text
($u->prop('browselang'),
180 'esn.community_join_requst.alert', undef,
182 who
=> $self->requestor->ljuser_display(),
183 comm
=> $self->comm->ljuser_display(),
187 sub subscription_as_html
{
188 my ($class, $subscr) = @_;
189 return LJ
::Lang
::ml
('event.community_join_requst'); # Someone requests membership in a community I maintain';
192 sub available_for_user
{ 1 }
193 sub is_subscription_visible_to
{ 1 }
194 sub is_tracking
{ 0 }
201 return LJ
::Lang
::get_text
($lang, "esn.push.notification.communityjoinrequest", 1, {
202 user
=> $self->requestor->user(),
203 community
=> $self->comm->user(),
207 sub as_push_payload
{
212 'j' => $self->comm->user(),
213 'u' => $self->requestor->user(),
218 package LJ
::Error
::Event
::CommunityJoinRequest
;
222 return "LJ::Event::CommuinityJoinRequest passed bogus u object: $self->{u}";