When adding the User relationships: Status link field I and presented with the Remove link in my View. This is perfect but when I click remove the usual confirmation form shows up empty. See attached. When testing the View I also get the following error message.

warning: Invalid argument supplied for foreach() in /public_html/sites/all/modules/user_relationships/user_relationships_api/user_relationships_api.module on line 43.

CommentFileSizeAuthor
#1 error.jpg30.22 KBAnonymous (not verified)

Comments

Anonymous’s picture

StatusFileSize
new30.22 KB

screenshot of above mentioned issue.

Anonymous’s picture

After further testing I can confirm that the error is in fact being caused by enabling the User relationships: Status field in my View.

design.er’s picture

Yes, I can confirm this. I have the same issue.

alex.k’s picture

Status: Active » Closed (duplicate)

Sounds like a duplicate of #587880: Change status link for Views which is already fixed in -dev.

Anonymous’s picture

Can you please confirm if the patch you are referring to here http://drupal.org/node/587880#comment-2144504 can be applied to version 6.x-1.0-rc3?

Thanks

alex.k’s picture

Yes it should work with no issues.

bentoo42’s picture

I want to be able to have an add or remove link depending on whether a particular relationship has been added. What is the best way to accomplish this? Do I need to write custom php code to check if the relationship exists using the UR-api?

alex.k’s picture

If you need to show link to add/remove relationship of type B based on the existence of relationship of type A - then you'll still need custom PHP code. Otherwise the field will know the status of relationship and show correct add or remove link.

andrew.lansdowne’s picture

Actually it seems that the views field is not able to show an Add link - it only shows Remove, Cancel pending, Approve, Decline. Which is a shame if you wanted to make a 'friend finder' view but I suppose it makes sense since fields and filters run on data which *does* exist rather than not.

You can do this via custom PHP field (using the Views Custom Field module; you must add a field User: UID before the PHP field - it can be hidden from display) for example:

global $user;
if ($user->uid != $data->users_uid) {
              if ($relationships = user_relationships_load(array('requester_id' => $user->uid, 'requestee_id' => $data->users_uid))) {

                $relationships_array = array_values($relationships);
                $relationship = $relationships_array[0];
                //print $relationship->rid; 

             return '<span class="profile-contact"><span class="profile-remove">' . l('Remove as contact', 'user/' . $user->uid . '/relationships/' . $relationship->rid . '/remove', array('attributes' => array('class' => 'user_relationships_popup_link'))) . '</span></span>'; 
                 } else { 
             return '<span class="profile-contact"><span class="profile-add">' .l('Add as contact', 'relationship/' . $data->users_uid. '/request/1', array('attributes' => array('class' => 'user_relationships_popup_link'))). '</span></span>'; 
                 } 
}

Hope that might help someone. It could do with more stuff for handling pending, approve, reject, cancel though. Will update if I find a better way... hope someone else might too :-)

andrew.lansdowne’s picture

Update: This appears to be a better way which uses the same functions that the user relationships user view page uses to write out links:

global $user;
$found_user = user_load($data->users_uid);
if ($list = _user_relationships_ui_actions_between($user, $found_user)) {
return theme('item_list', $list);
}

I haven't tested this in all circumstances yet but it looks good so far.

salientknight’s picture

Are you adding this to a custom PHP field?