I'm going to be moving away from User Relationships on my own site. Nothing against UR; it's a fine module. I just decided I want to move to a more Twitter like "follow" module rather than friending and am going to do it using Flag.

I'm trying to cut down on supporting modules I don't use, so I'm asking to pull the Author Pane integration into UR. The AP specific code is very simple and low maintenance with the heavy lifting being in the UR specific code so it wouldn't be much work on your end. I have one last change I need to finalize with regards to allowing site admins to selectively turn off integrations but, after that, the code will be pretty stable.

Michelle

CommentFileSizeAuthor
#4 ur_author_pane.patch662 bytesjcmarco

Comments

michelle’s picture

Forgot something. This issue needs sorting, and that will be in the UR specific code as well: #738226: Ensure all possible user relationships are covered

Michelle

freelylw’s picture

seems UR can do the one way following as well. still thinking UR or Flagfriend

michelle’s picture

Here is the last version of the integration. I've pulled it from Author Pane. It works somewhat but has some issues as seen in #738226: Ensure all possible user relationships are covered. If you look at the code, you can see that 99% of it deals with UR code and there is very little to do for the AP integration. Given that, and given that I am moving away from UR, I just can't support it anymore and don't want a broken integration in the 2.0 release.

If you need any help with the AP side of things to add the integration to UR, I'd be happy to help.

Michelle

jcmarco’s picture

StatusFileSize
new662 bytes

Patch to fix last version with Author Pane 2.0

bennos’s picture

thx jcmarco

michelle’s picture

Hmm... I don't see what this patch is doing?

Anyway, as far as I know, the code works aside from that issue I linked to.

Michelle

jcmarco’s picture

Because with the existing nested if's,
the $variables['user_relationships_api'] was not defined and then not shown in the author pane template.

michelle’s picture

Oh, I was just looking at the actual text and didn't notice the indentation. Weird... I'm still using UR on my site at this point and it's working fine for me.

Michelle

michelle’s picture

In an attempt to move this along, here is the function with all the AP stuff in it. What's needed is for someone to fill in the "meat" of the function with the UR code that covers all the crazy possibilities of who can have relations with whom.

/**
 * Implementation of hook_preprocess_author_pane().
 */
function user_relationships_api_preprocess_author_pane(&$variables) {
  // Check if this preprocess needs to be run given who's calling it.
  if (!author_pane_run_preprocess('user_relationships_api', $variables['caller'])) {
    return;
  }

  global $user;
  $account = $variables['account'];
  $account_id = $account->uid;

  /*
  In this section, the $variables['user_relationships_api'] needs to be set to a link to either add the person or remove the person. The link needs to have a class of either author-relationship-add-icon or author-relationship-remove-icon so the appropriate icon can be added in CSS. That's all that is needed from the Author Pane end. The complex part is with the UR code and determining which link to show based on the logged in user and the user being viewed.
  */

}

/**
 * Implementation of hook_author_pane_allow_preprocess_disable().
 */
function user_relationships_api_author_pane_allow_preprocess_disable() {
  return array('user_relationships_api' => 'User Relationships');
}
michelle’s picture

Sorry to keep posting on here but I want to have this resolved before I release AP 2.0 so keep thinking about this.

I think part of the problem is that UR is very complex and isn't easily reduced to a simple "add friend" in all cases. So how about if it gets a new API function that does this:

  • Caller passes in the UID of the user who is viewing and the UID of the user that is being viewed.
  • Function returns an item list of links. Each possible relationship has one link.
  • Each link has a class of either "relationship-add" or "relationship-remove"
  • Each link also has a class that corresponds to the relationship type, such as "relationship-contact" or "relationship-friend"

Doing this would encapsulate all the logic into a UR API function and keep the integration clean. I would still prefer to have the integration in UR but would be willing to pull it back into AP if needed if all the UR logic was a simple function call. It would also cover all the possible relationship types and put them in a single variable that's easy to add to the template. By having both the add/remove class and the relationship class, the theme could target each type and give it a different icon if wanted. AP would continue to provide the generic icon based on add/remove.

What do you think?

Michelle

dmetzcher’s picture

Are there any updates from the UR maintainer(s)?
Will support for Author Pane be added to User Relationships? :)

michelle’s picture

He emailed and said he'd look at it but it sounds like he's very busy so I don't know when he'll get to it.

Michelle

dmetzcher’s picture

Thanks, Michelle.
For now I've gone with displaying the UR Actions block in a pane on my profile pages. I added a little styling and it actually sort of looks like what you had going on in Author Pane (although I've moved it to just under the profile page's title text).

Note for the maintainer: If this is implemented... could we get a setting (even a submodule that we could deactivate would be fine) so that we can choose to not display the UR actions in the Author Pane? An interesting idea would be to allow us to turn it on and off for Advanced Profile Kit (Author Pane on profiles) and Advanced Forum (Author Pane on forums), but I know that's probably a lot more work for you, so whatever is simplest will work just fine, I think. :)

alex.k’s picture

Assigned: Unassigned » alex.k

I committed initial integration in http://drupal.org/cvs?commit=437224

It uses the CSS classes you suggested, as well as settings to turn on/off the entire feature (see in admin/user/relationships/settings) and pick which relationship type to use for the link.

I have a question, though. AP seems to require that only one element is passed into $variables[...]. This means that UR needs to output just one link, or an HTML list of several. It would have been better if AP would array_merge the individual $variables so that the list looks uniform, yet modules can return more than one link. What do you think?

In the meantime UR has a control to pick which relationship type will be used in AP.

michelle’s picture

Thanks for committing this. :)

You can put whatever you want into $variables. I suggest using 1 variable to keep it simple for end users. Whatever you put in there comes out as a variable in the template. It's a lot easier for someone who may not know PHP to just have one variable per module. If you want to change things, though, just let me know and I'll update the template with the changes.

Michelle

alex.k’s picture

Status: Active » Fixed

Thanks for the hint, corrected this now to allow picking more than one relationship type, if desired. Hope this works :)
http://drupal.org/cvs?commit=437362

michelle’s picture

Thanks, Alex. I'm totally focused on Advanced Forum at the moment but will be turning my attention back to Author Pane soon as I get AF alpha 4 out. If I find anything that's not working I'll let you know.

Michelle

ukrdrupal’s picture

...subscribing

stg11’s picture

...subscribing

Status: Fixed » Closed (fixed)

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

michelle’s picture

Status: Closed (fixed) » Active

Sorry to have to revisit this but it turns out this isn't fixed. When I tested, I missed deleting the .inc from my copy of AP and it turns out it was using that instead of this version. I just discovered that today while trying to fix another issue.

1) The file is named wrong. It should be user_relationships_api.author-pane.inc. This is why I never noticed I was testing the wrong code... It never found your code.

2) The changes to the code itself aren't working. Comparing what's in there now to what used to be in there, it looks like there's a bunch of changes. I don't know enough about UR to be able to tell what's wrong but I narrowed down the problem area to this:

  foreach ($rtids as $rtid) {
    $rtypes[] = $all_rtypes[$rtid];
  }

$rtids is array(0 => 0)
$all_rtypes is array(1 => $object) where $object is the relationship.

So $all_rtypes[$rtid]; isn't finding anything because there is no 0 key in that array.

Thanks,

Michelle

michelle’s picture

Oh! I just had a lightbulb moment with #2. I looked at the variable and realized it said "author pane" in it which meant there must be some AP related setting. Doh! Reading back, I see you said that and I totally missed it. Ok, so forget #2. That's just a matter of going into the setting page and setting it. #1 is still needing fixing, though.

Michelle

alex.k’s picture

Status: Active » Fixed

Fixed http://drupal.org/cvs?commit=459510 please try it out.

michelle’s picture

Looks like it should work fine; all I did was change the filename on my copy to fix it in testing. I'll grab a new tarball tonight when it's generated and do a fresh install to be sure. Thanks!

Michelle

alex.k’s picture

And http://drupal.org/cvs?commit=459512 to remove manual load of the .inc file from user_relationships_api.module. That's why it worked for me despite being incorrectly named.

michelle’s picture

Huh... Weird. If there's a manual include in there, I wonder why I didn't get an error about the redefined function? At any rate, yeah, you don't need it. AP handles loading the file for you. Trying to make it real simple for module maintainers. :)

Michelle

webchick’s picture

This mis-named file caused rc6 to completely white screen of death on any forum node on our site.

It might be good to get another rc out when it's prudent. That's an hour of my life I'll never get back. :D

sandino’s picture

I have UR link if I'm already in relationship with a user (e.g. link to remove a friend). But the link is not shown if I'm not in relaitonship (e.g. to add a friend).

After updating on new version of UR the problem still exists.

gallamine’s picture

I have the same problem that Sandino has. I running Author Pane 2, the latest version of Advance Profile Kit and the latest (as of today), dev. copy of UR. I can only see the "remove" link, not the "add" link.

paul555’s picture

I also have the same problem with sandino and gallamine

DrupalCuckoo’s picture

hi,

I've read this this issue and I've a question:

Since I've updated to Author Pane 6.x-2.0, the "add user as friend" link on a profile page is no longer showing up. I've also updated the User Relationships Module to the latest version 6.x-1.0. In the UR module directory there's a file called "user_relationships_api.author-pane.inc" which - I think - should provide the missing link.

In the author_pane.tpl.php file there's the variable "$user_relationships_api_link" and when I print it, it's empty.

How can I make this work again?

Thanks for any help!
DrupalCuckoo

michelle’s picture

Try this version: http://drupal.org/node/500960 . I can't remember if the changes to the template file made it in before 2.0. I'll be making a 2.1 release once Advanced Forum Alpha 4 is released.

Michelle

oduvanchik’s picture

Michelle,

I tried to update author pane, and updated user relationships. It is not showing up. IS there anything else I can do?

HamsterTrainer’s picture

the newest versions dont work together :(

junro’s picture

Hello, just figure user relationship link doesn't not appear in author pane anymore.

Even If I check "Show links in Author Pane" in admin/user/relationships/settings, and select my relationship to use.

I can't tell after what event the link has dissappear. After the update of UR module? I think so, logical, but not sure.

junro’s picture

Status: Fixed » Active

I'm using:
Author Pane 6.x-2.0
User Relationships 6.x-1.0

HamsterTrainer’s picture

it works withe the newest versions of UR and AP

i see the AP integration is now in UR --> settings

junro’s picture

Can you give me your versions? dev version? new 1.0 version?

I'm using the last recommanded version.

michelle’s picture

Status: Active » Fixed

This integration is working fine. You may need to use the development version of AP until there's a new release. Make sure you've set up the integration in the UR settings.

Michelle

HamsterTrainer’s picture

Status: Fixed » Active

my versions...

Author Pane 6.x-2.0
UR 6.x-1.0

rkarajgi’s picture

I am using

user_relationships-6.x-1.0
author_pane-6.x-2.x-dev (as of today)

I enabled the Integration in UR settings and selected the Friends, as the relationship.

I cleared all caches.

I was expecting to see the links for Add as Friends in Author pane.

But still dont get the links. Is this integration working?

In the AP 2.x-dev, in the modules folder, there is no user_relationships*.author-pane.inc file present.

rkarajgi’s picture

It works - I was using Advanced Profile Kit and I had made another copy of the author-pane.tpl.php as the advanced_profile_author_pane.tpl.php. I copied the new author-pane.tpl.php file to themes folder as advanced_profile_author_pane.tpl.php and it works as expected.

Thanks for this Author Pane and User Relationships integration. It sure makes life much easier now !

AntiNSA’s picture

Priority: Normal » Critical

I absolutely can not see the add friend link with newest devs of both versions... I need this to work.

AntiNSA’s picture

Priority: Critical » Normal

ok sorry I had to select the friend type to add..

michelle’s picture

Status: Active » Fixed

I don't even know why this is active. This has been implemented for some time.

Michelle

Status: Fixed » Closed (fixed)

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

venusrising’s picture

Status: Closed (fixed) » Active

We are running RC6 but did not want to start a new duplicate thread. Don't know how we missed this but we too have the issue with the missing add friend link in authorpane. All user relationship configurations are ticked and I see the code in AP but no sign of the link.

Any input from anyone would be terrific.
Thanks

venusrising’s picture

I have the same issue as gallamine & Sandino

venusrising’s picture

Status: Active » Fixed

Okay for anyone having trouble
We had an old type of friend. I opened it up and made sure that the settings were not blank (which would mean ALL users could have the type but it was not working this way) I made sure that for
Role request access
Role receive access
These were set and not left blank.
Prior of course we went in to the new UR admin and selected Authorpane. After hunting for hrs it was the lack of the Role settings being blank causing the issue for us. Hope this helps someone.

Status: Fixed » Closed (fixed)

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