The advanced forum mudule is told to be compatible with the User Relationship module, but there is no documentation about that. in the module folder, there is no user-relationship.INC file...

Does this mean there is no support ?

Comments

michelle’s picture

Status: Active » Fixed

Whoever told you that was wrong. There is no integration that I'm aware of.

Michelle

Roulion’s picture

i read it here : http://drupal.org/node/227121

is it planned to be done ?

michelle’s picture

There is no astrisk by user relationsips on that page.

Whether it gets added or not is up to Alex.

Michelle

Roulion’s picture

that means buddylist2 is not supported as well, i gues?

michelle’s picture

The only one that AF comes with code for is buddylist 1 in D5 because I use that on my own site and didn't want to wait for the maintainer to write the code for it.

Michelle

Roulion’s picture

StatusFileSize
new2.37 KB

you might look at these snippets : http://drupal.org/node/319809#comment-1063747, maybe it's not so hard to add this to the advf-author-pane.tpl file ?

I made a little evolution for drupal 6. It looks like woorking...
it gets an add /remove form into the author pane. However, i don't know how to make a module (i just hardcodded the advf-author-pane.tpl.php file to implement it)

If you might help

michelle’s picture

Status: Fixed » Closed (won't fix)

I'm not going to add it unless it gets to a point that I need it and Alex refuses to add it. It doesn't matter how hard it is. The code doesn't belong in AF.

Michelle

michelle’s picture

Title: User relationship implementation » Advanced forum integration
Project: Advanced Forum » User Relationships
Component: User interface » Code
Status: Closed (won't fix) » Active

Actually, why don't we just pop this over to his queue and see what he says.

Alex: I haven't written the doc page, yet, for the hook, but it's simple to do. If you're interested in making UR work with AF, I can write the shell code here for you to fill in with the UR code.

Michelle

alex.k’s picture

Assigned: Unassigned » alex.k

Sure, let me see what the hook, and expected output, is. Generating links to add/remove relationships isn't very hard.

michelle’s picture

At its simplist, it looks like this:

/**
 * Implementation of hook_preprocess_author_pane().
 */
function user_relationship_preprocess_author_pane(&$variables) {
    $variables['YOUR_VARIABLE_NAME_HERE'] = SOME_FUNCTION_CALL_HERE()
 }

You can put as much code in that function as you need and you can define as many variables as you want. Just let me know what they are so I can document them in the template file. The $variables passed in contains 'account' which is the full user object of the author of the post.

You can either include this function directly in your .module or put it in the file user_relationships.forum.inc and it will be picked up automatically.

For a fuller example, see the buddylist 1 integration.

If you have any questions, let me know. I'll write up some better docs on this and get it in the handbook.

Thanks,

Michelle

alex.k’s picture

StatusFileSize
new20.26 KB

This is the simplest integration:

function user_relationships_api_preprocess_author_pane(&$variables) {
  global $user;
  $author = $variables['account'];
  if (!$user->uid || !$account->uid || $user->uid == $account->uid) {
  	return;
  }
  $variables['user_relationships_links'] = theme('item_list', _user_relationships_ui_actions_between($user, $account));
}

Which will print out a bullet list of available add/remove links similarly to Relationship Actions in the user profile. So there is basically a link for each defined relationship type. Do want to show it more minimally, or pop up in a div?

michelle’s picture

Erm... That's way too complicated and way too much text to cram into the author pane.

For reference, here's the variables available for buddylist:

* - $buddylist: Linked icon.
* - $buddylist_link: Linked translated text "Add to buddylist" or "Remove from buddylist".

AF uses the icon by default. If the site admin wants words instead, they change it to use the other variable. That's the sort of thing we need here.

Michelle

alex.k’s picture

StatusFileSize
new4.88 KB
new5.06 KB

This is a little better. If there is just one relationship type defined, it'll look just like buddylist, offering an icon and a text link.

If there are several types, each is shown as a text link: +buddy, +associate, +whatever. See attached screen for what the links are. There are no 'minus' links, since removing relationships is not an often-done task. To make display cleaner, you probably want to style the list items inline

michelle’s picture

Funny, I was just thinking in the shower this morning that I really need to come back to this thread and clarify. I wrote my posts hastily without putting a lot of thought into them and I'm afraid I came off as unappreciative of the work you did, especially since I did say at the start that modules can define whatever variables they want.

And that's true of most modules. The problem is that "buddy" modules are a special case. When you're using standard forum software, you usually just have a little icon to click on to add a user as a buddy. In forum software, you're either a buddy or you're not. That's how buddylist 1 works. This new generation of "buddy" modules has added all sorts of complications. Now, I'm not knocking the features. I'm sure there's tons of people out there wanting this. But they present a problem for forums. If the site has 20 different ways of making someone your buddy, we don't want those all in a list in the author pane of every forum post.

So there's a few routes we could go here:

  1. Present the list as you have and forgo the icon. Not horrible as long as they don't have too many.
  2. Present an icon/short text and have the link it takes you to show all the options and you choose from there.
  3. Pick one buddy type to use for forums and use the icons/short text as normal.
  4. Icon/short text that uses js to pop up your choice and record them on the spot with no page reload.

As you can guess, I'm not terribly fond of #1 but you're the one writing this so if that's what you want to do so be it. #2 isn't a bad option if it's not hard to do from your end. I haven't tried your code, yet, so I don't know what is even on the page the link takes you to. #3 would be my choice but that could be simply because I'm used to the simpleness of buddylist 1 and other users may find that too restrictive. #4 is my ideal fantasy land choice but, as I don't know javascript, is not going to happen unless you have the skills. :)

So what do you think?

Incidentally, I'm going to change the name of the include file in the next alpha. If you're going to put the code right in the .module that doesn't matter to you. If you're going the include file route, you'll want to add it after the alpha. I've been thinking about advanced profile kit and code duplication and I'm going to try and reuse these hooks for AF as much as I can.

Thanks,

Michelle

alex.k’s picture

No worries, I'm just as stumped as you are on what the optimal way is. @Roulion can you try the function I attached (paste it at the end of user_relationships_api.module), and pitch in with your usecase?

One argument for the sites that have 20 relationship types is they probably have advanced enough themers to hide unneeded ones via css. To me, an acceptable alternative is augmenting one of AF's configuration forms with a choice of a default relationship to use for this integration. Then, the UI remains a single icon. But, the Ajax popup is the cleanest solution, so I'd lean towards getting it right from the start. Even if it takes longer.

michelle’s picture

Well, the ajax popup would be awesome but I don't know any js so I'm totally unable to help with that. If that's something you can handle, though, that's great. :)

Michelle

Roulion’s picture

thanks alex

i test it tonight en tell you...

michelle’s picture

Just to update, I've written up some docs: http://drupal.org/node/326809

Michelle

Roulion’s picture

hi
sorry to be newbie but i can't make your code working

if I call this in my advf-author-pane.tpl.ph file

 $lien = user_relationships_api_preprocess_author_pane($account); 
	<div class="author-pane-icon"> <?php echo $lien; ?></div> 

I get this error message :
Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\mysite\sites\all\modules\user_relationships\user_relationships_api\user_relationships_api.module on line 221

What am i supposed to do in the author-pane ? which is the variable of the function i have to call
i tried $author... no error but no links neither, with $account->uid, $user->uid and $author->uid it's the same

i i try this code
<div class="author-pane-icon"><?php print $user_relationships_api; ?></div>
i get the same error massage as above

Thank for your help

michelle’s picture

@Roulion - Sorry, I wasn't clear. I linked to that page for alex. That isn't something you can stick in the .tpl file.

Michelle

michelle’s picture

Title: Advanced forum integration » Advanced Forum / Advanced Profile Kit integration

Updating the title since this applies to both modules.

Michelle

Apollo610’s picture

Hi guys, just wanted to know if you're closer to plugging User Relationships into AF? I just recently decided to implement UR as my "Friends" module, was hoping to be able to plug it into AF soon.

Thanks-

Manamarak’s picture

Alex, just for the record, I have tried to impliment that code at the end of the file you specified, but it doesn't seem to have any effect. There is no error message, nothing, it is as if I have not added it.
Am I doing something wrong?

michelle’s picture

Status: Active » Fixed

Ok, I fixed up #13 and committed it to the author pane module. The original idea was to have each module keep its own integration but I gave up after 2 months of trying. Taking care of it myself is just easier. It would be lovely, though, if you could let me know if you change anything that breaks your code in there. It's hard for me to maintain the APIs of everyone else's modules.

At this point I don't intend to support the D5 version of UR unless you are willing to make me a D5 version of that file. UR makes my head swim and I'm only getting paid to do the D6 version. ;)

Thanks for the code,

Michelle

alex.k’s picture

Thanks much, Michelle! Since you're using public API functions, there are no big risks of changes being introduced later on.

Status: Fixed » Closed (fixed)

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