fixed: #4177 You can no longer send friends who are in your friends list or who you've already invitedto your friends network
This commit is contained in:
parent
18585200a7
commit
4dbd7bac1a
4 changed files with 59 additions and 1 deletions
|
|
@ -169,6 +169,37 @@ sub isFriend {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isInvited ( userId )
|
||||
|
||||
Returns a booelean indicating whether the user has already been invited to the friends network.
|
||||
|
||||
=head3 userId
|
||||
|
||||
The userId to check against this user.
|
||||
|
||||
=cut
|
||||
|
||||
sub isInvited {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $userId = shift;
|
||||
|
||||
my ($isInvited) = $session->db->quickArray(q{
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
friendInvitations
|
||||
where
|
||||
inviterId = ?
|
||||
and friendId = ?
|
||||
},
|
||||
[$session->user->userId,$userId]);
|
||||
|
||||
return $isInvited;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( session, user )
|
||||
|
||||
Constructor.
|
||||
|
|
|
|||
|
|
@ -40,8 +40,24 @@ sub www_addFriend {
|
|||
return $session->privilege->insufficient() unless ($session->user->isRegistered);
|
||||
my $friendId = $session->form->get('userId');
|
||||
my $protoFriend = WebGUI::User->new($session, $friendId);
|
||||
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Friends');
|
||||
|
||||
my $friends = WebGUI::Friends->new($session);
|
||||
if($friends->isFriend($friendId)) {
|
||||
my $returnToProfile = sprintf($i18n->get('add to friends profile'),$protoFriend->getFirstName);
|
||||
my $backUrl = $session->url->append($session->url->getRequestedUrl, 'op=viewProfile;uid='.$friendId);
|
||||
return $session->style->userStyle(
|
||||
sprintf($i18n->get("error user is already friend"),$backUrl,$returnToProfile)
|
||||
);
|
||||
}
|
||||
elsif($friends->isInvited($friendId)) {
|
||||
my $returnToProfile = sprintf($i18n->get('add to friends profile'),$protoFriend->getFirstName);
|
||||
my $backUrl = $session->url->append($session->url->getRequestedUrl, 'op=viewProfile;uid='.$friendId);
|
||||
return $session->style->userStyle(
|
||||
sprintf($i18n->get("error user is already invited"),$backUrl,$returnToProfile)
|
||||
);
|
||||
}
|
||||
|
||||
# Check for non-existant user id.
|
||||
if ((!$protoFriend->username) || (!$protoFriend->profileField('ableToBeFriend'))) {
|
||||
|
|
|
|||
|
|
@ -295,6 +295,16 @@ Thanks,
|
|||
lastUpdated => 1181493546,
|
||||
},
|
||||
|
||||
'error user is already friend' => {
|
||||
message => q|This user is already a member of your friends network <br /><p> <a href="%s">%s</a></p>|,
|
||||
lastUpdated => 1181493546,
|
||||
},
|
||||
|
||||
'error user is already invited' => {
|
||||
message => q|You have already sent an invitation for this user to join your friends network <br /> <p><a href="%s">%s</a></p>|,
|
||||
lastUpdated => 1181493546,
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue