--- userpoints_nodelimit.module	Sun Oct 14 15:33:38 2007
+++ userpoints_nodelimit_new.module	Fri Jun 06 18:19:08 2008
@@ -18,3 +18,46 @@
     case 'admin/modules#description':
-      return '<strong>UP:</strong> '.t('Enables a limit on node creation based on user points');
+      return '<strong>UP:</strong> '.t('Enables a limit on node creation based on user points.');
+  }
+}
+
+/**
+ * Implementation of hook_usperpoints().
+ */
+function userpoints_nodelimit_userpoints($op, $points = 0, $uid = 0, $operation = NULL, $description = NULL) {
+  $translation = userpoints_translation();
+  
+  switch ($op) {
+    case 'setting':
+      $form = array();
+      
+      $form['userpoints_nodelimit'] = array(
+        '#type'          => 'fieldset',
+        '#title'         => t('Userpoints Nodelimit settings'),
+        '#collapsible'   => TRUE,
+        '#collapsed'     => TRUE,
+      );
+      $form['userpoints_nodelimit']['description'] = array(
+        '#value'         => t(
+          'This module uses the settings of <em>!userpoints_basic</em><br />.
+          It assumes the !points assigned for the creation of a node are negative;
+          this works, i.e., when the user gets !points he can use to contribute by creating nodes until he has sufficient !points.',
+          array('!userpoints_basic' => 'userpoints_basic.module') + $translation
+        ),
+        '#prefix'        => '<div>', 
+        '#suffix'        => '</div>', 
+      );
+      $form['userpoints_nodelimit']['userpoints_nodelimit_points_limit'] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('!Points limit', $translation),
+        '#default_value' => variable_get('userpoints_nodelimit_points_limit', 0),
+        '#size'          => 3,
+        '#maxlength'     => 3,
+        '#description'   => t(
+          'The minimum !points an user must have to be able to create a node',
+          $translation
+        )
+      );
+      
+      return $form;
+      break;
   }
@@ -28,6 +71,6 @@
     $node = $form['#node'];      
-    if (!$node->nid && !user_access('administer nodes') && userpoints_nodelimit_check($node->type) == FALSE) {
+    if (!$node->nid && !user_access('administer nodes') && !userpoints_nodelimit_check()) {
       drupal_set_message(t("You don't have enough points to create more nodes of this type."), 'error');
       //destory the form
-      $form = NULL;
+      $form = array();
       //return a simple hidden field so that function doesn't fail
@@ -44,3 +87,3 @@
  */
-function userpoints_nodelimit_check($nodetype) {
+function userpoints_nodelimit_check() {
   global $user;
@@ -48,11 +91,5 @@
   $current_points = userpoints_get_current_points($user->uid);
-
-  $node_points = variable_get(USERPOINTS_POST . $nodetype, 0);
-
-  if (($current_points + $node_points) < 0) {
-    return FALSE;
-  }
-  else {
-    return TRUE;
-  }
+  $limit          = (integer)variable_get('userpoints_nodelimit_points_limit', 0);
+  
+  return ($current_points >= $limit);
 }
