I'm writing a simple module that during hook_nodeapi case update, sets the target of the Fivestar CCK widget to match the nid value of a nodereference field in the same node. However, the target is overwritten, no matter what system weight my module and fivestar have, because of the way the $field['php'] value is evaluated.

In fivestar_field.inc on line 47, Fivestar sets $form['php'] #value to 1 if the user viewing the form has the 'use PHP for fivestar target' permission. In fivestar_field(), on case update(when the field is being submitted), when $field['php'] is true, Fivestar evaluates the (empty) target php text area, setting the target to NULL. Then, when if (is_numeric($items[$delta]['target'])) comes back as false, the target is set to the target of the node containing the Fivestar CCK widget. Instead, I think fivestar should check to see if $form['php'] is true and verify that there is in fact some PHP to evaluate before setting the target. That way, I could set it very simply in my own separate module, without entering PHP into the textarea.

If the maintainers think this is a good idea, I'll submit a patch.

CommentFileSizeAuthor
#1 fivestar_target_php.patch341 bytesezra-g

Comments

ezra-g’s picture

StatusFileSize
new341 bytes

This patch resolved the issue for me.

greggles’s picture

Status: Active » Needs review

just fixing status

quicksketch’s picture

Status: Needs review » Fixed

Thanks Ezra! Good idea, this is something that you'd never think of unless you encounter it directly. I used !empty() instead simply because it's what I use more frequently. Committed and will make it into the next version.

Anonymous’s picture

Status: Fixed » Closed (fixed)