Hi,

Looking at http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/friendlist/... , I noticed that FriednList is using the SocNet API *internally*. Internally, the module shuld use its own internal functions. Socnet's functions are there as an external interface to other modules.

Bye,

Merc.

Comments

irakli’s picture

Can you explain why should there be an "internal" API and "external" API?

mercmobily’s picture

Hi,

The module has a set of functions it uses *throughout* itself to accomplish tasks.
The universal API is designed to be hook-based, and it's there to allow other modules to query *every* friend-like module about friends and relations. They are different, they have different purposes.
Short list -- but it could be longer:

* Performance. Bu calling the external API, you are actually calling out for any module implementing the socnet API -- Friendlist is basically calling itself, but at the expense of performance

* Disasters will happen if there are two Friends APIs. Yes, this is uncommon, but still

* The Socnet API is designed to work on relation names rather than IDs, to be... universal. If used extensively (which would be wrong), it would then need to use Friendlist's own function to reverse lookup thse types -- and then *hope* that you are taling about a relation type belonging to FriendList.

* It's just plain wrong. The module has its implementation on how to do things. Using an external interface layer for internal use just doesn't make sense.

Bye,

Merc.

mercmobily’s picture

Hi,

In general, different APIs are designed for different purposes. The socnet API was designed as a set of common functions between Friends modules to export functionalities. The internal API is the module's core. That's the basic reasonl without delving into the "implications" of these reasons.

Bye,

Merc.

mercmobily’s picture

Hi,

You added this function in the module:

function friendlist_api_socnet_mutual_friends($uid1, $uid2, $rtid=NULL, $limit = 5)

Socnet is a predefined API... adding functions to it requires interaction with alex.k in order to get a new function added to it.

The socnet API already had a function for that:

function hook_socnet_get_related_users($uid, $relation_name = NULL, $relation_style='all') {};

Bye,

Merc.

mercmobily’s picture

Hi,

I fixed this issue in my latest big commit.
In that commit, I also rewrote the blocks system to include the improvements submitted and generally went through everything.

It's a big commit. I explained by email why I felt the code review was much needed -- I would rather keep it between the two of us.

Thank you for helping out!

Merc.

mercmobily’s picture

Status: Active » Fixed
mercmobily’s picture

Status: Fixed » Closed (fixed)