diff -urpN old/acl.module new/acl.module
--- old/acl.module	2008-03-13 03:18:00.000000000 +0530
+++ new/acl.module	2008-04-17 22:06:09.546875000 +0530
@@ -9,6 +9,11 @@
  * other without having to actually know much about them, and so that
  * ACLs can easily co-exist with the existing node_access system.
  */
+
+if (module_exists('workflow_ng')) {
+  include_once(drupal_get_path('module', 'acl') .'/acl_workflow_ng.inc');
+}
+
 
 /**
  * Create a new ACL.
@@ -177,14 +182,37 @@ function acl_node_add_acl($nid, $acl_id,
 }
 
 /**
+ * Gets all the existing ACL(s).
+ * 
+ * @return 
+ *  Array with the ACL(s) module and name.
+ */
+function acl_node_return_all_existing_acl() {
+  $existing_acl = array();
+  $result = db_query("SELECT module, name FROM {acl}");
+  while ($data = db_fetch_object($result)) {
+    // This makes sure there are no duplicate entries.
+    $existing_acl[$data->module . ', ' . $data->name]= $data->module . ', ' . $data->name;
+  } 
+  return $existing_acl; 
+}
+
+
+/**
  * Remove an ACL completely from a node.
+ * 
+ * @return 
+ *   TRUE if the ACL was removed. 
  */
 function acl_node_remove_acl($nid, $acl_id) {
   db_query("DELETE FROM {acl_node} WHERE acl_id = %d AND nid = %d", $acl_id, $nid);
+  return (boolean)db_affected_rows(); 
 }
 
 /**
  * Clear all of a module's ACL's from a node.
+ * @return 
+ *  TRUE if there were any ACL's deleted from the node. 
  */
 function acl_node_clear_acls($nid, $module) {
   $result = db_query("SELECT acl_id FROM {acl} WHERE module = '%s'", $module);
@@ -194,14 +222,23 @@ function acl_node_clear_acls($nid, $modu
   if ($acls) {
     db_query("DELETE FROM {acl_node} WHERE nid = %d AND acl_id in (%s)", $nid,
       implode(',', $acls));
+    return (boolean)db_affected_rows();   
   }
 }
 
 /**
  * Gets the id of an acl
- */
-function acl_get_id_by_name($module, $name) {
-  return db_result(db_query("SELECT acl_id FROM {acl} WHERE module = '%s' AND name = '%s'", $module, $name));
+ * @param $auto_create
+ *    If TRUE it will create a new acl if an acl not found
+ * @return 
+ *   The acl
+ */
+function acl_get_id_by_name($module, $name, $auto_create = FALSE) {
+  $acl_id = db_result(db_query("SELECT acl_id FROM {acl} WHERE module = '%s' AND name = '%s'", $module, $name));
+  if ($auto_create && !$acl_id) {
+    $acl_id = acl_create_new_acl($module, $name);
+  }
+  return $acl_id;
 }
 
 /**
diff -urpN old/acl_workflow_ng.inc new/acl_workflow_ng.inc
--- old/acl_workflow_ng.inc	1970-01-01 05:30:00.000000000 +0530
+++ new/acl_workflow_ng.inc	2008-04-17 21:59:23.031250000 +0530
@@ -0,0 +1,293 @@
+<?php
+// $Id$
+/**
+ * @file acl_workflow_ng.inc
+ * 
+ * This include file is enabled when Workflow-ng module is enabled. 
+ * It adds some actions that allow adding and removing users and content into arbitrary ACL lists. 
+ * The ACL lists are written in the ACL table as acl_wfng.
+ */
+
+
+/*
+ * Implementation of hook_action_info().
+ */
+function acl_action_info() {
+  return array(
+    'acl_workflow_ng_action_load_acl' => array(
+      '#label' => t('Load ACL'),
+      '#new arguments' => array(
+        'acl' => array('#entity' => 'acl', '#label' => t('ACL')),
+      ),
+      '#description' => t('Load an exitsting ACL or create (and load) a new one. 
+        This action should be added before other ACL manipulation actions. 
+        You may have a single user/node assigned to several ACL lists.'),
+      '#module' => 'ACL',
+    ),    
+  'acl_workflow_ng_action_add_user_to_acl' => array(
+      '#label' => t('Add user to ACL'),
+      '#arguments' => array(
+        'user' => array('#entity' => 'user', '#label' => t('User which will be added to the ACL')),
+        'acl' => array('#entity' => 'acl', '#label' => t('ACL')),
+      ),
+      '#description' => t('Add a user to a loaded ACL.'),
+      '#module' => 'ACL',
+    ),
+    'acl_workflow_ng_action_remove_user_from_acl' => array(
+      '#label' => t('Remove user from ACL'),
+      '#arguments' => array(
+        'user' => array('#entity' => 'user', '#label' => t('User which will be removed from the ACL.')),
+        'acl' => array('#entity' => 'acl', '#label' => t('ACL')),
+      ),
+      '#module' => 'ACL',
+    ),
+    'acl_workflow_ng_action_add_node_to_acl' => array(
+      '#label' => t('Add content to ACL'),
+      '#arguments' => array(
+        'node' => array('#entity' => 'node', '#label' => t('Content which will be added to the ACL')),
+        'acl' => array('#entity' => 'acl', '#label' => t('ACL')),
+      ),
+      '#description' => t('Add a content to a loaded ACL.'),      
+      '#module' => 'ACL',
+    ),
+    'acl_workflow_ng_action_remove_node_from_acl' => array(
+      '#label' => t('Remove content from ACL'),
+      '#arguments' => array(
+        'node' => array('#entity' => 'node', '#label' => t('Content which will be removed from the ACL')),
+        'acl' => array('#entity' => 'acl', '#label' => t('ACL')),
+      ),
+      '#description' => t('Remove a content from a loaded ACL.'),      
+      '#module' => 'ACL',
+    ),  
+    'acl_workflow_ng_action_delete_whole_acl' => array(
+      '#label' => t('Delete ACL(s) from content'),
+      '#arguments' => array(
+        'node' => array('#entity' => 'node', '#label' => t('Content which ACL will be removed')), 
+      ),
+      '#description' => t('Delete all ACL(s) of a certain module from a content.'),      
+      '#module' => 'ACL',
+    ),  
+    'acl_workflow_ng_action_delete_acl' => array(
+      '#label' => t('Delete ACL'),
+      '#arguments' => array(
+        'acl' => array('#entity' => 'acl', '#label' => t('ACL')),    
+      ),
+      '#description' => t('Completely delete ACL of a certain module. Note that this action might load many nodes at once,
+        thus should be used by advanced users and with caution.'),        
+      '#module' => 'ACL',
+    ),     
+  );
+}
+function acl_workflow_ng_action_load_acl($settings, &$arguments, &$log) {
+  // Make sure that if the ACL by text fields are used, then both of them are filled. 
+  // If only one, then do not load ACL.
+  if ((!empty($settings['acl_module_token']) && empty($settings['acl_name_token'])) 
+       || empty($settings['acl_module_token']) && !empty($settings['acl_name_token'])) {
+  }
+  else {
+    // Check if 'ACL by text' was used.
+    if ($settings['acl_module_token']) {
+      extract(workflow_ng_token_replace_all(array('acl_module_token', 'acl_name_token'), $settings, $arguments, $log));
+      $acl_module = $acl_module_token;
+      $acl_name = $acl_name_token;
+    }
+    else {
+      $acl_module = $settings['acl_module'];
+      $acl_name = $settings['acl_name'];
+    }
+    // If acl doesn't exist, creaete one.
+    $acl = acl_get_id_by_name($acl_module, $acl_name, TRUE);
+    return array('#new arguments' => array('acl' => $acl));
+  }
+
+}
+
+/*
+ * Action: Load ACL form.
+ *
+ * @ingroup forms
+ * @see acl_workflow_ng_action_load_acl_submit
+ */
+function acl_workflow_ng_action_load_acl_form($settings = array(), $argument_info) {
+
+  //Get existing ACL.
+  $options = acl_node_return_all_existing_acl();
+  if ($options) {
+    $description = t('Specify the ACL which should be loaded.');
+  }
+  else {
+    $description = t('There are no exisiting ACL.');
+    $options = array('--');
+  }
+  
+  $form = array();
+  $form['acl_list'] = array(
+    '#type' => 'select',
+    '#title' => t('ACL by select. First value is the "ACL module" and the second is the "ACL name"'),
+    '#description' => $description,
+    '#options' => $options,  
+    '#default_value' => $settings['acl_list'],
+  );
+  $form['acl_module_token'] = array(
+    '#type' => 'textfield',
+    '#title' => t('ACL module by text'),
+    '#description' => t('Enter the ACL module. If this field is used the "ACL by select" is disregarded 
+      and "ACL name by text" should also be filled.'),
+    '#default_value' => $settings['acl_module_token'],
+  );
+  $form['acl_name_token'] = array(
+    '#type' => 'textfield',
+    '#title' => t('ACL name by text'),
+    '#description' => t('Enter the ACL name.'),
+    '#default_value' => $settings['acl_name_token'],
+  );      
+  workflow_ng_token_replacement_help($form, $argument_info);  
+  return $form;
+}
+
+function acl_workflow_ng_action_load_acl_submit($form_id, $form_values) {
+  $token = workflow_ng_token_get_settings(array('acl_module_token', 'acl_name_token'), $form_values);
+  $acl = explode(', ', $form_values['acl_list']);
+  $settings =  array('acl_module' => $acl['0'], 'acl_name' => $acl['1'], 'acl_module_token' => $form_values['acl_module_token'], 'acl_name_token' => $form_values['acl_name_token']);
+  return $token + $settings;
+}
+
+/*
+ * Action: Add a user to ACL.
+ */
+function acl_workflow_ng_action_add_user_to_acl($user, $acl, $settings, &$arguments, &$log) {
+  acl_add_user($acl, $user->uid);
+}
+
+
+/*
+ * Action: Remove a user from ACL.
+ */
+function acl_workflow_ng_action_remove_user_from_acl($user, $acl, $settings, &$arguments, &$log) {
+  acl_remove_user($acl, $user->uid);
+}
+
+/*
+ * Action: Add content to ACL.
+ */
+function acl_workflow_ng_action_add_node_to_acl($node, $acl, $settings, &$arguments, &$log) {
+  acl_node_add_acl($node->nid, $acl, (boolean)$settings['access_permissions']['view'], (boolean)$settings['access_permissions']['edit'], (boolean)$settings['access_permissions']['delete']);
+  return array('node' => $node);  
+}
+
+
+/*
+ * Action: Add a node to ACL form
+ *
+ * @ingroup forms
+ * @see acl_workflow_ng_action_add_node_to_acl_submit
+ */
+function acl_workflow_ng_action_add_node_to_acl_form($settings = array(), $argument_info) {
+  $form = array();
+  $form['access_permissions'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Access permissions'),
+    '#description' => t('Set the access permisions. Users asigned to the ACL will be able to preform these actions.'),
+    '#default_value' => $settings['access_permissions'],
+    '#options' => array(
+      'view' => t('View'), 
+      'edit' => t('Edit'), 
+      'delete' => t('Delete'),
+    ),  
+  );  
+  return $form;
+}
+
+function acl_workflow_ng_action_add_node_to_acl_submit($form_id, $form_values) {
+  $settings =  array('access_permissions' => $form_values['access_permissions']);
+  return $settings;
+}
+
+/*
+ * Action: Remove content from ACL.
+ */
+function acl_workflow_ng_action_remove_node_from_acl($node, $settings, &$arguments, &$log) {
+  $acl_removed = acl_node_remove_acl($node->nid, $acl_id);
+  if ($acl_removed) {
+    //Make sure new node access grants are written.
+    return array('node' => $node);
+  }
+}
+
+/*
+ * Action: Delete whole ACL from content.
+ * 
+ */
+function acl_workflow_ng_action_delete_whole_acl($node, $settings, &$arguments, &$log) {
+  if ($settings['acl_module_token']) {
+    extract(workflow_ng_token_replace_all(array('acl_module_token'), $settings, $arguments, $log));
+    $acl_module = $acl_module_token;
+  }
+  else {
+    $acl_module = $settings['acl_module'];
+  }
+  $acl_removed = acl_node_clear_acls($node->nid, $acl_module);
+  if ($acl_removed) {
+    //Make sure new node access grants are written.
+    return array('node' => $node);
+  }
+}
+
+
+/*
+ * Action: Remove content from ACL form.
+ *
+ * @ingroup forms
+ * @see acl_workflow_ng_action_delete_whole_acl_submit
+ */
+function acl_workflow_ng_action_delete_whole_acl_form($settings = array(), $argument_info) {
+
+  //Get existing ACL.
+  $acl = acl_node_return_all_existing_acl();
+  if ($acl) {
+    $description = t('Specify the ACL module which should all its ACL(s) should be removed from the content.');
+    foreach ($acl as $acl_key) {
+      $key = explode(', ', $acl_key);
+      $options[$key['0']] = $key['0'];
+    }
+  }
+  else {
+    $description = t('There are no exisiting ACL.');
+    $options = array('--');
+  }
+  
+  $form = array();
+  $form['acl_module_list'] = array(
+    '#type' => 'select',
+    '#title' => t('ACL module by select'),
+    '#description' => $description,
+    '#options' => $options,  
+    '#default_value' => $settings['acl_list'],
+  );
+  $form['acl_module_token'] = array(
+    '#type' => 'textfield',
+    '#title' => t('ACL module by text'),
+    '#description' => t('Enter the ACL module.'),
+    '#default_value' => $settings['acl_module_token'],
+  ); 
+  workflow_ng_token_replacement_help($form, $argument_info);  
+  return $form;
+}
+
+function acl_workflow_ng_action_delete_whole_acl_submit($form_id, $form_values) {
+  $token = workflow_ng_token_get_settings(array('acl_module_token'), $form_values);
+  $settings =  array('acl_module' => $form_values['acl_module_list'], 'acl_module_token' => $form_values['acl_module_token']);
+  return $token + $settings;
+}
+
+/*
+ * Action: Delete ACL
+ */
+function acl_workflow_ng_action_delete_acl($acl, $settings, &$arguments, &$log) {
+  //ACL takes care of writing the node grants to the database. 
+  acl_delete_acl($acl, TRUE);
+}
+
+
+
+
