? 1002952-9.patch
Index: activity.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/activity/Attic/activity.admin.inc,v
retrieving revision 1.1.2.43
diff -u -p -r1.1.2.43 activity.admin.inc
--- activity.admin.inc	18 Jul 2010 19:03:39 -0000	1.1.2.43
+++ activity.admin.inc	21 Dec 2010 17:23:50 -0000
@@ -692,6 +692,29 @@ function activity_batch_regenerate($batc
   foreach ($batches as $aid => $batch) {
     $trigger_assignment = db_fetch_object(db_query("SELECT hook, op FROM {trigger_assignments} WHERE aid = '%s'", $aid));
     if (!empty($trigger_assignment)) {
+      // Refine the batch before sending for processing
+      switch ($trigger_assignment->hook) {
+        case "nodeapi":
+          // Obtain the node type for this particular regeneration
+          $parameters = unserialize(db_result(db_query("SELECT a.parameters FROM {actions} a WHERE aid = '%s'", $aid)));
+          $types = $parameters['activity_types'];
+          // Create a list of NIDs for this node type
+          foreach ($types as $type) {
+            $result = db_query("SELECT nid FROM {node} WHERE type = '%s'", $type);
+            while ($row = db_fetch_array($result)) {
+              $nids[] = $row['nid'];
+            }
+          }
+          $nids = array_flip($nids);
+          // Remove all nodes from the batch that are not of this node type
+          foreach ($batch as $key => $item) {
+            if (!array_key_exists($item['id'], $nids)) {
+              unset($batch[$key]);
+            }
+          }
+          break;
+      }
+
       $batch_set = TRUE;
       $batch = array(
         'title' => t('Regenerating @description Activity', array('@description' => db_result(db_query("SELECT description from {actions} WHERE aid = '%s'", $aid)))),
@@ -804,4 +827,4 @@ function activity_batch_regenerate_step(
     // If finished, delete the sandbox.
     unset($batch_context['sandbox']);
   }
-}
\ No newline at end of file
+}
