diff -urpN old/acl.module new/acl.module --- old/acl.module 2007-11-18 01:32:42.000000000 +0530 +++ new/acl.module 2007-12-17 06:04:35.531250000 +0530 @@ -1,5 +1,5 @@ l('admin/content/node-settings', 'admin/content/node-settings'), - '!button' => t('Rebuild permissions'), - ))); -} - 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 2007-12-17 09:10:59.234375000 +0530 @@ -0,0 +1,224 @@ + array( + '#label' => t('add user to ACL'), + '#arguments' => array( + 'author' => array('#entity' => 'user', '#label' => t('User which will be added to the ACL')), + ), + '#module' => t('ACL'), + ), + 'acl_workflow_ng_remove_user_from_acl' => array( + '#label' => t('remove user from ACL'), + '#arguments' => array( + 'node' => array('#entity' => 'user', '#label' => t('User which will be removed from the ACL')), + ), + '#module' => t('ACL'), + ), + 'acl_workflow_ng_add_node_to_acl' => array( + '#label' => t('add node to ACL'), + '#arguments' => array( + 'node' => array('#entity' => 'node', '#label' => t('Content')), + ), + '#module' => t('ACL'), + ), + 'acl_workflow_ng_remove_node_from_acl' => array( + '#label' => t('remove node from ACL'), + '#arguments' => array( + 'node' => array('#entity' => 'node', '#label' => t('Content')), + ), + '#module' => t('ACL'), + ), + 'acl_workflow_ng_delete_whole_acl' => array( + '#label' => t('delete whole ACL(s) from node'), + '#arguments' => array( + 'node' => array('#entity' => 'node', '#label' => t('Content')), + ), + '#module' => t('ACL'), + ), + ); +} + + +/* + * Action: Add a user to ACL + */ +function acl_workflow_ng_add_user_to_acl($author, $settings, &$arguments, &$log) { + //Check if ACL exists, or else create it + $acl_name = workflow_ng_token_replace_all (array('acl'), $settings, $arguments, $log); + $acl_id = acl_get_id_by_name('acl', $acl_name['acl']); + if (!$acl_id) { + $acl_id = acl_create_new_acl ('acl', $acl_name['acl']); + } + + //TODO: Check if user not already in ACL + acl_add_user($acl_id, $author->uid); +} + +/* + * Action: Add a user to ACL form + */ +function acl_workflow_ng_add_user_to_acl_form($settings = array(), $argument_info) { + $form = array(); + $form['acl'] = array( + '#type' => 'textfield', + '#title' => t('ACL name'), + '#description' => t('Enter the name of the ACL. You may have a single user/ node assigned to several ACL lists'), + '#default_value' => $settings['acl'], + '#required' => TRUE, + ); + workflow_ng_token_replacement_help($form, $argument_info); + return $form; +} + +function acl_workflow_ng_add_user_to_acl_submit($form_id, $form_values) { + $acl_name = workflow_ng_token_get_settings(array('acl'), $form_values); + $settings = array('acl' => $form_values['acl']); + return $acl_name + $settings; +} + +/* + * Action: Remove a user from ACL + */ +function acl_workflow_ng_remove_user_from_acl($author, $settings, &$arguments, &$log) { + //Make sure ACL exists + $acl_name = workflow_ng_token_replace_all (array('acl'), $settings, $arguments, $log); + $acl_id = acl_get_id_by_name('acl', $acl_name['acl']); + if ($acl_id) { + //TODO: Check if user not already in ACL + acl_remove_user($acl_id, $author->uid); + } +} + +/* + * Action: Remove a user from ACL form + */ +function acl_workflow_ng_remove_user_from_acl_form($settings = array(), $argument_info) { + $form = array(); + $form['acl'] = array( + '#type' => 'textfield', + '#title' => t('ACL name'), + '#description' => t('Enter the name of the ACL.'), + '#default_value' => $settings['acl'], + '#required' => TRUE, + ); + workflow_ng_token_replacement_help($form, $argument_info); + return $form; +} + +function acl_workflow_ng_remove_user_from_acl_submit($form_id, $form_values) { + $acl_name = workflow_ng_token_get_settings(array('acl'), $form_values); + $settings = array('acl' => $form_values['acl']); + return $acl_name + $settings; +} + + +/* + * Action: Add a node to ACL + */ +function acl_workflow_ng_add_node_to_acl($node, $settings, &$arguments, &$log) { + //Make sure ACL exists + $acl_name = workflow_ng_token_replace_all (array('acl'), $settings, $arguments, $log); + $acl_id = acl_get_id_by_name('acl', $acl_name['acl']); + if (!$acl_id) { + $acl_id = acl_create_new_acl ('acl', $acl_name['acl']); + } + //TODO: Check if node not already in ACL + acl_node_add_acl($node->nid, $acl_id, (boolean)$settings['access_permisions']['view'], (boolean)$settings['access_permisions']['edit'], (boolean)$settings['access_permisions']['delete']); + //Make sure new node access grants are written. + node_save(&$node); +} + +/* + * Action: Add a node from ACL form + */ +function acl_workflow_ng_add_node_to_acl_form($settings = array(), $argument_info) { + $form = array(); + $form['acl'] = array( + '#type' => 'textfield', + '#title' => t('ACL name'), + '#description' => t('Enter the name of the ACL.'), + '#default_value' => $settings['acl'], + '#required' => TRUE, + ); + $form['access_permisions'] = array( + '#type' => 'checkboxes', + '#title' => t('Access permisions'), + '#description' => t('Select the operations users will have access rights to, when added to the node ACL.'), + '#default_value' => $settings['access_permisions'], + '#options' => array ( + 'view'=> t('View'), + 'edit' => t('Edit'), + 'delete' => t('Delete'), + ), + ); + workflow_ng_token_replacement_help($form, $argument_info); + return $form; +} + +function acl_workflow_ng_add_node_to_acl_submit($form_id, $form_values) { + $acl_name = workflow_ng_token_get_settings(array('acl'), $form_values); + $settings = array('acl' => $form_values['acl'], 'access_permisions' => $form_values['access_permisions']); + return $acl_name + $settings; +} + +/* + * Action: Remove a node to ACL + */ +function acl_workflow_ng_remove_node_from_acl($node, $settings, &$arguments, &$log) { + //Make sure ACL exists + $acl_name = workflow_ng_token_replace_all (array('acl'), $settings, $arguments, $log); + $acl_id = acl_get_id_by_name('acl', $acl_name['acl']); + if ($acl_id) { + //TODO: Check if node not already in ACL + acl_node_remove_acl($node->nid, $acl_id); + //Make sure new node access grants are written. + node_save(&$node); + } +} + +/* + * Action: Remove a node to ACL form + */ +function acl_workflow_ng_remove_node_from_acl_form($settings = array(), $argument_info) { + $form = array(); + $form['acl'] = array( + '#type' => 'textfield', + '#title' => t('ACL name'), + '#description' => t('Enter the name of the ACL.'), + '#default_value' => $settings['acl'], + '#required' => TRUE, + ); + workflow_ng_token_replacement_help($form, $argument_info); + return $form; +} + +function acl_workflow_ng_remove_node_from_acl_submit($form_id, $form_values) { + $acl_name = workflow_ng_token_get_settings(array('acl'), $form_values); + $settings = array('acl' => $form_values['acl']); + return $acl_name + $settings; +} + +/* + * Action: Delete a whole ACL(s) from node + */ +function acl_workflow_ng_delete_whole_acl($node, $settings, &$arguments, &$log) { + //Make sure ACL exists + //TODO: Check if node has any ACL defined + acl_node_clear_acls($node->nid, 'acl'); + + //Make sure new node access grants are written. + node_save(&$node); +} + + +