Closed (fixed)
Project:
User Relationships
Version:
6.x-1.0-beta9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
10 Oct 2008 at 23:23 UTC
Updated:
17 Aug 2009 at 18:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
alex.k commentedI will look at it tomorrow, I hope, as I don't know this off-hand. Something involving drupal_get_form, i suspect...
Comment #2
alex.k commentedAlso, have you looked at #319104: how to implement 'one click friend request' for ideas.
Comment #3
Flying Drupalist commentedThanks, I've seen it, but I'm not a coder, so I don't actually know how to adapt his solution.
Comment #4
alex.k commentedAttached are the snippets since I can't paste html inline.
You need to replace "3" with the id of your relationship type.
Let me know how it works.
Comment #5
Flying Drupalist commentedThank you so much, this works atm, but may I make 2 requests?
Can the buttons be standard links instead, for easier theming, and a variation for 1 - way fan adds. Simply changing it to my second type of relationship type didn't work.
Comment #6
Roulion commentedHi the snppet is working good on comments. However, the request is sent to annonymous instead of comment's author, which is actually quite buggy :p
It would be good to add a "remove relationship" form as well, if there is already a relation between the user and the comment's author.
PS : I tested it on drupal 6.5
Comment #7
Roulion commentedI just make a little modification to the comment snippet :
you can add or remove relations depending if it's already created or not.
I also make the form appaear as an image
Comment #8
alex.k commentedThank you, @Roulion
Comment #9
unxposed commentedWhat would I need to change to the snippet above to get the add / remove buttons working on the user profile pages?
Thanks!
Comment #10
alex.k commented@unxposed user_relationships_ui already places all action links onto the user profile, do you have them? See attached for the standard UI. This issue is for comments/nodes, where normally the links are not displayed.
Comment #11
unxposed commentedHi Alex,
Yes I've got those coming up (another issue, but I need to remove them form the main page).
My situation is that I basically want two contextual buttons in the user profile sidebar, I guess in a block, one which says 'add as a friend' when you don't have a relationship with the profile you're looking at, or if you do, a button should appear saying 'delete from friends'... ideally they would be single clicks, no confirmation. What would be the best way of doing this? I thought this post was kind of along the right lines?
Comment #12
alex.k commentedThat's a little clearer. I think one of the blocks in user_relationship_blocks.module is an 'actions' block. So I want to fix the bugs in #257198: Return the user id of the user to compare with the current user which will probably take care of your request.
As to doing it in one click, a number of users have asked for it, but currently UR's workflow is to always confirm, if the standard links are used. The only way to subvert it is to use submit buttons and a form, like the snippet above.
Comment #13
unxposed commentedOkay cool, I'll see if I can style this as desired.
Where is the copy such as 'You have sent a new Friend request to this user' and the html for this being generated out of interest?
Thanks
Comment #14
alex.k commentedThis is
function _user_relationships_ui_actions_between(&$viewer, &$viewed) {in user_relationships_ui.moduleComment #15
unxposed commentedBrilliant, thanks again.
Comment #16
Flying Drupalist commentedHi, how do you edit this so that anon users don't show a add to friend link. Thanks.
Comment #17
alex.k commentedAt the top of the snippet, you just need to add
&& $comment->uid, so it will look like this:This will work for both my and Roulion's versions. Sorry about not adding it right away.
Comment #18
Flying Drupalist commentedThanks, works great.
Comment #19
unxposed commentedOkay, still trying to work out how to change the class so it's different on the status of the relationship, 1. none, 2. pending 3.friends - doesn't matter what it's called so long as they're different so I can add unique icons... I keep trying different variables but without any luck
Any ideas on what might work?
Thanks
Comment #20
alex.k commented@unxposed there isn't a way to tag individual links based on their status. Could you patch the functions in user_relationships_ui the way you want it, and submit a patch? The two functions are the one you used, plus
_user_relationships_ui_between($viewer, $account). This would help a lot.Comment #21
ascetic commentedthanks for the great snippets,
what should we do to return the submit button to an AJAX confirmation dialog which is integrated on the latest beta9 release?
Comment #22
unxposed commentedHi, sorry. I don't fully understand... there is no variable that gives one value if you are in a relationship with the user you are viewing, and another if not?... isn't one needed to determine whether or not to add the relevent action link on the user page?
I have no idea how to create a patch (plus I'm not sure you're prepared for the damage I've done to your nice code)... but once I'm done I can email you the files if it will help you at all?
Comment #24
Flying Drupalist commentedHas this stopped working?
I did this in node.tpl.php:
print url(NULL, array('query' => drupal_get_destination())); ">It takes me to ?destination=node%2F163
Rather than the node I was viewing, and no friend request either.
Comment #25
alex.k commentedCould you confirm you are using the same snippet as in comment #4, plus correction in #17. In what you pasted there is no < form>...
Have you changed anything else, or updated user_relationships code?
Comment #26
Flying Drupalist commentedAhh I should update what I'm using now.
Oh the form, I am using what's in #4, I think the d.o input filters probably stripped out the form I tried to paste. But yes it's #4.
[form method="post" action="
print url(NULL, array('query' => drupal_get_destination()));">[input type="submit" name="add_submit_1" value="add as friend" id="add_submit">
[/form>
The form looks like this.
Comment #27
alex.k commentedI've just tried the code from #4, it worked, no changes. This is using the latest -dev code, but i don't remember that it's different from -beta9. I've tried both a two-way, no approval relationship, and a one-way, approval required relationship. So, something else must have changed in your setup :(
Comment #28
Rosamunda commentedsubscribing
Comment #29
alex.k commentedComment #30
alex.k commentedPlease reopen if problem reoccurs.
Comment #33
cincy_kid commentedI know this is a slightly different issue, but since it was mentioned earlier in this thread by unxposed, i thought I would ask here..
I have been looking through the user_relationships_ui.module (and various others) at the different functions trying to figure out what code i need to extract to be able do a conditional statement on the user profile page.
the part that basically says:
if user is not already your friend{
print "add to friends"
else
print "remove from friends"
}
I have a user-profile.tpl.php file where I need to put this code into. Currently it just shows the "add to friends" link because thats the only part I have in. It looks like:
So I need to put in a conditional to show "Remove From Friends" if they are already a Friend...
Comment #34
andrenoronha commentedsubscribing
Comment #35
andrenoronha commentedI have this code outputting the link to add or remove a friend:
I tried changing the ul to a div tag because I already have an ul outside it. it works fine in FF but not on IE. It gives me a bug in the css.... the right column goes downward.
i dont know what's happening...
How can I changed it to just a li item?
Comment #36
andrenoronha commentedok nevermind
i got it by using this function
http://www.justin-cook.com/wp/2006/03/31/php-parse-a-string-between-two-...
now it just prints what's in between