How can I tell easily if to user_ids with many_to_many association are "friends"?

Login or register to post comments
9 replies [Last post]
Offline
Joined: 12/10/2008

I have set up user's so that they can be associated as many-to-many friends using AssociateUserAsAllies

When someone encounter a new User, I want to display knowing the UserId of the logged in user and the UserId of the profile they are viewing whether they are friends?

How can I do that? Seems like I need a way to pass both UserId of user and UserId of the profile they are looking at and searched whether there is an autogen that would do that for me?

Thanks.

Offline
Joined: 03/31/2008

There should be a function like $user->IsUserAsAlliesAssociated($objUser) you can use.

Offline
Joined: 12/10/2008

Ah, so if the logged in user is objUserUser and the "friend" is say objAllyUser, it would be:

$objAllyUser->IsUserAsAlliesAssociated($objUserUser)

if($objAllyUser) {
  echo "you're friends!";
}

Offline
Joined: 03/31/2008

More like

if($objAllyUser->IsUserAsAlliesAssociated($objUserUser)) {
  echo "you're friends!";
}

Offline
Joined: 12/10/2008

right, thanks!

Offline
Joined: 12/10/2008

I guess this logic would be placed in the actual view.....? Maybe create a strLabel that is assigned based on the outcome?

Offline
Joined: 12/10/2008

Hmmm...get error Call to undefined method ProfileActivityForm::IsUserAsAlliesAssociated()...this should be part of the core autogen, right?

Offline
Joined: 12/10/2008

hmm...okay the function is there in the generated code....so why would this be an undefined method?

k9
Offline
Joined: 11/19/2008

i think you're calling it as a static method e.g ProfileActivityForm::IsUserAsAlliesAssociated()

that's wrong i think. you need to have created a user object

$objAllyUser->IsUserAsAlliesAssociated($objUserUser)

Offline
Joined: 12/10/2008

So am I putting that in the VIEW? What I have is one content is displayed if = 1 and another if =0