--- workflow_ng_node_old.inc	2007-11-07 02:59:54.000000000 +0530
+++ workflow_ng_node_new.inc	2007-12-12 12:02:34.031250000 +0530
@@ -42,7 +42,7 @@ function node_event_info() {
       '#label' => t('Content has been deleted'),
       '#module' => t('Node'),
       '#arguments' => workflow_ng_events_node_arguments(t('deleted content'), t('content author')),
-    ),
+    ),
   );
 }
 
@@ -166,7 +166,14 @@ function node_action_info() {
         'node' => array('#entity' => 'node', '#label' => t('Content')),
       ),
       '#module' => t('Node'),
-    ),
+    ),
+    'workflow_ng_action_add_node' => array(
+      '#label' => t('Add a node'),
+      '#arguments' => array(
+        'author' => array('#entity' => 'user', '#label' => t('User, which is set as author of the node')),
+      ),
+      '#module' => t('Node'),
+    ),      
   );
 }
 
@@ -233,3 +240,69 @@ function workflow_ng_action_node_promote
 function workflow_ng_action_node_promote_submit($form_id, $form_values) {
   return array('promote' => $form_values['promote']);
 }
+
+
+
+/*
+ * Action add a node
+ */
+function workflow_ng_action_add_node ($author, $settings, &$arguments, &$log) {
+  //check if WF-ng should check for access rights on node creation
+  if ($settings['node_access']) {
+    if (node_access('create', $settings['nodetypes'])) {
+      $authorize = TRUE;
+    } 
+    else {
+     $authorize = FALSE;
+    }
+  }
+  else $authorize = TRUE;
+  if ($authorize) {
+    $node = array('type' => $settings['nodetypes']); 
+    $node_form = $settings['nodetypes'].'_node_form';
+    $title_from_token = workflow_ng_token_replace_all (array('title'), $settings, $arguments, $log);
+    $values['title'] =  $title_from_token['title']; 
+    $values['name'] = $author->name; 
+    drupal_execute($node_form, $values, $node);
+  }
+}
+
+
+/*
+ * Action "Add node" configuration form
+ */
+
+function workflow_ng_action_add_node_form($settings = array(), $argument_info) {
+  $form = array();
+  $form['nodetypes'] = array(
+    '#type' => 'select',
+    '#title' => t('Content type to be used for node creation'),
+    '#options' => node_get_types('names'),
+    '#default_value' => $settings['nodetypes'],
+    '#description' => t('Select a single content type that will be created when this action is invoked.'),
+    '#required' => TRUE,
+  );
+    $form['node_access'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Create the node only if the author has access rights to do so'),
+    '#default_value' => $settings['node_access'],
+    '#description' => t('Enable this in order for the system to check if the user has access rights for creating the 
+      required node.'),
+  );  
+  $form['title'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Title'),
+    '#default_value' => $settings['title'],
+    '#description' => t('Enter the Title of the new created node. Using Auto-node titles will overide this'),
+    '#required' => TRUE,
+  );
+  workflow_ng_token_replacement_help($form, $argument_info);
+  return $form;
+}
+
+
+function workflow_ng_action_add_node_submit($form_id, $form_values) {
+  //returns the needed settings
+  $used_args = workflow_ng_token_get_settings(array($form_values['title']), $form_values);
+  return array('nodetypes' => $form_values['nodetypes'], 'title' => $form_values['title'], 'node_access' => $form_values['node_access'], 'used arguments' => $used_args);
+}
\ No newline at end of file
