? confused.patch
? fivestar_rerole.patch
Index: fivestar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v
retrieving revision 1.2.2.107
diff -u -p -r1.2.2.107 fivestar.module
--- fivestar.module	5 Oct 2008 23:39:09 -0000	1.2.2.107
+++ fivestar.module	9 Oct 2008 20:22:18 -0000
@@ -82,7 +82,7 @@ function fivestar_init() {
  * snippets when configuring fivestar CCK fields.
  */
 function fivestar_perm() {
-  return array('rate content', 'use PHP for fivestar target');
+  return array('rate content', 'use PHP for fivestar target', 'rate on own content', 'always rate on own content');
 }
 
 /**
@@ -115,6 +115,13 @@ function fivestar_form_alter($form_id, &
       '#weight' => -5,
     );
 
+    $form['fivestar']['fivestar_author'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Allow the author to rate his own content'),
+      '#default_value' => variable_get('fivestar_author_'. $form['#node_type']->type, 1),
+      '#weight' => -4,
+    );
+
     $form['fivestar']['fivestar_stars'] = array(
       '#type' => 'select',
       '#title' => t('Number of stars'),
@@ -888,7 +895,21 @@ function fivestar_block($op = 'list', $d
 }
 
 function fivestar_widget_form($node) {
-  return drupal_get_form('fivestar_form_node_'. $node->nid, 'node', $node->nid);
+  // checks whether the current user is the author
+  // if true, then checks if he is allowed to vote, otherwise return static form
+  global $user;
+  if ($user->uid != $node->uid) {
+    return drupal_get_form('fivestar_form_node_'. $node->nid, 'node', $node->nid);
+  }
+  else if (user_access('rate on own content') && variable_get('fivestar_author_'. $node->type, 1)) {
+    return drupal_get_form('fivestar_form_node_'. $node->nid, 'node', $node->nid);
+  }
+  else if (user_access('allow always to rate on own content')) {
+    return drupal_get_form('fivestar_form_node_'. $node->nid, 'node', $node->nid);
+  }
+  else {
+    return fivestar_static('node', $node->nid, $node->type);
+  }
 }
 
 /**
