Breaking out this issue from a separate thread.
The issue here is if more than one action is possible between users, each iteration through the below array will overwrite the previous, resulting in just one link for relationship actions, regardless of how many there are, when visiting another user's page under the 'Profile image and action links' block.

$actions = _user_relationships_ui_actions_between($user, $account);
foreach ($actions as $key => $action) {
        $links["ur_action"] = array(
          'title' => $action . 'action',
          // No href because this is the best that UR can offer
          'html' => TRUE,
        );
      }

This patch, logic provided here: http://drupal.org/node/1244998#comment-5020824, fixes that, since the $links array is passed through the theme_links function. Therefore instead of overwriting, we create a separate array for each link (e.g. $links['ur_action_0'] = array('title' => 'some linked title', 'html' => TRUE); $links['ur_action_1'] = array('title' => 'some other linked title', 'html' => TRUE);).

Resulting patched code below:

$actions = _user_relationships_ui_actions_between($user, $account);
foreach ($actions as $key => $action) {
        $links["ur_action_$key"] = array(
          'title' => $action,
          // No href because this is the best that UR can offer
          'html' => TRUE,
        );
      }
CommentFileSizeAuthor
ur_action_links_fix-1244998-6.patch846 byteschrisarusso

Comments

isellakuria’s picture

Thanks for your patch, I have tried it and now two links are displayed below the user picture: "follow" and "unfollow". If I press "follow" both users can see their respective user updates like in twitter. However now I see two "unfollow" links below the user's picture.

isellakuria’s picture

I think I found a temporary solution to my problem, I'm posting the modified code, I tested it rapidly and it works even if I think it should not be the final solution:

if (user_access('maintain own relationships')) {
      $actions = _user_relationships_ui_actions_between($user, $account);
	  if (count($actions)>1){
		$size = count($actions)-1;
		$actions = array_slice($actions,0,$size);
	  }	  
	  foreach ($actions as $key => $action) {
       	//drupal_set_message($actions[$key]);
		$links["ur_action"] = array(
          'title' => $action,
          // No href because this is the best that UR can offer
          'html' => TRUE,
        );
      }
    }

I basically added a condition for when there is just more than one action and if so I remove the last item of the array ("unfollow") that is the one that was originating the problem initially. Only one action is passed to the $links array every time.

ezra-g’s picture

Status: Needs review » Fixed

Thanks very much for the patch here - I apologize that it didn't get a proper review. An equivalent fix to this hunk of code was made in the commit for #1244998: User relationships not working as expected (version 2).

Thanks!

Status: Fixed » Closed (fixed)

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