Can't have more than one related person without "multiple relationships" activated

ergelo - June 16, 2008 - 17:52
Project:User Relationships
Version:5.x-2.x-dev
Component:User interface
Category:support request
Priority:critical
Assigned:alex.k
Status:closed
Description

Hi, I installed the module on drupal 5.7, I can create relationships and see the "all" and "pending" requests pages, but there is no sign of the "request relationship" links! Do I have to activate it somehow, or maybe insert code somewhere?
thanks
bruno

#1

tlash - June 17, 2008 - 18:06

Similar problem. I can Invite a friend via email, but when I navigate to another user profile there is no link to request relationship. I am using Advanced Profile Kit and NodeProfile. I have added Buddylist in the UserProfile/Panel..and I would have thought that there would be a Request Relationship item there to be added. This all could be because I added buddylist2 after I installed Advanced Profile Kit so now it needs to be added manually.

Thanks in advance for your help.

#2

Roman S - June 19, 2008 - 19:11

When I enable "Allow Multiple Relationships" in User Management -> Relationships -> Settings and also display the Actions block, I get a link to create a relationship with a user, whose profile I'm on. The link leads to a page when I get to choose the relationship type. If I disable "Allow Multiple Relationships", I would think it would just try to bypass that page, however the entire Actions block is now gone! Is there some other way of adding relationships that I'm missing?

#3

reed.richards - June 25, 2008 - 12:14

I can confirm that I have the same issue.

The problem seems to stem from the _user_relationships_actions_between function where there are some lines like this

<?php
  $types_count
= (int)db_result(db_query("SELECT COUNT(*) FROM {user_relationship_types}"));
  if (
   
variable_get('user_relationships_allow_multiple', TRUE) &&
    (
user_relationships_load(array('between' => array($viewer->uid, $viewed->uid)), TRUE) < $types_count
 
) {
   
$list[] = theme('user_relationships_request_relationship_link', $viewed);
  }
?>

The code does some strange checking, the logical way for me as I see it would be to first check if there's a relationship with this user, pending or other and if so check if multiple relationships are allowed. The easy way would be just to check if the there's some sort of relation right now pending or other and then check if multiples are allowed and if everything is returned true list the other possible relationships. Of course this would all be solved if the module implemented some sort of role based permissions. Anyways my fix for this would look like this,

<?php
  $types_count
= (int)db_result(db_query("SELECT COUNT(*) FROM {user_relationship_types}"));
 
$relationshipsBetweenUsers = sizeof(user_relationships_load(array('between' => array($viewer->uid, $viewed->uid)), FALSE));
 
# First check if there's some pending relationships, we
  # did that above so now we just check if there's a relationship
  # and if so add the relationships options.

 
if( $relationshipsBetweenUsers < 1 ){
   
$list[] = theme('user_relationships_request_relationship_link', $viewed);
      }     
  else {   
     
# Ok so there's lists check if multiple relationships are allowed
      # and if there's less relationsships between users than there's
      # relationships below.
     
if (
       
variable_get('user_relationships_allow_multiple', TRUE) &&
       
$relationshipsBetweenUsers < $types_count)
      ) {
       
$list[] = theme('user_relationships_request_relationship_link', $viewed);
      }
}
?>

The only problem now is the rest of the places, where's there seems to be a problem. Even with this fix you can't add requests you just get to the request page and then nothing happens. So this seems to be a bigger overall issue.

#4

reed.richards - June 25, 2008 - 11:30
Status:active» needs review

In the user_relationship_api.inc, there's a function called user_relationships_request_relationship where there's a snippet

<?php
 
if (!variable_get('user_relationships_allow_multiple', TRUE)) {
    if (
user_relationships_load(array('user' => $requester->uid, TRUE) || user_relationships_load(array('user' => $requestee->uid, TRUE)))) {
      return
t('Users are not allowed to have multiple relationships');
    }
  }
?>

I changed this to

<?php
 
if (!variable_get('user_relationships_allow_multiple', TRUE)) {
    if (
user_relationships_load(array('between' => array($requester->uid, $requestee->uid), 'rtid' => $type->rtid), FALSE)) {
      return
t('Users are not allowed to have multiple relationships');
    }
  } 
?>

This combined with the stuff above seems to fix at least the possibility to add one relationship when the multiple option is not checked.

#5

reed.richards - June 26, 2008 - 14:19

Come to think of it, the allow multiple option might be designed to let user only have one relationship, not one type of relationship i.e. if the multiple option is not checked then the user can have only one relationship not matter what kind of relationships there are. This kind of make sense, however if you wanted to restrict the user to having only one kind of relationship there's no such option.

The above patch thus transforms the multiple option into an option for letting the user have a relationship but only one to as many as the user want, disregarding how many types of relationships there are.

#6

Vuds - October 10, 2008 - 20:29
Title:Can't add relationships» Can't have more than one related person without "multiple relationships" activated
Version:5.x-2.8» 5.x-2.x-dev
Priority:normal» critical
Status:needs review» reviewed & tested by the community

I didn't have found this issue before, even if I had looked for it. I had found it just when I was looking for create an issue of this error, when I already had a solution for it.

I also tracked down this error and I've got the same conclusion as in #4 with one difference: because I believe that the concept of "single relationship" is to have two persons with just one relationship of any kind (their choice) between them only. So, I don't test it for $type->rtid, just verify if there is some relationship between requester and requestee, or not.

This is critical since UR single relationships based systems doesn't work without this patch. And in last DEV it isn't included yet.

Also, I couldn't understand why this function user_relationships_request_relationship() returns messages errors. The "if" statement right after a call for that inside the function user_relationships_request() (in user_relationships_forms.inc) tests if it returns TRUE or FALSE. That means, there is a big concept error here.

Anyway, it's a great module...

Vuds could you create an

alex.k - October 10, 2008 - 20:50

Nevermind this comment, strange d.o behavior...

#7

alex.k - October 10, 2008 - 21:11
Assigned to:Anonymous» alex.k
Status:reviewed & tested by the community» fixed

Just committed a fix for this, please check out the dev branch, and test. I've also tweaked function user_relationships_request_submit() in user_relationships_actions.inc, because it did not properly handle return values when relationship was not created. Hope it works.

#8

Anonymous (not verified) - October 24, 2008 - 21:23
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.