Hi!
I would like to use the Affinity module to provide users with friend "recommendations" based on their voting history. Affinity relies on VotingAPI to do its magic which forces me to use a "voting" module like Vote Up/Down, DrupalIt and others.

Flag has proven that it can work really well on a "vote up" scenario and considering everything else, it would make a spectacular base ground for user and content recommendations but I digress... =)

Anyway, my question is: is there any undocumented way make Flag work with VotingAPI or (somewhat far fetched) even replace the Affinity module?

Thanks!
Ricardo

Comments

quicksketch’s picture

Flag has no "hidden" support for VotingAPI or Affinity, but it does have a good number of APIs that could easily integrate Flag with either project. It would be a very simple module to implement hook_flag() and cast a vote through VotingAPI whenever a flag was triggered. However, this would lead to a good amount of redundant data storage, since the vote would be recorded in VotingAPI tables as well as in the flag_content table, so it'd be a bit wasteful in implementation (since you'd also end up doing duplicate queries on retrieval, since each module would query its own tables).

So yes it's possible to do what you've asked, but I don't think it'd be a very efficient way of implementing it.

rbl’s picture

Thanks! =)

This poses a difficult choice.... In your opinion what would be better/easier/or more efficient:
- tweaking/hacking Flag to perform user and node recommendations based on flagging history or;
- implementing VotingAPI? Even though it's resource wasteful it would allow for integration with other VotingAPI based modules for some neat feature combinations.

Ricardo

quicksketch’s picture

It depends on the scale of the website you're working with. It'd definitely be easier to build a flag-votingapi bridge, then put Affinity on top of it.

On a site of any large scale or one you plan on maintaining for a reasonable amount of time I'd recommend sticking with one type of data storage, leaving you two options:
- Build a new Affinity module (or somehow improve the current one) to use the Flag database table directly.
- Build a new VotingAPI-based rating module that looks and works like Flag.

If you're absolutely stuck on using Flag, I think improving the existing Affinity module would be the best approach, but it's probably the most work-intensive. But if you're not stuck on flag, I'd probably just use an existing VotingAPI widget like Vote Up/Down, since that wouldn't require any work at all.

naught101’s picture

I'm (vaguely) interested in this too. Hooking up Flag with User Karma via VotingAPI would allow a slashdot style voting system, where comments can be flagged as "insightful", "funny" or "stupid", and the user's karma would go up/down depending on the value of the flag (+1/-1). I think this probably not possible with existing votingAPI modules.

I imagine that Flag doesn't use the votingAPI specifically because it only deals with +/- numerical voting, right? In that case, such a solution would almost certainly require the duplication of data anyway, wouldn't it? Since you need to store the numerical vote value of the flag, as well as the verbal flag values...

quicksketch’s picture

Status: Active » Closed (fixed)

it only deals with +/- numerical voting, right?

Flag actually does NOT deal with numerical voting at all. It can't even store a "-" value, since it can only record a boolean TRUE if an item has been flagged (and NULL otherwise).

Since you need to store the numerical vote value of the flag, as well as the verbal flag values...

The only way this could be done would be to create 3-4 different flags, one for each verbal value.

Generally I don't think Flag by itself is an adequate solution for the problems posed here. It's not currently possible with Flag core, and it probably won't be possible with just Flag by itself in the future. I'm going to go ahead and close this issue, since I don't want it spinning into a feature request.