Index: cck_fullname.module
===================================================================
--- cck_fullname.module	(revision 432)
+++ cck_fullname.module	(working copy)
@@ -120,9 +120,9 @@
 
     case 'database columns':
       $columns = array(
+        'last' => array('type' => 'varchar', 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
         'first' => array('type' => 'varchar', 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
         'middle' => array('type' => 'varchar', 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
-        'last' => array('type' => 'varchar', 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
       );
       if ($field['max_lengths']['max_length_first'] == 0 || $field['max_lengths']['max_length_first'] > 255) {
         $columns['first']['type'] = 'longtext';
@@ -222,9 +222,10 @@
       break;
     
     case 'view':
-      //TODO if other formats are added, change 'default' below to $formatter after selecting the proper formatter
+      $context = $teaser ? 'teaser' : 'full';
+      $formatter = isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
       foreach ($items as $delta => $item) {
-        $items[$delta]['view'] = content_format($field, $item, 'default', $node);
+        $items[$delta]['view'] = content_format($field, $item, $formatter, $node);
       }
       return theme('field', $node, $field, $items, $teaser, $page);
   }
@@ -236,9 +237,21 @@
 function cck_fullname_field_formatter_info() {
   return array(
     'default' => array(
-      'label' => t('Default'),
+      'label' => t('Default, first middle last'),
       'field types' => array('cck_fullname'),
     ),
+    'last_name_only' => array(
+      'label' => t('Last name only'),
+      'field types' => array('cck_fullname'),
+    ),
+    'first_name_only' => array(
+      'label' => t('First name only'),
+      'field types' => array('cck_fullname'),
+    ),
+    'last_name_first' => array(
+      'label' => t('Last, first middle'),
+      'field types' => array('cck_fullname'),
+    ),
   );
 } // function cck_fullname_field_formatter_info()
 
@@ -280,10 +293,27 @@
         $cck_fullname['middle'] = strip_tags($item['middle']);
       }
       $cck_fullname['last'] = strip_tags($item['last']);
-    
       $output = theme('cck_fullname', $cck_fullname, $field);
-
       return $output;
+    case 'last_name_only':
+      //check the values
+      $cck_fullname['last'] = strip_tags($item['last']);
+      $output = theme('cck_fullname', $cck_fullname, $field);
+      return $output;
+    case 'first_name_only':
+      //check the values
+      $cck_fullname['first'] = strip_tags($item['first']);
+      $output = theme('cck_fullname', $cck_fullname, $field);
+      return $output;
+    case 'last_name_first':
+      //check the values
+      $cck_fullname['first'] = strip_tags($item['first']);
+      if (isset($item['middle'])) {
+        $cck_fullname['middle'] = strip_tags($item['middle']);
+      }
+      $cck_fullname['last'] = strip_tags($item['last']);
+      $output = theme('cck_fullname', $cck_fullname, $field, TRUE);
+      return $output;
   }
 } // function cck_fullname_field_formatter()
 
@@ -292,23 +322,44 @@
  * 
  * @param array $cck_fullname
  * @param array $field
+ * @param boolean $last_first TRUE if displayed last name first
  * @return string $output
  */
-function theme_cck_fullname($cck_fullname, $field) {
+function theme_cck_fullname($cck_fullname, $field, $last_first = FALSE) {
   //create the output
-  $output = $cck_fullname['first'];
-  if (strlen($cck_fullname['first']) == 1) $output .= '. ';
-  else $output .= ' ';
-  
-  if (isset($cck_fullname['middle']) && $field['use_middle']) {
-    $output .= $cck_fullname['middle'];
-    if ($field['middle_initial'] == 1) $output .= '. ';
-    else $output .= ' ';
+  if ($last_first) {
+    if (isset($cck_fullname['last'])) {
+      $output = $cck_fullname['last'];
+      if (strlen($cck_fullname['last']) == 1) $output .= '., ';
+      else $output .= ', ';
+    }
+    if (isset($cck_fullname['first'])) {
+      $output .= $cck_fullname['first'];
+      if (strlen($cck_fullname['first']) == 1) $output .= '. ';
+      else $output .= ' ';
+    }
+    if (isset($cck_fullname['middle']) && $field['use_middle']) {
+      $output .= $cck_fullname['middle'];
+      if ($field['middle_initial'] == 1) $output .= '. ';
+      else $output .= ' ';
+    }
+  } else {
+    if (isset($cck_fullname['first'])) {
+      $output = $cck_fullname['first'];
+      if (strlen($cck_fullname['first']) == 1) $output .= '. ';
+      else $output .= ' ';
+    }
+    if (isset($cck_fullname['middle']) && $field['use_middle']) {
+      $output .= $cck_fullname['middle'];
+      if ($field['middle_initial'] == 1) $output .= '. ';
+      else $output .= ' ';
+    }
+    if (isset($cck_fullname['last'])) {
+      $output .= $cck_fullname['last'];
+      if (strlen($cck_fullname['last']) == 1) $output .= '. ';
+      else $output .= ' ';
+    }
   }
-  $output .= $cck_fullname['last'];
-  if (strlen($cck_fullname['last']) == 1) $output .= '. ';
-  else $output .= ' ';
-  
   return $output;
 } // function theme_cck_fullname()
 
@@ -637,4 +688,37 @@
     }
   }
   return $result;
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_token_values
+ *
+ * @param string $type $type contains the current context -- 'node', 'user', 'global', etc.
+ * @param mixed $object contains the specific node, user, etc. that should be used as the basis for the replacements.
+ * @return array $tokens
+ 
+function cck_fullname_token_values($type, $object = NULL) {
+  drupal_set_message('<pre>Type: ' .print_r($type, TRUE). '</pre>');
+  if ($type == 'node') {
+    $tokens = array();
+//    $node = $object;
+  //  $tokens['fullname'] = $node->name;
+    return $tokens;
+  }
+}*/
+
+/**
+ * Implementation of hook_token_list
+ *
+ * @param string $type indicates the context that token help is being generated for.
+ * @return array $tokens
+
+function cck_fullname_token_list($type = 'all') {
+  drupal_set_message('<pre>Type: ' .print_r($type, TRUE). '</pre>');
+  if ($type == 'user' || $type == 'all') {
+    $tokens = array();
+    //$tokens['user']['name']      = t("The user's name");
+    //$tokens['user']['mail']      = t("The user's email address");
+    return $tokens;
+  }
+} */
\ No newline at end of file
