Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
this is the scenario:
I mantain music community site. We are going to have two main roles for our registered user - musician and user. Then we are going to have two types of relations - friend and fan. And now - user role can create one way fan relationships with musicians as well as two-way friend relationships with other users. However, musicians are not allowed to create two-way relationships between each other.
Is this doable using your module?
Thanks,
Petiar.
Comment | File | Size | Author |
---|---|---|---|
#24 | user_relationships-roles_receive_20100227.patch | 8.6 KB | john.money |
#11 | user_relationships-327624.2.patch | 19.49 KB | Manuel Garcia |
#9 | user_relationships-327624.1.patch | 19.18 KB | Manuel Garcia |
#5 | user_relationships-327624.patch | 19.19 KB | Manuel Garcia |
relations.PNG | 4.13 KB | petiar |
Comments
Comment #1
alex.k CreditAttribution: alex.k commentedYes it's doable with additional code work. Right now all relationship types are accessible to everyone. This would need an admin setting with a kind of a matrix allowing certain types for certain roles. I've been wanting to do this feature, but so far it has not been great priority. Any development help would be great, and would move this forward, though.
Comment #2
petiar CreditAttribution: petiar commentedThanks for the update. I might be able to have a look into the code and check what could I do but I can't promise any effort as I am not very familiar with coding for Drupal yet. But maybe this could be the way how to move forward. ;-) We'll see...
Comment #3
Manuel Garcia CreditAttribution: Manuel Garcia commentedOK I'm switching this to a feature request for dev, and changing the title accordingly.
I think the basic idea would be the same as #228206: Different types of relationships per role type, only that feature (already in) is to configure what roles can request the relationship. This is the other way around, what roles can receive the relationship.
I assume this could be doable in an extra module, through
hook_user_relationships_type($op, &$relationship_type)
, but I think user_relationships would gain a ton of flexibility with this in it.I'd be willing to look into it, but I'm new to the api and would need a bit of guidance as to how to go about doing it...
Comment #4
alex.k CreditAttribution: alex.k commentedWould appreciate you taking it on. You are right, I think the implementation will be similar to the issue you quoted. If you look at the commit (http://drupal.org/cvs?commit=176372 unfortunately it fixes several issues at once, so it's hard to tease apart):
* most changes revolve around a new function user_relationships_api_can_request http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/user_relati...
* an addition to user_relationships_types_load http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/user_relati... that loads the permissions.
* data is stored in a new table user_relationship_type_roles. I would suggest creating a similar new table to keep the impl simple.
* one example of one check in the code for the permission would be http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/user_relati...
Comment #5
Manuel Garcia CreditAttribution: Manuel Garcia commentedThanks alex.k for the info =)
I went ahead and spent a couple of hours on this, and here's a patch that I think is already working, at least as far as I have tested it. Hopefuly it will work nicely with the other permission settings for roles etc.
The patch unfortunately came out with some cruft I guess coming from my editor... sorry if it's a bit hard to read :X
Comment #6
Bilmar CreditAttribution: Bilmar commentedHello,
Thank you for this patch! This is exactly what I have been looking for!
I used terminal to patch but received 2 errors (seen below).
Also got error messages in drupal pasted below.
Are you or others also experiencing the same errors?
adhoc:untitled Franky$ patch -p0 < user_relationships-327624.patch
patching file user_relationships_api/user_relationships_api.api.inc
patching file user_relationships_api/user_relationships_api.install
patching file user_relationships_ui/user_relationships_ui.actions.inc
patching file user_relationships_ui/user_relationships_ui.admin.inc
patching file user_relationships_ui/user_relationships_ui.admin_actions.inc
patching file user_relationships_ui/user_relationships_ui.module
Hunk #2 FAILED at 44.
Hunk #3 succeeded at 69 (offset -4 lines).
Hunk #4 succeeded at 245 (offset -4 lines).
Hunk #5 succeeded at 304 with fuzz 1 (offset -4 lines).
Hunk #6 succeeded at 378 (offset -4 lines).
Hunk #7 succeeded at 680 (offset -4 lines).
Hunk #8 FAILED at 810.
2 out of 8 hunks FAILED -- saving rejects to file user_relationships_ui/user_relationships_ui.module.rej
Drupal error=>
* user warning: Table 'drupal.user_relationship_type_roles_receive' doesn't exist query: SELECT rtid, rid FROM user_relationship_type_roles_receive ORDER BY rtid, rid in /f1/content/example/public/sites/all/modules/user_relationships/user_relationships_api/user_relationships_api.api.inc on line 88.
* user warning: Table 'drupal.user_relationship_type_roles_receive' doesn't exist query: SELECT rtid, rid FROM user_relationship_type_roles_receive ORDER BY rtid, rid in /f1/content/example/public/sites/all/modules/user_relationships/user_relationships_api/user_relationships_api.api.inc on line 88.
Comment #7
Manuel Garcia CreditAttribution: Manuel Garcia commentedWhat version of the module are you patching?
I tried the patch with the latest dev release, from the module directory, run:
I get no errors. Make sure you are using the lates dev release, and you are runing the patch command from the module's directory.
ALSO: MAKE SURE TO RUN UPDATE.PHP AFTER APPLYING THE PATCH!
Comment #8
Bilmar CreditAttribution: Bilmar commentedThank you Manuel Garcia - I was able to successfully patch the module.
I spent 3 hours testing the patched module but was unable request relationship:
Setting-
Role A is allowed to request Friend relationship
Role B is allowed to receive Friend relationship
As user with Role A I try to request friend relationship to user with Role B, but getting "You may not create any more relationships to this user." when request link is clicked. Both Role A and Role B do not have any relationship to one another or any other user.
Is there additional steps necessary for this patch to work that I am overlooking?
Thanks for your support!
Comment #9
Manuel Garcia CreditAttribution: Manuel Garcia commentedThanks for reviewing the patch trupal218 =)
I've found a problem that is now fixed. The links to apply for the relationship with the user are now showing up properly.
However, I'm getting an error that I have no idea where it's coming from,
You may not create any more relationships to this user.
when trying to request a relationship. Very weird.I've revised all the changes I'm making, and realy can't find what's going wrong. Perhaps the module maintainer can review it and figure out what's going on...
Comment #10
Bilmar CreditAttribution: Bilmar commentedI am still getting the same message as well.
I think this addition will allow great flexibility for the module and I would be at the front of the line to test your patch my current site as well as on a fresh Drupal install for any future versions of the patch to give you feedback.
I hope someone will be able to take a look and comment on the issue.
Thanks!
Comment #11
Manuel Garcia CreditAttribution: Manuel Garcia commentedOK, new day, new ideas and new hope! (lol)
I think I finally got it working, problem was that the user_relationships_api_can_receive function was getting just a UID for the $requestee, and I was not validating against that to load the user if it was the case. Hence it was returning false. So now it's validating all arguments in that function properly, and should work just fine.
Note that I've only tested this with just the api and ui modules enabled, and not with all combinations, so testing would be nice from you guys =)
Let me know how it goes!
Comment #12
Bilmar CreditAttribution: Bilmar commentedAwesome! I have tested your latest patch with multiple roles/users and on a Drupal fresh install as well as my current website. It looks to be working perfectly testing from end-user =D
Comment #13
Manuel Garcia CreditAttribution: Manuel Garcia commentedGreat, thanks again for testing trupal218 =)
Can we get this commited?
Comment #14
Bilmar CreditAttribution: Bilmar commentedHi Manuel Garcia,
If your schedule allows, could you please take a look at feature request I raised at http://drupal.org/node/598938
I hope others will be able to test your patch soon =)
Thanks!
Comment #15
pritch20001 CreditAttribution: pritch20001 commentedHi, this looks great, is it going to be added to the module?
Comment #16
alex.k CreditAttribution: alex.k commentedYep, absolutely. I totally appreciate the patch. I'd like to put out another RC and then hopefully 1.0 before adding new features. Or else we'll never get to a stable release. That's the reason there are a few patches already waiting to be included.
Comment #17
skizzo CreditAttribution: skizzo commentedJust installed latest User Relationships dev (6.x-1.x-dev 2009-11-09)
Unfortunately the patch user_relationships-327624.2 does not apply cleanly.
I would really appreciate if someone can bring it in line with the latest dev. Thx.
Comment #18
Manuel Garcia CreditAttribution: Manuel Garcia commentedI will bring it up to date when there is intention of actualy commiting it.
So far the maintainer wants to keep new features in stand by until they get a stable release out unfortunately.
Comment #19
hellomobe CreditAttribution: hellomobe commentedWould love to see this implemented...any updates on status?
edit: I added the patch by hand to the user_relationships-6.x-1.0-rc3 version. Works great -- I just had to change the database update to 6103 not to conflict with the 1602 update. thank you Manuel!
Comment #20
hellomobe CreditAttribution: hellomobe commentedManuel - this really is fabulous. Thank you. I have found a need to allow authenticated users to receive relationship 'A', but not allow a vendor (who by default is also an authenticated user) to receive relationship 'A'. Is there a way to add this additional level of filtering?
Comment #21
fehin CreditAttribution: fehin commentedWould also love to have this patch in 5x. Can someone please help? Thanks.
Comment #22
Manuel Garcia CreditAttribution: Manuel Garcia commented@hellomobe: Nope, since both users have the same role assigned, they get the same settings. Only way around that is to assign every user a role when they register, and then use that for the relationship A.
See http://drupal.org/project/autoassignrole
@fehin: Sorry, but no. You should really consider upgrading to d6, as d5 will soon be go to not supported when d7 comes out.
Comment #23
YK85 CreditAttribution: YK85 commented+1 subscribing - any chance of seeing this patch added to User Relationships core module as a stable release was available after this patch was put on hold?
Sounds like a very cool feature and great work Manuel Garcia!
Comment #24
john.money CreditAttribution: john.money commentedPatch #11 rerolled against 6.x-1.x-dev (2010-Feb-23). All credit goes to Manuel Garcia for the patch -- I only updated so it applies cleanly.
Don't forget to run update.php after applying patch.
Comment #25
YK85 CreditAttribution: YK85 commentedthanks for continuing Manuel Garcia's great work!
tested and works perfectly!
can the maintainer of UR please let us know if there is a chance of seeing this in the next dev =)
thanks!
Comment #26
robby.smith CreditAttribution: robby.smith commentedi had the opportunity to test the patch and it looks good
thanks for the original patch and the re-roll!
+1 for commit
Comment #27
Hoeven CreditAttribution: Hoeven commentedHello, when will an update to User Relationship module include this feature?
Thanks,
Egon
Comment #28
alex.k CreditAttribution: alex.k commentedCommitted in http://drupal.org/cvs?commit=366732. Thanks to Manuel Garcia, John Money, and testers.
Comment #29
Manuel Garcia CreditAttribution: Manuel Garcia commentedawesome news alex.k -> Thanks!
Comment #30
Bilmar CreditAttribution: Bilmar commentedawesome, thanks to all!