I honestly don't like php in databases also it makes for crappy deployment.

I say replace it with a better implementation maybe a hook_fivestar_field_targets

Also we can provide some nice defaults like we already do with the comments.

Comments

ericduran’s picture

StatusFileSize
new8.2 KB

This is killing me, trying to come up with a good solutions.

This isn't by any means complete but uploading this patch here so I wont loose it.

ericduran’s picture

chx mention adding support for http://drupal.org/project/relation

james.elliott’s picture

The problem I'm running into when trying to solve this issue is that different entities have different primary keys to identify them. If you are rating a user you need $entity->uid and if you are rating a node you need $entity->nid and if you are rating a file you need $entity->fid, etc.

This is currently blocking my progress with #1198128: Convert fivestar/node_type pairings into fivestar field widgets

james.elliott’s picture

Status: Active » Needs review
StatusFileSize
new4.41 KB

This may not be something better for target selection. However, what it does is to make fivestar fields default to voting on the entity to which they are attached.

It also allows you to vote on entities that are not nodes. Which I suppose is an improvement. So perhaps better target selection does apply.

james.elliott’s picture

I took a closer look at your first patch here, and I agree that it is the way to go. I rerolled your patch with some tweaks. It appears to work beautifully. But it revealed to me another issue.

I think that perhaps the voting target should be instance specific. This is due to the fact that the same field can be attached to multiple instances.

Here is the scenario:

  1. I attach field_fivestar to comments on a specific content type and set it to target "Parent Node".
  2. I attach the same field_fivestar to the content type itself and set it to target "Self"

I would expect that setting a vote in either location would cast a vote on the node. However, because the target is field and not instance specific, what I've done in step 2 is to retarget the comment votes at "Self".

I think that the best solution would be to change the voting target to be an instance setting in #1198128: Convert fivestar/node_type pairings into fivestar field widgets

ericduran’s picture

Hey James,

You are right, the voting target should be instance specific. We should turn that into it's own little patch that can be the 1st in our serious of patches.

I know is a hassle to separate them out. But this is the easiest way to make sure we don't break any functionality as we start migrating to fields.

Once we have the target option on the instance settings, we can work on this issue, then we can apply the access changes and last but not least we can move the fivestar_voting to field settings.

I know this seems like a hassle but at the same time we can't break fivestar between branches.

Again, Thanks so much for all your work on this.

james.elliott’s picture

I took your advice and have created separate patches that followed your order of updates.

  1. #1205166: Field settings should be instance specific
  2. #1173814: Replace php target selection with something better this issue
  3. #1204350: fivestar_field_settings_form incorrectly sets the default value for stars
  4. #1203428: Better Fivestar access check for the exposed field
  5. #1198128: Convert fivestar/node_type pairings into fivestar field widgets

The patch for this issue does the following:

  • Added a fivestar_get_targets function
  • Implemented hook_fivestar_target_info for fivestar. This enables the "Self", "Reference node", and "Comment" options where applicable
  • Added callbacks for each of the previously mentioned target options
  • Replaced the PHP target section with the simple dropdown that reveals options described in hook_fivestar_target_info
  • Altered _fivestar_field_helper and _fivestar_field_target to accommodate the new method of target selection. This enables voting on any entity type a field is attached to, not just nodes.
james.elliott’s picture

Latest patch is attached

ericduran’s picture

Priority: Normal » Critical

Next patch to go in..... Working on this now.

ericduran’s picture

StatusFileSize
new10.87 KB

Patch above no longer applies.

Re-rolled. Attached, also this needs work, the target is only allowed to be a int, yet we're setting 'text' of self, so it throws a db exception

ericduran’s picture

StatusFileSize
new10.87 KB

Patch above no longer applies.

Re-rolled. Attached, also this needs work, the target is only allowed to be a int, yet we're setting 'text' of self, so it throws a db exception

ericduran’s picture

Here's an updated patch.

I removed the fivestar_update_7003 update because not every option with a target needs to be self. This will be more clear when we separate the widgets out.

But the target is only needed when voting with voting api. If you're using the fivestar widget only as a cck field you don't need any of that. It'll be a lot simple to differentiate between both use case once we separate out the fields which I'm hoping to get through today

ericduran’s picture

StatusFileSize
new10.24 KB

Forgot the patch.

ericduran’s picture

Status: Needs review » Fixed

Trying to tackle all these patches so we can clean up the two widgets.

--
http://drupalcode.org/project/fivestar.git/commit/8e265f6e7f82737f36cad1...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.