Index: trunk/ippTools/share/pubtool_definerun.sql
===================================================================
--- trunk/ippTools/share/pubtool_definerun.sql	(revision 28375)
+++ trunk/ippTools/share/pubtool_definerun.sql	(revision 28411)
@@ -38,4 +38,24 @@
         AND (camRun.magicked != 0 OR publishClient.magicked = 0)
     -- WHERE hook %s
+    UNION
+    -- Get diffphots to publish
+    SELECT DISTINCT
+        client_id,
+        diff_phot_id AS stage_id,
+        diffPhotRun.label AS src_label
+    FROM publishClient
+    JOIN diffPhotRun
+    JOIN diffRun USING(diff_id)
+    JOIN diffInputSkyfile USING(diff_id)
+    JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 -- Only JOINing input, not reference!
+    JOIN fakeRun USING(fake_id)
+    JOIN camRun USING(cam_id)
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
+    WHERE publishClient.stage = 'diffphot'
+        AND publishClient.active = 1
+        AND diffPhotRun.state IN ('full', 'cleaned', 'goto_cleaned')
+        AND (diffRun.diff_mode = 4 OR publishClient.magicked = 0) -- diffPhotRun doesn't respect magic
+    -- WHERE hook %s
     ) AS publishToDo
 -- Only get stuff that hasn't been published
Index: trunk/ippTools/share/pubtool_pending.sql
===================================================================
--- trunk/ippTools/share/pubtool_pending.sql	(revision 28375)
+++ trunk/ippTools/share/pubtool_pending.sql	(revision 28411)
@@ -50,4 +50,30 @@
         AND (camRun.magicked != 0 OR publishClient.magicked = 0)
         -- WHERE hook %s
+    SELECT DISTINCT
+        publishRun.pub_id,
+        publishClient.product,
+        publishClient.stage,
+        publishClient.workdir,
+        diffPhotRun.diff_phot_id AS stage_id,
+        rawExp.camera,
+        rawExp.exp_id
+    FROM publishRun
+    JOIN publishClient USING(client_id)
+    JOIN diffPhotRun
+        ON diffPhotRun.diff_phot_id = publishRun.stage_id
+    JOIN diffRun USING(diff_id)
+    JOIN diffInputSkyfile USING(diff_id)
+    -- Need to do something fancy here to get the camera name for a stack
+    LEFT JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1
+    JOIN fakeRun USING(fake_id)
+    JOIN camRun USING(cam_id)
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
+    WHERE publishClient.stage = 'diffphot'
+        AND publishClient.active = 1
+        AND publishRun.state = 'new'
+        AND diffPhotRun.state IN ('full', 'cleaned', 'goto_cleaned')
+        AND (diffRun.diff_mode = 4 OR publishClient.magicked = 0) -- diffPhotRun doesn't respect magic
+        -- WHERE hook %s
 ) AS publishToDo
 LEFT JOIN publishDone USING(pub_id)
