Integrate with friends module using the Universal Relation API
gausarts - September 27, 2008 - 13:40
| Project: | Profile Privacy |
| Version: | 6.x-1.2 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi,
I'd like to request a feature to integrate your module with friendlist, if you don't mind. The module is in rapid development and the maintainer planned to have more complete features by the end of September. So would you mind taking a look at this: http://drupal.org/project/friendlist. I have requested the friendlist maintainer to integrate with your module as well. Hope you both could kindly put this into consideration.
Thank you very much.

#1
Hi,
I would _love_ to integrate with you. I am Friendlist's author.
Please let me know how to. A piece fo working code, maybe for a different module, would be grand.
I am all ears -- let's do it!
Merc.
#2
Hi,
I just checked the source code for this module and... do you actually allow other modules to return a value to you and decide access according to that value?
Maybe I am just plain blind...
Merc.
#3
Hi,
While talking to the author of CCK Field Privacy, we came up with this: #314170: Plugin architecture for field access permissions + Integration with Friendlist.
It's basically a way to get a plugin architecture to access to fields.
Would you be interested in doing something like that? I'd give you a valid callback in 2 minutes.
Merc.
#4
Hi merc,
I read through your linked issue, I don't think this would be difficult to implement at all. I'm glad to hear that you'd like to put the implementation in your module also, as the current conundrum with buddylist/friendlist/user_relationships makes implementation in this module somewhat difficult to support all the buddylist-like modules out there.
In the example I pulled from the issue:
<?php$all_good=TRUE;
foreach (module_invoke_all('cck_field_privacy_access', $request,$requestee) as $access_result ) {
if(! $access_result){
$all_good=FALSE;
}
}
?>
What are the $request and $requestee variables? My best guesses are the UIDs of the user ($request) and the user requesting access ($requestee). It seems like it would be significantly more helpful if (at the very least) the name of the field were passed along also, or possibly the entire field definition object. Perhaps this is what you meant with your hook. I'd propose the following hook:
<?php/**
* Implementation of hook_profile_privacy_field_access().
*
* @param $field
* The profile field that is being requested for viewing.
* @param $requestee
* The user requesting to view the field, usually the current user.
*/
function mymodule_profile_privacy_field_acces($field, $requestee) {
if (!$something) {
return FALSE;
}
// To match Drupal's node ACL lists, return nothing (NULL) if no preference is stated.
// Returning TRUE would enable access to the field regardless of other modules.
}
?>
#5
Hi,
I think the hook should be completely agnostic about what's been done.
The fields could be called, on your end, $owner and $viewer. So, you call the hook giving it the two parameters.
Now, about field-permissions: I think it's tricky to pass the field name as well. I don't think the friends module should really go as far.
How would the field module be configured? It would have a list of possible fields, and for each one the kind of access...?
Hummm it sounds very complex. cck_field_access simply allows the user to put a "lock" on the fields. The lock means "only friends can see this". Then, it's up to the module to pass the right field through the sieve to see if access is granted or not.
Do you know what I mean?
I think it's saner to just ask the friends module "Is this person OK to see the private fields of this other person?", and then your module should ask this question for the protected fields.
Bye,
Merc.
Merc.
#6
Subscribe. Hey, are there any news about the integration with friendlist?
Bye Franzer.
#7
Hi,
I just wanted to point out that there are now three maintained Friend modules: FriendList, User Relationships and FlagFriend. Now... the best way to go about this, really, would be using the generic API:
http://drupal.org/project/drupal_universal_relation_api
This will cover any module providing friends functionality in Drupal -- I am talking to the FlagFriend maintainer so that FlagFriend uses the API as well.
Changing the title accordingly.
I am here if you need any help!
Merc.
#8
+1 for this
Any news about it?