--- /tmp/workflow_post_install/workflow_post_install.module	2009-04-19 21:45:16.000000000 -0700
+++ workflow_post_install/workflow_post_install.module	2010-01-11 16:30:22.000000000 -0800
@@ -9,7 +9,8 @@
  * Deliberately no menu created for this link. Invoke by typing the following
  * URI in your browser:
  *
- *   .../content/set_workflow_state/<state>
+ *   .../content/set_published_workflow_state/<state>
+ *   .../content/set_unpublished_workflow_state/<state>
  *
  * where <state> is the name of an existing state you want to put all content
  * (provided it is of a type that participates in workflows, i.e. as set on the
@@ -29,16 +30,30 @@ function workflow_post_install_menu() {
   // "Secret" link to place all stateless nodes in a workflow state, which is
   // supplied by name as the last arg of the URL, like "in-review":
   //
-  //   /content/set_workflow_state/in-review
+  //   /content/set_unpublished_workflow_state/in-review
+  //   /content/set_published_workflow_state/live
   //
-  $items['content/set_workflow_state'] = array(
-    'page callback' => 'workflow_create_state_for_stateless_nodes',
+  $items['content/set_published_workflow_state'] = array(
+    'page callback' => 'workflow_create_state_for_published_stateless_nodes',
+    'access arguments' => array('administer nodes'),
+    'type' => MENU_CALLBACK
+  );
+  $items['content/set_unpublished_workflow_state'] = array(
+    'page callback' => 'workflow_create_state_for_unpublished_stateless_nodes',
     'access arguments' => array('administer nodes'),
     'type' => MENU_CALLBACK
   );
   return $items;
 }
 
+function workflow_create_state_for_published_stateless_nodes() {
+	workflow_create_state_for_stateless_nodes(1);
+}
+
+function workflow_create_state_for_unpublished_stateless_nodes() {
+	workflow_create_state_for_stateless_nodes(0);
+}
+
 /**
  * Create states for all nodes that do not have a workflow state assigned.
  *
@@ -49,7 +64,7 @@ function workflow_post_install_menu() {
  * defined.
  * WARNING: be careful, this action cannot be undone!
  */
-function workflow_create_state_for_stateless_nodes() {
+function workflow_create_state_for_stateless_nodes($published) {
   // Get workflow state id from last argument of URL and look up associated id.
   $state_name = end(arg());
   $count = 0;
@@ -58,7 +73,7 @@ function workflow_create_state_for_state
     drupal_set_message(t('Invalid workflow state: "@state"', array('@state' => $state_name)), 'error');
   }
   else {
-    $count = _create_workflow_state_for_nodes($sid);
+    $count = _create_workflow_state_for_nodes($sid, $published);
     if ($count > 0) {
       drupal_set_message(t('The content access permissions need to be rebuilt. Please visit <a href="@rebuild-permissions-page">this page</a>.', array('@rebuild-permissions-page' => url('admin/content/node-settings/rebuild'))), 'error');
     }
@@ -79,10 +94,10 @@ function workflow_create_state_for_state
  * @return
  *  The number of nodes that had a state created.
  */
-function _create_workflow_state_for_nodes($sid) {
+function _create_workflow_state_for_nodes($sid, $published) {
   $now = time();
   $count = 0;
-  $result = db_query('SELECT n.nid, n.uid, ws.state FROM {node} n INNER JOIN {workflow_type_map} wtm ON n.type=wtm.type LEFT JOIN {workflow_node} wn ON n.nid=wn.nid LEFT JOIN {workflow_states} ws ON wn.sid=ws.sid WHERE wtm.wid > 0');
+  $result = db_query('SELECT n.nid, n.uid, ws.state FROM {node} n INNER JOIN {workflow_type_map} wtm ON n.type=wtm.type LEFT JOIN {workflow_node} wn ON n.nid=wn.nid LEFT JOIN {workflow_states} ws ON wn.sid=ws.sid WHERE n.status = %d AND wtm.wid > 0', $published);
   while ($node = db_fetch_object($result)) {
     if (empty($node->state)) { // i.e. 'No state'
       if (_create_workflow_state_for_node($node->nid, $sid, $node->uid, $now)) {
