From 06a2d20f7806e3b00f824c12f2462c03ba9cb39a Mon Sep 17 00:00:00 2001
From: TravisCarden <TravisCarden@236758.no-reply.drupal.org>
Date: Fri, 18 May 2012 11:52:36 -0500
Subject: [PATCH] Issue #1588880 by TravisCarden: Added ability to display Current state Views field as ID.

---
 .../includes/workflow_views_handler_field_sid.inc  |   25 ++++++++++++++++++-
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/workflow_views/includes/workflow_views_handler_field_sid.inc b/workflow_views/includes/workflow_views_handler_field_sid.inc
index e144d0d..43d3d27 100644
--- a/workflow_views/includes/workflow_views_handler_field_sid.inc
+++ b/workflow_views/includes/workflow_views_handler_field_sid.inc
@@ -9,8 +9,28 @@
  * Field handler to provide simple renderer that allows linking to a node.
  */
 class workflow_views_handler_field_sid extends views_handler_field {
+
+  /**
+   * Provide machine_name option for to workflow state display.
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $form['machine_name'] = array(
+      '#title' => t('Output ID'),
+      '#description' => t('Display field as the workflow state ID.'),
+      '#type' => 'checkbox',
+      '#default_value' => !empty($this->options['machine_name']),
+    );
+  }
+
   function render($values) {
-    if (empty($values->{$this->field_alias})) {
+    $value = $values->{$this->field_alias};
+
+    if ($this->options['machine_name'] == 1) {
+      return check_plain($value);
+    }
+
+    if (empty($value)) {
       return t('No state');
     }
 
@@ -18,10 +38,11 @@ class workflow_views_handler_field_sid extends views_handler_field {
     if (!isset($states)) {
       $states = workflow_get_states();
     }
-    $output = $states[$values->{$this->field_alias}];
+    $output = $states[$value];
     if (empty($output)) {
       $output = t('Unknown state');
     }
+
     return check_plain($output);
   }
 }
-- 
1.7.4.1

