I´m starting to test the several modules out there that have as a purpose to contactr users between themselves.
I like this module very much so far. And I think it´s easier to implement than UR, and Friend.
Anyway, my profile pages breathes around APK (advanced profile kit and Author Pane, it´s complementary module), and it hasn´t implemented the according compatibility with this module.
I think a lot of folks out there are pretty much in love with APK, as I am, as it allows to have a cool profile without development skills.
So, maybe anyone here could help and implement the .inc file that is needed for this mode to be implemented in APK. I´m sure many, many people will prefer this module before UR (that module HAS been implemented in Author Pane, sigh!).
Please, please, please :)
THANKS!!!!
Rosamunda
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | flag_friend.author-pane.zip | 876 bytes | Witch |
| #17 | templates.zip | 3.77 KB | Witch |
| #3 | flag_friend.avp_.patch | 1.24 KB | sirkitree |
Comments
Comment #1
sirkitree commentedI'm pretty hesitant to implement things into my own modules that are 'required' by other modules. It's bitten me before, even from the other end where one of my modules required things from other modules and I ended up maintaining a bunch of sub-modules just to glue them together. I'm more in favor of modules working together on a higher level with module_implements and preprocessors (which I will gladly throw more of into my modules) than to include files. I doubt you'll see me putting any of them in here unless someone comes up with a very convincing argument for this.
Comment #2
michelle@sirkitree: This is a preprocess function. See http://drupal.org/node/326809 for details. If you don't want to include this in Flag Friend, I can add it to Author Pane. I prefer for modules providing variables to maintain their own code so I don't have to chase after everyone's API changes but I've ended up adding a bunch of them right into Author Pane because the other maintainers just weren't interested in cooperating. :(
Either way, if you have time to provide the functions for getting the links to add/remove friend, that would help as I'm not currently using flag friend. You can probably copy much of the buddylist integration and even reuse the same images.
BTW, all the code on my end is the same for both D5 and D6 so you can reuse the same code for both unless your API has changed.
Thanks,
Michelle
Comment #3
sirkitree commentedLOL.
@Michelle: You got me! It _is_ a preprocess. To tell you the truth, when you posted this in #335912: Integration with Advanced Forum and Advanced Profile Kit I still wasn't very knowledgeable on preprocessors and how to use them. Now that I've gotten to work with them extensively, I see how easy this would be to incorporate. Thank you for calling it to my attention again :)
Please see if this will work with your module.
Comment #4
michelleThat's ok. I'd forgotten I'd even asked.
There's some bad routing near Atlanta that's keeping me from being able to get to my dev sites so I can't test this out tonight unless that gets fixed. :( The only thing I see on a read through is that you don't include a linked image variable. Or does your function already provide an image with the link? I like to provide the themers with both options, if possible, so they can have a linked image, linked text, or both at the same.
Thanks!
Michelle
Comment #5
sirkitree commentedI don't provide any images with my module, so I didn't see a need. Is there? You can mod the patch if you like to do so and I'll throw it in once it's tested.
Comment #6
michelleAuthor Pane has an image set that buddylist / user relationships uses. I'll add that in soon as I can get a chance and update the patch.
Thanks!
Michelle
Comment #7
Rosamunda commentedYes, THANKS!!
Thank you very much indeed!
Gracias :)
Comment #8
michelleOk, I'm probably not going to get to this for a couple days. Pulling this over to my queue since the ball is in my court to work on it and I'm likely to forget it if it's not in my queue. When I have something RTBC, I'll toss it back over to you.
Thanks for your help.
Michelle
Comment #9
michelleOk, I've worked on this a bit. There was a bug in the patch were the $uid needed to be changed to $account_id but, otherwise, this is working fine for the text. Before I can add in icon support, though, I need to get a third icon made. I currently have add buddy and remove buddy but no pending state, which this introduces. Once I have that, I'll add in the icon support and then toss it back over to friend flag.
Michelle
Comment #10
michelleActually... I looked at the code closer and realized I have no clue how to make it work with images. Is there an API function I can use that will take the current user, the account user, and return back 1) whether they are friends/pending and 2) the link to change the friend status?
Tossing it back to Flag Friend's queue so I can get some advice on this.
Thanks,
Michelle
Comment #11
michelleOk, so actually looking at the source helps... Sorry for the bouncing around. When I try programming while distracted by children it ends up a bit messy. :)
Looks like flag_friend_determine_friend_status() gives me the info I need. Pulling it back to my queue. I'll see if I can work on this a bit at nap time.
Michelle
Comment #12
michelleOk, I've made some progress but I'm stuck on how to find the actual URL to link the image to. If I'm understanding correctly, that's somewhere in the bowels of the flag module itself. I need to stop working on this until later this evening. Any help appreciated. :)
Edit: Removed the code paste since it's corrected in the next comment and took up a lot of space.
Comment #13
michelleOk, I got a bit more time to work on this. I ended up hardcoding the paths. This works, but I'd like your review to make sure this isn't a really bad idea for reasons I'm not yet aware of. This code is working based on limited testing so far. I'd like someone else to try it and review it. For now, I'm using the remove friend icon for the pending friend.
Thanks,
Michelle
Comment #14
Witch commentedI want to test the code, where does i have to add this?
Comment #15
michelleIt goes in flag_friend.author-pane.inc which goes in flag_friend module directory. Or in author pane's "modules" directory. Either will work. Don't forget to add the variable(s) to the template as well.
Michelle
Comment #16
Rosamunda commentedThanks for your amazing hard work Michelle!!!!!!
Comment #17
Witch commentedHi Michelle, i created the file "flag_friend.author-pane.inc" (attachment) which went in pane's "modules" directory.
I didn't unterstand correctly what you mean with "Don't forget to add the variable(s) to the template as well." Do you talk about the template file of my litejazz theme? I dont know where to add the variables exactly. it would be great to get some help. i know that you have not much time... i am very sorry but it would be very nice to get this solved. i will attach my template file. i hope you can give me some help.
Comment #18
michelle@Buffer2k: I meant add it to the Author Pane template you are using. Either author-pane.tpl.php, advf-author-pane.tpl.php, or advanced_profile-author-pane.tpl.php, depending on how you are using Author Pane.
Michelle
Comment #19
Witch commentedouhhh....
after trying a lot i got the "Add me" button in the author pane. but i know that my solution is very very bad.
i added the following code in author-pane.tpl.php
In this case i can add myself as a friend :\ furthermore the button appears even when you already added the user....
oh my god, i am not good in code. hope that there is someone who can post the correct code.
Comment #20
michelle@Buffer2k: Erm.. that's totally off. This is what you need:
Link:
Icon:
Michelle
Comment #21
Witch commentedHey Michelle it works very fine! Thanks a lot!
When i start a friend request and try to remove the reuquest by clicking on the icon, the request still exist. thats the only thing i noticed.
thank you michelle. slowly i understand how drupal code works....i used many years phpnuke but thats another theme...
Comment #22
michelleDoes the same thing still happen if you use the link instead of the icon? Maybe I got the path wrong.
Any input, sirkitree?
Michelle
Comment #23
sirkitree commentedIf you dsm($flag) you'll see that the text for the flag and unflag action is housed there and can be referenced like so:
$flag->flag_short: Add friend$flag->unflag_short: Remove friendAlso, (and I know I've not explained this very well) but the statuses returned by flag_friend_determine_friend_status() are being used incorrectly.
FLAG_FRIEND_FLAGGED means that two users are friends. There are now no flags and there is just the relationship stored in the flag_friends table. This means that we cannot use flag's 'unflag' functionality, but must use our own. This is why I created the 'unfriend' action. This simply means that when this status is returned, we have to use a different url in order to remove the relationship. You've used this one correctly.
FLAG_FRIEND_BOTH should NEVER be returned to this function. As soon as this status is detected within hook_flag(), which is as soon as you've approved a friend, both flags are removed and the relationship is recorded into the flag_friend table, essentially changing the status to FLAG_FRIEND_FLAGGED. So I've removed this case from the code.
FLAG_FRIEND_UNFLAGGED is used correctly.
FLAG_FRIEND_PENDING is when you have flagged someone else. You are not flagged, but they are. So when you look at another user's profile and get this status you are still seeing a regular flag and should see something that allows you to 'unflag' the user, not 'unfriend' them; you will be using normal flag operations instead of our additional one. I've changed the hardcoded link from "flag/confirm/unfriend/friend/$account_id" to "flag/confirm/unflag/friend/$account_id".
FLAG_FRIEND_APPROVAL is the opposite of FLAG_FRIEND_PENDING. So here someone else has flagged you and you want so Approve that relationship. This is where you, Michelle, or whomever else really wants this functionality, needs to make the decision of whether you want this to look the same as when you are not flagged already (Add as friend) or if you want to indicate to the user that you have been flagged by this user you are viewing and you are not only adding them as a friend, but approving the relationship (Approve as friend). I actually vote for the former as I'm not sure it needs to be indicated on the profile that the other person has flagged you, or requested your friendship. For the former case, you would want to group FLAG_FRIEND_APPROVAL with FLAG_FRIEND_UNFLAGGED. For the latter case, you would want to add a completely separate case for FLAG_FRIEND_APPROVAL and provide a different classname and or image. The link would remain the same. I've reflected the former case in my edit.
So something like this:
Thanks, and great work so far! I hope I've helped you understand the different statuses and will try to get this all into documentation.
Comment #24
michelleHey, I didn't do too bad considering I've never used either flag or flag friend and just installed them for this issue. LOL!
Ok, I understand everything except the approval/pending bit is making my head spin. If the logged in user is looking at the author pane of someone that has flagged them but they (the logged in user) have not done any sort of friending, then I think they should just get the add friend icon. I don't think we need any special icon for that. Does that mesh with what you're saying up there? It seems to, looking at the code, but I'm not 100% sure.
So it looks like the text just needs to be changed to use what's in the flag object. I'll try to do that later tonight unless someone else jumps in and does it. I'm feeling pretty sick today and have some client work that needs to get done so I can't do it right now.
Michelle
Comment #25
sirkitree commentedYes, the code reflects both things. I've put the $flag->flag_short and $flag->unflag_short in already.
The one that is still hardcoded needs to be, as it is this way within Flag Friend module. Maybe this can be a setting somewhere at some point.
The code above should be good to go, just needs tested.
Comment #26
michelleAh, I see, you added it to the link title just not the image ones. Not sure if that matters... If you link an image and the image isn't there, does the link title win out?
I'll give it a whirl on my dev site later tonight but it would be great if Rosamunda would test it as well. Since I don't actually use flag friend, I don't have any real data to test it with.
Thanks!
I'll get the variables added into AP/AF/APK as well.
Michelle
Comment #27
michelleI'm drawing a blank on whether I tested this or not. Did anyone else test it? Rosamunda: it was your request... Would be great if you would test it.
I'm adding the variables to my modules tonight since I'm trying to get those finished up.
Michelle
Comment #28
sirkitree commentedAny further progress on this? I want to put up a beta release and will include this if someone can test it in the next day or so.
Comment #29
michelleWell, it would have been great if the person requesting it had tested it since I don't actually use this module. But I hate to bail on it since we got it this far so I'll try to give it a good test tonight.
Michelle
Comment #30
michelleSorry, didn't get to it last night. But I just tested #23 now and it seems to be working just fine. So, from here, either:
1) Stick that code in flag_friend.author-pane.inc and put it at the root of flag_friend and have it loaded by AP automatically.
2) Stick the function somewhere else in flag friend that you know will get loaded.
3) Put it in AP.
I'd prefer 1 or 2 because you are in a better position than me to make changes to it if you change flag_friend. The odds of me changing anything in AP that will affect this are extremely slim and I will file a patch if that happens.
Thanks!
Michelle
Comment #31
sirkitree commentedThanks Michelle!
I will probably just add it to the .module since it's a preprocessor.
Comment #32
michelleOk, sounds good.
Thanks,
Michelle
Comment #33
sirkitree commentedcommitted: http://drupal.org/cvs?commit=186974
Comment #34
michelleAwesome, thanks!
Michelle
Comment #36
mrjavum commentedBut if anonymous user has access to view user profiles?
Only overriding hook_preprocess_author_pane in custom module helps?
Comment #37
michelle@mrjavum: Why would you want anonymous users seeing it? There's no way an anonymous user can use this. But, yes, if you really want anonymous users seeing it you'd need to use your own preprocess, duplicate the code, and take out that
$account_id != 0part.Michelle
Comment #38
mrjavum commentedFor example:
http://socnet.shellmultimedia.com/user/1
I can see profile without registration :)
Comment #39
michelle@mrjavum: I'd certainly hope so. Wouldn't be a very good demo site for the module if you had to log in. If there's a point here, I'm missing it.
Michelle