? .cvsignore
? split.patch
Index: userpoints_nc.install
===================================================================
RCS file: userpoints_nc.install
diff -N userpoints_nc.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ userpoints_nc.install	9 Feb 2011 21:55:38 -0000
@@ -0,0 +1,17 @@
+<?php
+
+/**
+ * @file
+ * Install time hooks for userpoints_nc module.
+ */
+
+/**
+ * Implements hook_uninstall().
+ */
+function userpoints_nc_uninstall() {
+  // Delete all variables with "userpoints_nc_" prefix.
+  // This is to make sure that node type specific settings are deleted too.
+  db_delete('variable')
+    ->condition('name', 'userpoints_nc_%', 'LIKE')
+    ->execute();
+}
\ No newline at end of file
Index: userpoints_nc.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/userpoints_nc/Attic/userpoints_nc.js,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 userpoints_nc.js
--- userpoints_nc.js	10 Nov 2010 20:26:38 -0000	1.1.2.1
+++ userpoints_nc.js	9 Feb 2011 21:55:38 -0000
@@ -7,31 +7,66 @@
       $('fieldset#edit-userpoints-nc', context).drupalSetSummary(function (context) {
         var params = {
           '@points': $('#edit-userpoints-nc-points', context).val(),
-          '%category': $('select#edit-userpoints-nc-category :selected', context).text(),
-          '@points_comment': $('#edit-userpoints-nc-comment-points', context).val(),
-          '%category_comment': $('select#edit-userpoints-nc-comment-category :selected', context).text()
+          '%category': $('select#edit-userpoints-nc-category :selected', context).text()
         }
 
         if ($('#edit-userpoints-nc-enabled').is(':checked')) {
           if ($('#edit-userpoints-nc-published-only').is(':checked')) {
-            return Drupal.t('Enabled (published only), @points (%category) for content, @points_comment (%category_comment) for comments.', params);
+            return Drupal.t('Enabled (published only), @points (%category) for content.', params);
           }
           else {
-            return Drupal.t('Enabled (all), @points (%category) for content, @points_comment (%category_comment) for comments.', params);
+            return Drupal.t('Enabled (all), @points (%category) for content.', params);
           }
         }
         else {
           // If disabled on the node type settings, the other settings don't
           // matter so we don't display them.
           if ($('form#node-type-form').length) {
-            return Drupal.t('Disabled');
+            return Drupal.t('Disabled.');
           }
           else {
             if ($('#edit-userpoints-nc-published-only').is(':checked')) {
-              return Drupal.t('Disabled (published only), @points (%category) for content, @points_comment (%category_comment) for comments.', params);
+              return Drupal.t('Disabled (published only), @points (%category) for content.', params);
             }
             else {
-              return Drupal.t('Disabled (all), @points (%category) for content, @points_comment (%category_comment) for comments.', params);
+              return Drupal.t('Disabled (all), @points (%category) for content.', params);
+            }
+          }
+        }
+      })
+    }
+  };
+
+  Drupal.behaviors.userpointsNCCommentFieldsetSummaries = {
+    attach: function (context) {
+      // This is both for the userpoints settings and the node type settings
+      // vertical tab.
+      $('fieldset#edit-userpoints-nc-comment', context).drupalSetSummary(function (context) {
+        var params = {
+          '@points': $('#edit-userpoints-nc-comment-points', context).val(),
+          '%category': $('select#edit-userpoints-nc-comment-category :selected', context).text()
+        }
+
+        if ($('#edit-userpoints-nc-comment-enabled').is(':checked')) {
+          if ($('#edit-userpoints-nc-comment-published-only').is(':checked')) {
+            return Drupal.t('Enabled (published only), @points (%category) for comments.', params);
+          }
+          else {
+            return Drupal.t('Enabled (all), @points (%category) for comments.', params);
+          }
+        }
+        else {
+          // If disabled on the node type settings, the other settings don't
+          // matter so we don't display them.
+          if ($('form#node-type-form').length) {
+            return Drupal.t('Disabled.');
+          }
+          else {
+            if ($('#edit-userpoints-nc-comment-published-only').is(':checked')) {
+              return Drupal.t('Disabled (published only), @points (%category) for comments.', params);
+            }
+            else {
+              return Drupal.t('Disabled (all), @points (%category) for comments.', params);
             }
           }
         }
Index: userpoints_nc.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/userpoints_nc/userpoints_nc.module,v
retrieving revision 1.3.2.2.2.2
diff -u -p -r1.3.2.2.2.2 userpoints_nc.module
--- userpoints_nc.module	9 Feb 2011 20:33:24 -0000	1.3.2.2.2.2
+++ userpoints_nc.module	9 Feb 2011 21:55:38 -0000
@@ -7,11 +7,11 @@
 function userpoints_nc_form_node_type_form_alter(&$form, &$form_state) {
   $form['userpoints_nc'] = array(
     '#type' => 'fieldset',
-    '#title' => t('!Points Awards', userpoints_translation()),
+    '#title' => t('!Points for content', userpoints_translation()),
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
     '#access' => user_access('administer userpoints'),
-    '#weight' => 25,
+    '#weight' => 15,
     '#group' => 'additional_settings',
     '#attached' => array(
       'js' => array(
@@ -20,18 +20,18 @@ function userpoints_nc_form_node_type_fo
     ),
     '#attributes' => array('class' => array('userpoints-nc-nodetype-form')),
   );
-  
+
   $type = $form['#node_type']->type;
   $form['userpoints_nc']['userpoints_nc_enabled'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Enabled'),
+    '#title' => t('Enabled.'),
     '#default_value' => userpoints_nc_get_setting('enabled', $type, TRUE),
-    '#description' => t('If checked, !points can be awarded for creating or commenting upon content of this type.', userpoints_translation()),
+    '#description' => t('If checked, !points can be awarded for creating content of this type.', userpoints_translation()),
   );
 
   $form['userpoints_nc']['userpoints_nc_ownership_deduct'] = array(
     '#type'          => 'checkbox',
-    '#title'         => t('Deduct !points when the content or comment author changes', userpoints_translation()),
+    '#title'         => t('Deduct !points when the content author changes.', userpoints_translation()),
     '#default_value' => userpoints_nc_get_setting('ownership_deduct', $type, TRUE),
     '#description'   => t('If checked, the old author will lose any !points that he previously gained.', userpoints_translation()),
     '#states' => array(
@@ -43,7 +43,7 @@ function userpoints_nc_form_node_type_fo
 
   $form['userpoints_nc']['userpoints_nc_delete_deduct'] = array(
     '#type'          => 'checkbox',
-    '#title'         => t('Deduct !points when content or comments are deleted or unpublished', userpoints_translation()),
+    '#title'         => t('Deduct !points when content is deleted or unpublished.', userpoints_translation()),
     '#default_value' => userpoints_nc_get_setting('delete_deduct', $type, TRUE),
     '#description'   => t('If checked, the author will lose any !points that he previously gained.', userpoints_translation()),
     '#states' => array(
@@ -80,7 +80,49 @@ function userpoints_nc_form_node_type_fo
     ),
   );
 
-  $form['userpoints_nc']['userpoints_nc_comment_points'] = array(
+  $form['userpoints_nc_comment'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('!Points for comments', userpoints_translation()),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#access' => user_access('administer userpoints'),
+    '#weight' => 20,
+    '#group' => 'additional_settings',
+    '#attributes' => array('class' => array('userpoints-nc-comment-nodetype-form')),
+  );
+
+  $form['userpoints_nc_comment']['userpoints_nc_comment_enabled'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enabled'),
+    '#default_value' => userpoints_nc_get_setting('comment_enabled', $type, TRUE),
+    '#description' => t('If checked, !points can be awarded for commenting upon content of this type.', userpoints_translation()),
+  );
+
+  $form['userpoints_nc_comment']['userpoints_nc_comment_ownership_deduct'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Deduct !points when the comment author changes.', userpoints_translation()),
+    '#default_value' => userpoints_nc_get_setting('comment_ownership_deduct', $type, TRUE),
+    '#description'   => t('If checked, the old author will lose any !points that he previously gained.', userpoints_translation()),
+    '#states' => array(
+      'visible' => array(
+        ':input[name="userpoints_nc_comment_enabled"]' => array('checked' => TRUE),
+      ),
+    ),
+  );
+
+  $form['userpoints_nc_comment']['userpoints_nc_comment_delete_deduct'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Deduct !points when comments are deleted or unpublished.', userpoints_translation()),
+    '#default_value' => userpoints_nc_get_setting('comment_delete_deduct', $type, TRUE),
+    '#description'   => t('If checked, the author will lose any !points that he previously gained.', userpoints_translation()),
+    '#states' => array(
+      'visible' => array(
+        ':input[name="userpoints_nc_comment_enabled"]' => array('checked' => TRUE),
+      ),
+    ),
+  );
+
+  $form['userpoints_nc_comment']['userpoints_nc_comment_points'] = array(
     '#type'          => 'textfield',
     '#title'         => t('!Points for new comments', userpoints_translation()),
     '#description'   => t('Set the number of !points to be awarded when a user adds a comment.', userpoints_translation()),
@@ -94,7 +136,7 @@ function userpoints_nc_form_node_type_fo
     ),
   );
 
-  $form['userpoints_nc']['userpoints_nc_comment_category'] = array(
+  $form['userpoints_nc_comment']['userpoints_nc_comment_category'] = array(
     '#type'          => 'select',
     '#title'         => t('!Points category for new comments', array_merge(userpoints_translation())),
     '#description'   => t('Choose the category of !points to be awarded when a user adds a comment.', userpoints_translation()),
@@ -121,34 +163,35 @@ function userpoints_nc_userpoints($op, $
         '#type'        => 'fieldset',
         '#collapsible' => TRUE,
         '#collapsed'   => TRUE,
-        '#title'       => t('Content and comments'),
+        '#title'       => t('Content'),
         '#group'       => 'settings_additional',
+        '#weight'      => 15,
       );
 
       $form['userpoints_nc']['userpoints_nc_enabled'] = array(
         '#type' => 'checkbox',
-        '#title' => t('Enabled by default'),
+        '#title' => t('Enabled by default.'),
         '#default_value' => userpoints_nc_get_setting('enabled', NULL, TRUE),
         '#description' => t('If checked, all content types award !points by default. This can be overridden for each content type on the content type edit page.', userpoints_translation()),
       );
 
       $form['userpoints_nc']['userpoints_nc_published_only'] = array(
         '#type'          => 'checkbox',
-        '#title'         => t('Only award !points for published nodes and comments.', userpoints_translation()),
+        '#title'         => t('Only award !points for published content.', userpoints_translation()),
         '#default_value' => variable_get('userpoints_nc_published_only', TRUE),
-        '#description'   => t('If checked, users only receive !points when content or comments are published.', userpoints_translation())
+        '#description'   => t('If checked, users only receive !points when content is published.', userpoints_translation())
       );
 
       $form['userpoints_nc']['userpoints_nc_ownership_deduct'] = array(
         '#type'          => 'checkbox',
-        '#title'         => t('Deduct !points when the content or comment author changes.', userpoints_translation()),
+        '#title'         => t('Deduct !points when the content author changes.', userpoints_translation()),
         '#default_value' => variable_get('userpoints_nc_ownership_deduct', TRUE),
         '#description'   => t('If checked, the old author will lose any !points that he previously gained. This setting can be overridden for each content type.', userpoints_translation())
       );
 
       $form['userpoints_nc']['userpoints_nc_delete_deduct'] = array(
         '#type'          => 'checkbox',
-        '#title'         => t('Deduct !points when content or comments are deleted or unpublished', userpoints_translation()),
+        '#title'         => t('Deduct !points when content is deleted or unpublished.', userpoints_translation()),
         '#default_value' => variable_get('userpoints_nc_ownership_deduct', TRUE),
         '#description'   => t('If checked, the author will lose any points that he previously gained. This setting can be overridden for each content type.', userpoints_translation())
       );
@@ -170,7 +213,44 @@ function userpoints_nc_userpoints($op, $
         '#default_value' => userpoints_nc_get_setting('category'),
       );
 
-      $form['userpoints_nc']['userpoints_nc_comment_points'] = array(
+      $form['userpoints_nc_comment'] = array(
+        '#type'        => 'fieldset',
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+        '#title'       => t('Comments'),
+        '#group'       => 'settings_additional',
+        '#weight'      => 20,
+      );
+
+      $form['userpoints_nc_comment']['userpoints_nc_comment_enabled'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Enabled by default.'),
+        '#default_value' => userpoints_nc_get_setting('comment_enabled', NULL, TRUE),
+        '#description' => t('If checked, all content types award !points by default. This can be overridden for each content type on the content type edit page.', userpoints_translation()),
+      );
+
+      $form['userpoints_nc_comment']['userpoints_nc_comment_published_only'] = array(
+        '#type'          => 'checkbox',
+        '#title'         => t('Only award !points for published comments.', userpoints_translation()),
+        '#default_value' => variable_get('userpoints_nc_comment_published_only', TRUE),
+        '#description'   => t('If checked, users only receive !points when comments are published.', userpoints_translation())
+      );
+
+      $form['userpoints_nc_comment']['userpoints_nc_comment_ownership_deduct'] = array(
+        '#type'          => 'checkbox',
+        '#title'         => t('Deduct !points when the comment author changes.', userpoints_translation()),
+        '#default_value' => variable_get('userpoints_nc_comment_ownership_deduct', TRUE),
+        '#description'   => t('If checked, the old author will lose any !points that he previously gained. This setting can be overridden for each content type.', userpoints_translation())
+      );
+
+      $form['userpoints_nc_comment']['userpoints_nc_comment_delete_deduct'] = array(
+        '#type'          => 'checkbox',
+        '#title'         => t('Deduct !points when comments are deleted or unpublished.', userpoints_translation()),
+        '#default_value' => variable_get('userpoints_nc_comment_ownership_deduct', TRUE),
+        '#description'   => t('If checked, the author will lose any points that he previously gained. This setting can be overridden for each content type.', userpoints_translation())
+      );
+
+      $form['userpoints_nc_comment']['userpoints_nc_comment_points'] = array(
         '#type'          => 'textfield',
         '#title'         => t('Default !points for new comments', userpoints_translation()),
         '#description'   => t('Set the default number of !points to be awarded when a user adds a comment. This can be overridden for each content type.', userpoints_translation()),
@@ -179,7 +259,7 @@ function userpoints_nc_userpoints($op, $
         '#maxlength'     => 5,
       );
 
-      $form['userpoints_nc']['userpoints_nc_comment_category'] = array(
+      $form['userpoints_nc_comment']['userpoints_nc_comment_category'] = array(
         '#type'          => 'select',
         '#title'         => t('Default !points category for new comments', userpoints_translation()),
         '#description'   => t('Choose the category of !points to be used by default when a user adds a comment. This can be overridden for each content type.', userpoints_translation()),
@@ -355,13 +435,13 @@ function userpoints_nc_node_presave($nod
 function userpoints_nc_comment_insert($comment) {
   $node = node_load($comment->nid);
   // Check if enabled for this node type.
-  if (!userpoints_nc_get_setting('enabled', $node->type, TRUE)) {
+  if (!userpoints_nc_get_setting('comment_enabled', $node->type, TRUE)) {
     return;
   }
 
   $tid = userpoints_nc_get_setting('comment_category', $node->type);
   $points = userpoints_nc_get_setting('comment_points', $node->type);
-  $published_or_all = $comment->status == COMMENT_PUBLISHED || !variable_get('userpoints_nc_published_only', TRUE);
+  $published_or_all = $comment->status == COMMENT_PUBLISHED || !variable_get('userpoints_nc_comment_published_only', TRUE);
 
   if ($points != 0 && $published_or_all) {
     $params = array(
@@ -384,14 +464,14 @@ function userpoints_nc_comment_presave($
 
   $node = node_load($comment->nid);
   // Check if enabled for this node type.
-  if (!userpoints_nc_get_setting('enabled', $node->type, TRUE)) {
+  if (!userpoints_nc_get_setting('comment_enabled', $node->type, TRUE)) {
     return;
   }
 
   $tid = userpoints_nc_get_setting('comment_category', $node->type);
   $points = userpoints_nc_get_setting('comment_points', $node->type);
-  $published_or_all = $comment->status == COMMENT_PUBLISHED || !variable_get('userpoints_nc_published_only', TRUE);
-  $published_only = $comment->status == COMMENT_PUBLISHED && variable_get('userpoints_nc_published_only', TRUE);
+  $published_or_all = $comment->status == COMMENT_PUBLISHED || !variable_get('userpoints_nc_comment_published_only', TRUE);
+  $published_only = $comment->status == COMMENT_PUBLISHED && variable_get('userpoints_nc_comment_published_only', TRUE);
 
   if (!$comment->cid) {
     return;
@@ -422,7 +502,7 @@ function userpoints_nc_comment_presave($
     }
 
     // Only subtract points if he was published before.
-    if (userpoints_nc_get_setting('ownership_deduct', $node->type, TRUE) && ($old_status == NODE_PUBLISHED || $published_or_all)) {
+    if (userpoints_nc_get_setting('comment_ownership_deduct', $node->type, TRUE) && ($old_status == NODE_PUBLISHED || $published_or_all)) {
       $params = array(
         'points' => -$last_owner->points,
         'tid' => $tid,
@@ -447,7 +527,7 @@ function userpoints_nc_comment_presave($
     userpoints_userpointsapi($params);
   }
   // Check if node was unpublished and points need to be subtracted.
-  else if (userpoints_nc_get_setting('delete_deduct', $node->type, TRUE) && $points != 0 && $old_status == COMMENT_PUBLISHED && $comment->status == COMMENT_NOT_PUBLISHED && variable_get('userpoints_nc_published_only', TRUE)) {
+  else if (userpoints_nc_get_setting('comment_delete_deduct', $node->type, TRUE) && $points != 0 && $old_status == COMMENT_PUBLISHED && $comment->status == COMMENT_NOT_PUBLISHED && variable_get('userpoints_nc_comment_published_only', TRUE)) {
      $params = array(
       'points' => -$points,
       'tid' => $tid,
@@ -466,15 +546,15 @@ function userpoints_nc_comment_presave($
 function userpoints_nc_comment_delete($comment) {
   $node = node_load($comment->nid);
   // Check if enabled for this node type.
-  if (!userpoints_nc_get_setting('enabled', $node->type, TRUE)) {
+  if (!userpoints_nc_get_setting('comment_enabled', $node->type, TRUE)) {
     return;
   }
 
   $tid = userpoints_nc_get_setting('comment_category', $node->type);
   $points = userpoints_nc_get_setting('comment_points', $node->type);
-  $published_or_all = $comment->status == COMMENT_PUBLISHED || !variable_get('userpoints_nc_published_only', TRUE);
+  $published_or_all = $comment->status == COMMENT_PUBLISHED || !variable_get('userpoints_nc_comment_published_only', TRUE);
 
-  if (userpoints_nc_get_setting('delete_deduct', $node->type, TRUE) && $points != 0 && $published_or_all) {
+  if (userpoints_nc_get_setting('comment_delete_deduct', $node->type, TRUE) && $points != 0 && $published_or_all) {
     $params = array(
       'points' => -$points,
       'tid' => $tid,
