Index: workflow_fields.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/workflow_fields/workflow_fields.install,v
retrieving revision 1.1.4.1
diff -u -r1.1.4.1 workflow_fields.install
--- workflow_fields.install	20 Jul 2007 10:09:30 -0000	1.1.4.1
+++ workflow_fields.install	18 Jun 2008 21:20:22 -0000
@@ -8,18 +8,6 @@
   case 'mysqli':
   case 'mysql':
     $result[] = db_query(
-/*
-<<<QUERY
-CREATE TABLE {workflow_fields} (
-  `sid` int(10) NOT NULL,
-  `name` varchar(100) NOT NULL,
-  `type` varchar(100) NOT NULL,
-  `visible` tinyint(4) NOT NULL,
-  `editable` tinyint(4) NOT NULL,
-  PRIMARY KEY  (`sid`,`name`,`type`)
-);
-QUERY
-*/
 <<<QUERY
 CREATE TABLE {workflow_fields} (
   `sid` int(10) NOT NULL,
@@ -38,7 +26,7 @@
     drupal_set_message(t('PGSQL is currently not supported by workflow_fields.'), 'error');
     break;
   }
-    
+
   if (count($result) == count(array_filter($result))) {
     drupal_set_message(t('The workflow_fields module has successfully added tables to the database.'));
   }
@@ -73,8 +61,6 @@
     drupal_set_message(t('PGSQL is currently not supported by workflow_fields.'), 'error');
     break;
   }
- 
+
   // Note: Variables (if any) should removed here via variable_del().
 }
-
-?>
Index: workflow_fields.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/workflow_fields/workflow_fields.module,v
retrieving revision 1.5.2.12
diff -u -r1.5.2.12 workflow_fields.module
--- workflow_fields.module	1 Apr 2008 20:32:08 -0000	1.5.2.12
+++ workflow_fields.module	18 Jun 2008 21:20:23 -0000
@@ -1,4 +1,4 @@
-<?php // -*-php-*-
+<?php
 // $Id: workflow_fields.module,v 1.5.2.12 2008/04/01 20:32:08 kratib Exp $
 
 /**
@@ -7,7 +7,7 @@
  * It is a useful feature when workflows demand that certain information be hidden or read-only to certain roles.
  *
  */
- 
+
 /**
  * Implementation of hook_help().
  */
@@ -28,7 +28,8 @@
 function workflow_fields_form_alter($form_id, &$form) {
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     workflow_fields_node_form_alter($form_id, $form);
-  } elseif ('workflow_state_add_form' == $form_id) {
+  }
+  elseif ('workflow_state_add_form' == $form_id) {
     workflow_fields_state_form_alter($form_id, $form);
   }
 }
@@ -72,19 +73,11 @@
 
       // For each field, add checkboxes for visible and editable for all roles.
       $fields = $content['fields'];
-      foreach($fields as $field) {
-        #$visible = array_keys($rids);
-        #$editable = array_keys($rids);
+      foreach ($fields as $field) {
         $visible = array();
         $editable = array();
         $result = db_query("SELECT rid, visible, editable FROM {workflow_fields} WHERE sid = %d AND name = '%s'", intval($sid), $field['field_name']);
         while ($access = db_fetch_array($result)) {
-          /*if (!$access['visible']) {
-            unset($visible[array_search($access['rid'], $visible)]);
-          }
-          if (!$access['editable']) {
-            unset($editable[array_search($access['rid'], $editable)]);
-          }*/
           if ($access['visible']) {
             $visible[] = $access['rid'];
           }
@@ -92,9 +85,9 @@
             $editable[] = $access['rid'];
           }
         }
-       
+
         $form['fields'][$type][$field['field_name']]['visible'] = array(
-          '#type' => 'checkboxes', 
+          '#type' => 'checkboxes',
           '#options' => $rids,
           '#default_value' => $visible,
         );
@@ -102,9 +95,10 @@
           '#type' => 'checkboxes',
           '#options' => $rids,
           '#default_value' => $editable,
-        );      
+        );
       }
-    } else {
+    }
+    else {
       watchdog('workflow fields', t('The content type "%type" does not provide metadata information.', array('%type' => $type)));
     }
   }
@@ -117,16 +111,16 @@
   foreach ($form['types']['#value'] as $type) {
     $content = content_types($type);
     $fields = $content['fields'];
-    foreach($fields as $field) {
+    foreach ($fields as $field) {
       $rows[] = array(
-        $type, 
-        $field['widget']['label'].' ('.$field['field_name'].')', 
-        drupal_render($form[$type][$field['field_name']]['visible']), 
+        $type,
+        $field['widget']['label'] .' ('. $field['field_name'] .')',
+        drupal_render($form[$type][$field['field_name']]['visible']),
         drupal_render($form[$type][$field['field_name']]['editable'])
       );
     }
   }
-  $output = theme('table', $header, $rows).'<p />';
+  $output = theme('table', $header, $rows) .'<p />';
   return $output;
 }
 
@@ -137,7 +131,7 @@
       if ($type == 'types') continue;
       foreach ($fields as $key => $field) {
         foreach ($field['visible'] as $rid => $checked) {
-          db_query("INSERT INTO {workflow_fields} (sid, rid, name, type, visible, editable) VALUES (%d, %d, '%s', '%s', %d, %d)", 
+          db_query("INSERT INTO {workflow_fields} (sid, rid, name, type, visible, editable) VALUES (%d, %d, '%s', '%s', %d, %d)",
             $form_values['sid'], $rid, $key, $type, (bool) $checked, (bool) $field['editable'][$rid]
           );
         }
@@ -149,7 +143,7 @@
     // Make sure creation state values are correct.
     $form_values['sysid'] = WORKFLOW_CREATION;
     $form_values['weight'] = WORKFLOW_CREATION_DEFAULT_WEIGHT;
-    $form_values['state'] = t('(creation)'); 
+    $form_values['state'] = t('(creation)');
   }
   return _workflow_submit_form($form_id, $form_values);
 }
@@ -158,7 +152,7 @@
  * Alter the node form by hiding/disabling fields depending on the workflow state.
  * To hide a field, just unset it from the form.
  * To disable a field, replace its form element by a view-only version (by calling the 'view' CCK function).
- */ 
+ */
 function workflow_fields_node_form_alter($form_id, &$form) {
   $node = $form['#node'];
   $sid = workflow_node_current_state($node);
@@ -166,13 +160,13 @@
     $wid = db_result(db_query("SELECT wid FROM {workflow_type_map} WHERE type = '%s'", $form['type']['#value']));
     $sid = db_result(db_query("SELECT sid FROM {workflow_states} WHERE sysid = %d AND wid = %d", WORKFLOW_CREATION, $wid));
   }
-  
+
   // Check for visible/editable flags.
   if (module_exists('content') && ($content = content_types($node->type))) {
     $form['sid'] = array('#type' => 'value', '#value' => $sid);
     $form['submit_chain'] = array('#type' => 'value', '#value' => $form['#submit']);
     $form['#submit'] = array('workflow_fields_node_form_submit' => array());
-    $result = db_query("SELECT * FROM {workflow_fields} WHERE sid = %d AND type = '%s' AND rid IN (%s)", 
+    $result = db_query("SELECT * FROM {workflow_fields} WHERE sid = %d AND type = '%s' AND rid IN (%s)",
       $sid, $node->type, implode(_workflow_fields_compute_groups($node), ',')
     );
     // Compute the OR of permissions among all groups that this user belongs to.
@@ -180,7 +174,9 @@
       $visibles[$row['name']] |= $row['visible'];
       $editables[$row['name']] |= $row['editable'];
     }
-    if (!isset($visibles)) return;
+    if (!isset($visibles)) {
+      return;
+    }
     foreach ($visibles as $key => $visible) {
       $editable = $editables[$key];
       if (!isset($form[$key])) {
@@ -191,13 +187,14 @@
       $field = $content['fields'][$key];
       if (!$visible) {
         $form[$key] = array_merge($form[$key], array('#access' => FALSE));
-        $form[$key.'_default_value'] = array(
+        $form[$key .'_default_value'] = array(
           '#type' => 'value',
           '#value' => $form[$key][0]['value']['#default_value'],
         );
-      } elseif (!$editable) {
+      }
+      elseif (!$editable) {
         $weight = $form[$key]['#weight'];
-        $form[$key.'_default_value'] = array(
+        $form[$key .'_default_value'] = array(
           '#type' => 'value',
           '#value' => $form[$key][0]['value']['#default_value'],
         );
@@ -218,20 +215,22 @@
 }
 
 /**
- * Return an array of rids for the current user, given a node. 
+ * Return an array of rids for the current user, given a node.
  * Return -1 if the current user is the node author.
- */ 
+ */
 function _workflow_fields_compute_groups($node = NULL) {
   global $user;
-  $groups = array_keys($user->roles); 
-  if (isset($node) && ($user->uid == $node->uid)) array_push($groups,-1); # add 'author' group.
+  $groups = array_keys($user->roles);
+  if (isset($node) && ($user->uid == $node->uid)) {
+    array_push($groups, -1); // add 'author' group.
+  }
   return $groups;
 }
 
 /**
  * Process CCK node submission.
  * First load the original node before saving, then invoke the chain of hooks, then overwrite the hidden/disabled fields with their original values.
- */ 
+ */
 function workflow_fields_node_form_submit($form_id, $form_values) {
   $nid = $form_values['nid'];
   $sid = $form_values['sid'];
@@ -242,14 +241,14 @@
   if ($nid) {
     $original_node = node_load($nid);
   }
-  
+
   // Let the node be saved before we restore the original values.
   $goto = _workflow_submit_form($form_id, $form_values);
-  
+
   // Restore the field values that were hidden or read-only.
   if ($nid && $sysid != WORKFLOW_CREATION) {
     $node = node_load(array('nid' => $nid)); // Force node.module to load the node from database instead of cache
-    $result = db_query("SELECT * FROM {workflow_fields} WHERE sid = %d AND type = '%s' AND rid IN (%s)", 
+    $result = db_query("SELECT * FROM {workflow_fields} WHERE sid = %d AND type = '%s' AND rid IN (%s)",
       $form_values['sid'], $form_values['type'], implode(_workflow_fields_compute_groups($original_node), ',')
     );
     while ($row = db_fetch_array($result)) {
@@ -257,23 +256,17 @@
       $editables[$row['name']] |= $row['editable'];
     }
     if (!isset($visibles)) return $goto;
-    
+
     foreach ($visibles as $key => $visible) {
       $editable = $editables[$key];
       if (!$visible || !$editable) {
         $node->$key = $original_node->$key;
       }
     }
-/*
-    // Fix bug #200063 whereby taxonomy term doesn't get updated because of static declarations in taxonomy_node_get_terms().
-    if (isset($form_values['taxonomy'])) {
-      $node->taxonomy = $form_values['taxonomy'];
-    }
-*/
     node_submit($node);
     node_save($node);
   }
-  
+
   return $goto;
 }
 
@@ -286,12 +279,12 @@
     $editables[$row['name']] |= $row['editable'];
   }
   if (!isset($visibles)) return _workflow_submit_form($form_id, $form_values);
-  
+
   foreach ($visibles as $key => $visible) {
     $editable = $editables[$key];
     if (!$visible || !$editable) {
       // For some reason, the value cannot be empty or the node attribute will not get created.
-      $form_values[$key][0]['value'] = empty($form_values[$key.'_default_value']) ? 0 : $form_values[$key.'_default_value'];
+      $form_values[$key][0]['value'] = empty($form_values[$key .'_default_value']) ? 0 : $form_values[$key .'_default_value'];
     }
   }
 
@@ -321,7 +314,7 @@
 /**
  * Render a single field.
  * This function is a copy of cck/content.module:_content_field_view.
- */ 
+ */
 function _workflow_fields_node_view($node, $field, $node_field) {
   $field_types = _content_field_types();
   $teaser = FALSE;
@@ -346,7 +339,7 @@
     }
   }
 
-  return $value;  
+  return $value;
 }
 
 function _workflow_submit_form($form_id, $form_values) {
@@ -370,7 +363,7 @@
 function workflow_fields_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   if ($op != 'view') return;
   $sid = workflow_node_current_state($node);
-  $result = db_query("SELECT * FROM {workflow_fields} WHERE sid = %d AND type = '%s' AND rid IN (%s)", 
+  $result = db_query("SELECT * FROM {workflow_fields} WHERE sid = %d AND type = '%s' AND rid IN (%s)",
     $sid, $node->type, implode(_workflow_fields_compute_groups($node), ',')
   );
   // Compute the OR of permissions among all groups that this user belongs to.
@@ -390,5 +383,3 @@
     }
   }
 }
-
-?>
