Index: sugarondrupal.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sugarondrupal/Attic/sugarondrupal.module,v
retrieving revision 1.1.2.28.2.4
diff -u -r1.1.2.28.2.4 sugarondrupal.module
--- sugarondrupal.module	13 Jan 2011 08:37:27 -0000	1.1.2.28.2.4
+++ sugarondrupal.module	13 Jan 2011 17:34:27 -0000
@@ -138,7 +138,7 @@
       'label'         => t('Create a SugarCRM entry'),
       'type'          => 'system',
       'configurable'  => TRUE,
-      'triggers'      => array('any' => TRUE),
+      'triggers'      => array('any'),
     ),
   );
 }
@@ -180,7 +180,8 @@
 /**
  * Implementation of hook_form_system_actions_configure_alter().
  */
-function sugarondrupal_form_system_actions_configure_alter($form, $form_state) {
+function sugarondrupal_form_system_actions_configure_alter(&$form, $form_state) {
+  drupal_set_message("<pre>". print_r($form_state,1)."</pre>");
   // Only process sugarondrupal advanced actions.
   if (!isset($form['sugarondrupal_module_name'])) {
     return; 
@@ -189,10 +190,10 @@
   // Retrieve advanced action context.
   $context = $form['sugarondrupal_context']['#value'];
 
-  if (isset($form_state['post']['sugarondrupal_module_name']) || !empty($form['sugarondrupal_module_name']['#default_value'])) {
+  if (isset($form_state['input']['sugarondrupal_module_name']) || !empty($form['sugarondrupal_module_name']['#default_value'])) {
     // sugarondrupal_module_name field might not be set yet, so use POST information.
     $params = array(
-      'module' => (isset($form['sugarondrupal_module_name']['#default_value']) && !empty($form['sugarondrupal_module_name']['#default_value'])) ? $form['sugarondrupal_module_name']['#default_value'] : $form_state['post']['sugarondrupal_module_name'],
+      'module' => (isset($form['sugarondrupal_module_name']['#default_value']) && !empty($form['sugarondrupal_module_name']['#default_value'])) ? $form['sugarondrupal_module_name']['#default_value'] : $form_state['input']['sugarondrupal_module_name'],
       'fields' => array(),
     );
     $fields = sugarondrupal_get_module_fields($params);
@@ -214,12 +215,13 @@
 
     if (module_exists('token')) {
       $form['sugarondrupal_fields']['token_help']['help'] = array(
-        '#value' => theme('token_help', 'all'),
+        '#theme' => 'token_tree',
+        '#token_types' => array('all'),
       );
     }
     else {
       $form['sugarondrupal_fields']['token_help']['help'] = array(
-        '#value' => t('Predefined object attributes can be used to populate these fields. If you are assigning this action for object based events, you can put attributes enclosed in the form [attribute_name] to populate these fields. i.e., if you are assigning this action to an User event, you may use [mail] to populate the field with $user->mail attribute. It is recommended to install Token module to gain advantage of the token replacement.'),
+        '#markup' => t('You may use Drupal predefined tokens here. There is a list of available tokens in the !url. Depending on the object originating the action, only a few tokens might be available.', array('!url' => l(t('Token list handbook page'), 'http://drupal.org/node/390482'))),
       );
       $form['sugarondrupal_fields']['token_help']['#collapsed'] = FALSE;
     }
@@ -231,7 +233,7 @@
   }
   // The form has not been submitted, make initial alterations.
   else {
-    $form['buttons']['submit']['#value'] = t('Continue');
+    $form['actions']['submit']['#value'] = t('Continue');
   }
 
   return $form;
@@ -331,17 +333,18 @@
  * @param $object any of User, Node, Comment or system.
  * @param $context array of configuration for this advanced action.
  */
-function sugarondrupal_set_entry_action($object, $context) {
+function sugarondrupal_set_entry_action(&$entity, $context) {
   $type = 'global';
 
   // Guess entry type by hook and set object to actual object.
-  switch ($context['hook']) {
-    case 'nodeapi':
+  // @todo: pretty stright update from D6 to D7, requires recoding.
+  switch ($context['group']) {
+    case 'node':
       $object = $context['node'];
       $type = 'node';
       break;
     case 'user':
-      $object = $context['account'];
+      $object = $context['user'];
       $type = 'user';
       break;
     case 'comment':
@@ -356,7 +359,7 @@
   // Perform entry fields replacement.
   $fields = array();
   foreach ($context['sugarondrupal_module_fields'] as $name => $value) {
-    $fields[$name] = (module_exists('token')) ? token_replace($value, $type, $object) : sugarondrupal_replace_token($value, $object);
+    $fields[$name] = token_replace($value, $context);
   }
 
   // Submit the entry to SugarCRM

