--- tokenize.module	2008-10-20 16:09:38.161000000 +0100
+++ tokenize.module	2009-02-23 12:34:09.941974500 +0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: tokenize.module,v 1.8 2008/10/16 22:24:22 greggles Exp $
+// $Id$
 
 /**
  * @file
@@ -14,18 +14,17 @@
  * Adds a checkbox to the field settings form to allow tokenization.
  * Captures form submission to handle the checkbox.
  */
-function tokenize_form_alter($form_id, &$form) {
+function tokenize_form_alter(&$form, &$form_state, $form_id) {
   if (isset($form['#node'])) {
     $node = $form['#node'];
-  } 
-  else {
+  } else {
     //This may seem pretty pointless, but it allows for some splicity down below.
     $node = new stdClass();
     $node->type = '';
   }
 
   switch ($form_id) {
-    case '_content_admin_field':
+    case 'content_field_edit_form':
       $tokenize_widget = tokenize_get_settings($form['field_name']['#value'], $form['type_name']['#value'], TRUE);
 
       // Add a new checkbox for tokenization
@@ -49,7 +48,7 @@
       );
       
       // Make sure we capture form submission to deal with our new checkbox.
-      $form['#submit']['tokenize_content_admin_field_submit'] = array();
+      $form['#submit'][] = 'tokenize_content_admin_field_submit';
       
       break;
     case $node->type .'_node_form':
@@ -79,7 +78,7 @@
  */
 function tokenize_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   switch ($op) {
-    case 'submit':
+    case 'presave':
       $fields = array();
       $fields = tokenize_get_settings(NULL, $node->type);
       foreach ((array)$fields as $field => $method) {
@@ -104,15 +103,15 @@
       break;
   }
 }
- 
+
 /**
  * Form callback to capture submission of the field settings form
  */
-function tokenize_content_admin_field_submit($form_id, $form_values) {
-  db_query("DELETE FROM {tokenize} WHERE field_name = '%s' AND type_name = '%s'", $form_values['field_name'],  $form_values['type_name']);
+function tokenize_content_admin_field_submit($form, &$form_state) {
+  db_query("DELETE FROM {tokenize} WHERE field_name = '%s' AND type_name = '%s'", $form_state['values']['field_name'],  $form_state['values']['type_name']);
 
-  if ($form_values['tokenize'] > 0) {
-    db_query("INSERT INTO {tokenize} (field_name, type_name, method) VALUES ('%s', '%s', %d)", $form_values['field_name'], $form_values['type_name'], $form_values['tokenize']);
+  if ($form_state['values']['tokenize'] > 0) {
+    db_query("INSERT INTO {tokenize} (field_name, type_name, method) VALUES ('%s', '%s', %d)", $form_state['values']['field_name'], $form_state['values']['type_name'], $form_state['values']['tokenize']);
   }
 }
 
@@ -124,7 +123,7 @@
   
   if (!$reset && $cached = cache_get('tokenize')) {
     // See if there's cached data. If so, use that. 
-    $data = unserialize($cached->data);
+    $data = $cached->data;
   }
   else {
     $data = array(
@@ -145,7 +144,7 @@
     if (!empty($cached)) {
       cache_clear_all('tokenize', 'cache');
     }
-    cache_set('tokenize', 'cache', serialize($data), CACHE_PERMANENT);
+    cache_set('tokenize', $data);
   }
 
   if (empty($field_name) && empty($type_name)) {
@@ -161,4 +160,5 @@
   
   return isset($data['by type'][$type_name][$field_name]) ? $data['by type'][$type_name][$field_name] : NULL;
   
-}
\ No newline at end of file
+}
+
