--- workflow/workflow_access.module	Thu Jul 10 02:27:50 2008
+++ workflow/workflow_access.module	Thu Nov 06 18:03:48 2008
@@ -94,12 +94,8 @@
 
   // A list of roles available on the site and our 
   // special -1 role used to represent the node author.
-  // TODO i think there is an API call for this -- user_roles() perhaps?
-  $rids = array('-1' => t('author'));
-  $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name");
-  while ($obj = db_fetch_object($result)) {
-    $rids[$obj->rid] = $obj->name;
-  }
+  $rids = user_roles();
+  $rids['-1'] = t('author');
 
   $form['workflow_access'] = array('#type' => 'fieldset', 
     '#title' => t('Access control'),
@@ -118,14 +114,9 @@
     $view = $update = $delete = array();
 
     $result = db_query("SELECT * from {workflow_access} where sid = %d", $sid);
-
-    // Allow view grants by default for anonymous and authenticated users, 
-    // if no grants were set up earlier.
-    if (db_num_rows($result) == 0) {
-      $view = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);
-    }
-
+    $count = 0;
     while ($access = db_fetch_object($result)) {
+      $count++;
       if ($access->grant_view) {
         $view[] = $access->rid;
       }
@@ -137,6 +128,12 @@
       }
     }
     
+    // Allow view grants by default for anonymous and authenticated users, 
+    // if no grants were set up earlier.
+    if (!$count) {
+      $view = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);     
+    }
+    
     // TODO better tables using a #theme function instead of direct #prefixing
     $form['workflow_access'][$sid] = array(
       '#type' => 'fieldset', 
@@ -169,7 +166,7 @@
   }
   // Place our block comfortably down the page.
   $form['submit']['#weight'] = 10;
-  $form['#submit'] += array('workflow_access_form_submit' => array());
+  $form['#submit'][] = 'workflow_access_form_submit';
 }
 
 /**
