Index: vud.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/Attic/vud.install,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 vud.install
--- vud.install	16 Aug 2009 19:22:05 -0000	1.1.2.5
+++ vud.install	7 May 2010 20:46:07 -0000
@@ -17,7 +17,41 @@ function vud_install() {
  * Implementation of hook_schema().
  */
 function vud_schema() {
-  return array();
+  $schema = array();
+
+  $schema['vud_status'] = array(
+    'fields' => array(
+      'vudid' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'type' => array(
+        'type' => 'varchar',
+        'length' => '32',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'content_id' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'status' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'primary key' => array('vudid'),
+    'unique keys' => array(
+      'vudid_type_content_id' => array('vudid', 'type', 'content_id'),
+    ),
+  );
+
+  return $schema;
 }
 
 /**
Index: vud.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/Attic/vud.module,v
retrieving revision 1.1.2.25
diff -u -p -r1.1.2.25 vud.module
--- vud.module	23 Apr 2010 05:10:16 -0000	1.1.2.25
+++ vud.module	7 May 2010 20:46:07 -0000
@@ -159,3 +159,30 @@ function vud_ctools_plugin_directory($mo
     return $plugin;
   }
 }
+
+/**
+ * Helper function to get status for a piece of content.
+ */
+function vud_status_get($type, $content_id) {
+  return (int) db_result(db_query("SELECT status FROM {vud_status} WHERE type = '%s' AND content_id = %d", $type, $content_id));
+}
+
+/**
+ * Helper function to save status for a piece of content.
+ */
+function vud_status_save($type, $content_id, $status) {
+  db_query("SELECT status FROM {vud_status} WHERE type = '%s' AND content_id = %d", $type, $content_id);
+  if (db_affected_rows() > 0) {
+    db_query("UPDATE {vud_status} SET status = %d WHERE type = '%s' AND content_id = %d", $status, $type, $content_id);
+  }
+  else {
+    db_query("INSERT INTO {vud_status} (type, content_id, status) VALUES ('%s', %d, %d)", $type, $content_id, $status);
+  }
+}
+
+/**
+ * Helper function to delete status for a piece of content.
+ */
+function vud_status_delete($type, $content_id) {
+  db_query("DELETE FROM {vud_status} WHERE type = '%s' AND content_id = %d", $type, $content_id);
+}
Index: vud_node/vud_node.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud_node/Attic/vud_node.install,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 vud_node.install
--- vud_node/vud_node.install	15 Jan 2010 02:36:29 -0000	1.1.2.4
+++ vud_node/vud_node.install	7 May 2010 20:46:07 -0000
@@ -31,6 +31,7 @@ function vud_node_uninstall() {
   variable_del('vud_node_votes');
   variable_del('vud_node_reset');
   variable_del('vud_node_widget_vote_on_teaser');
+  variable_del('vud_node_per_node');
 }
 
 /**
Index: vud_node/vud_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud_node/Attic/vud_node.module,v
retrieving revision 1.1.2.30
diff -u -p -r1.1.2.30 vud_node.module
--- vud_node/vud_node.module	1 May 2010 08:18:23 -0000	1.1.2.30
+++ vud_node/vud_node.module	7 May 2010 20:46:08 -0000
@@ -70,6 +70,12 @@ function vud_node_admin_settings() {
     '#default_value' => variable_get('vud_node_types', array()),
     '#options'       => node_get_types('names'),
   );
+  $form['vud_node_per_node'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Toggle on/off per node'),
+    '#description' => t('Check this if it should be possible to turn off voting on a per node basis.'),
+    '#default_value' => variable_get('vud_node_per_node', FALSE),
+  );
   $form['vud_node_widget'] = array(
     '#title'         => t('Widget selection'),
     '#description'   => t('Select the voting widget theme that will be displayed.'),
@@ -111,17 +117,28 @@ return system_settings_form($form);
  * Implementation of hook_nodeapi().
  */
 function vud_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  switch ($op) {
-    case 'view':
-      if (($can_edit=user_access('use vote up/down on nodes')) || user_access('view vote up/down count on nodes')) {
-        $node_type = in_array($node->type, variable_get('vud_node_types', array()), TRUE);
-        $widget_showmode = variable_get('vud_node_widget_show', VUD_NODE_DISPLAY_BOTH);
-        $tag = variable_get('vud_tag', 'vote');
-        $widget = variable_get('vud_node_widget', 'plain');
-        $vote_on_teaser = (bool)variable_get('vud_node_widget_vote_on_teaser', TRUE);
-        $teaser = $a3;
+  if (vud_node_is_valid_node($node)) {
+    switch ($op) {
+      case 'insert':
+      case 'update':
+        vud_status_save('node', $node->nid, $node->vud_status);
+        break;
+
+      case 'delete':
+        vud_status_delete('node', $node->nid);
+        break;
 
-        if ($node_type) {
+      case 'load':
+        $node->vud_status = vud_status_get('node', $node->nid);
+        break;
+
+      case 'view':
+        if (vud_status_get('node', $node->nid) && (($can_edit = user_access('use vote up/down on nodes')) || user_access('view vote up/down count on nodes'))) {
+          $widget_showmode = variable_get('vud_node_widget_show', VUD_NODE_DISPLAY_BOTH);
+          $tag = variable_get('vud_tag', 'vote');
+          $widget = variable_get('vud_node_widget', 'plain');
+          $vote_on_teaser = (bool)variable_get('vud_node_widget_vote_on_teaser', TRUE);
+          $teaser = $a3;
 
           switch ($widget_showmode) {
             case VUD_NODE_DISPLAY_TEASER_ONLY:
@@ -167,10 +184,9 @@ function vud_node_nodeapi(&$node, $op, $
             ),
             'setting'
           );
-
         }
+        break;
       }
-      break;
   }
 }
 
@@ -280,3 +296,62 @@ function vud_node_link($type, $object, $
   }
   return $links;
 }
+
+/**
+ * Helper function to check for valid nodes.
+ */
+function vud_node_is_valid_node($node) {
+  // The parameter was a node.
+  if (is_object($node) && variable_get('vud_node_per_node', FALSE) && in_array($node->type, array_filter(variable_get('vud_node_types', array())))) {
+    return TRUE;
+  }
+  elseif (is_numeric($node)) {
+    $nid = $node;
+    return db_result(db_query("SELECT status FROM {vud_status} WHERE type = 'node' AND content_id = %d", $nid));
+  }
+  return FALSE;
+}
+
+/**
+ * Helper function to check for valid node types.
+ */
+function vud_node_is_valid_type($type_name) {
+  // The parameter was a content type name string.
+  if (is_string($type_name) && in_array($type_name, array_filter(variable_get('vud_node_types', array())))) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function vud_node_form_alter(&$form, &$form_state, $form_id) {
+  if (isset($form['#node']) && $form_id == $form['#node']->type . '_node_form' && vud_node_is_valid_type($form['#node']->type)) {
+    $status = isset($form['#node']->vud_status) ? $form['#node']->vud_status : 0;
+    $form['vud'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Vote Up/Down'),
+      'vud_status' => array(
+        '#type' => 'checkbox',
+        '#title' => t('Enable up/down voting'),
+        '#default_value' => $status,
+      ),
+    );
+  }
+}
+
+/**
+ * Implementation of hook_content_extra_fields().
+ */
+function vud_node_content_extra_fields($type_name) {
+  if (vud_node_is_valid_type($type_name) && variable_get('vud_node_per_node', FALSE)) {
+    $extra = array();
+    $extra['vud'] = array(
+      'label' => t('Vote Up/Down'),
+      'description' => t('Vote Up/Down settings'),
+      'weight' => 0,
+    );
+  }
+  return $extra;
+}
