? .cvsignore
? operation.patch
? operation2.patch
Index: userpoints_nodeaccess.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/userpoints_nodeaccess/userpoints_nodeaccess.module,v
retrieving revision 1.5
diff -u -p -r1.5 userpoints_nodeaccess.module
--- userpoints_nodeaccess.module	5 Jan 2011 14:13:46 -0000	1.5
+++ userpoints_nodeaccess.module	9 Jan 2011 16:36:11 -0000
@@ -405,9 +405,10 @@ function userpoints_nodeaccess_trade_acc
         'uid' => $uid,
         'points' => -$row->points,
         'tid' => $tid,
-        'operation' => 'Substract',
-        'description' => t('User bought access to @node', array('@node' => node_load($nid)->title)),
+        'operation' => 'userpoints_nodeaccess_bought',
         'display' => FALSE,
+        'entity_type' => 'node',
+        'entity_id' => $nid,
       );
       userpoints_userpointsapi($params);
 
@@ -436,3 +437,32 @@ function userpoints_nodeaccess_entity_in
   );
   return $return;
 }
+
+/**
+ * Implements hook_userpoints_info().
+ */
+function userpoints_nodeaccess_userpoints_info() {
+  return array(
+    'userpoints_nodeaccess_bought' => array(
+      'description callback' => 'userpoints_nodeaccess_description_callback',
+    )
+  );
+}
+
+/**
+ * Description callback for userpoint operation description/reason.
+ */
+function userpoints_nodeaccess_description_callback($operation, $entity) {
+
+  $arguments = array();
+  // Try to load content type name.
+  if ($operation->entity_type == 'node' && $entity) {
+    $arguments['%title'] = $entity->title;
+  }
+
+  // Fallback to string content if the above failed for some reason.
+  if (empty($arguments['%title'])) {
+    $arguments['%title'] = t('content');
+  }
+  return t('Gained access to %title.', $arguments);
+}
