Index: content_complete.admin.inc
===================================================================
--- content_complete.admin.inc	(revision 451)
+++ content_complete.admin.inc	(working copy)
@@ -19,42 +19,95 @@
 }
 
 /**
+ * Menu Callback Function
+ *  Build output of the tagged content_complete fields
+ *  and allow the ability to assign custom percentages for each field
+ */
+function content_complete_percentage_settings() {
+  $header = t('Displays selected fields for content completion. Give each field a desired percentage.<br />'
+  	. 'The fields will only show up once they have been enabled on the !fieldspage page. They can also be disabled there if no longer required.', array('!fieldspage' => l('Fields', 'admin/settings/content_complete/fields')));
+  $form = drupal_get_form('content_complete_percentage_settings_form');
+  return $header . $form;
+}
+
+/**
+ * Menu Callback Function
+ *  Build output of the tagged content_complete fields
+ *  and allow the ability to assign custom percentages for each field
+ */
+function content_complete_roles_settings() {
+  $header = t('Use this page to select which roles you would like to specify fields for. '
+    .'If the role you want to use isn\'t listed here, then make sure you have given it '
+    .'appropriate !permissions.<br /><br />'
+    .'IMPORTANT: At least one role needs to be specified here and by default that will be '
+    .'authenticated user (if it has permission). Otherwise the last option on the '
+    .'list will be used.', array('!permissions' => l('permissions', 'admin/user/permissions')));
+  $form = drupal_get_form('content_complete_roles_settings_form');
+  return $header . $form;
+}
+
+/**
  * Admin settings form
  */
 function content_complete_admin_settings_form() {
+	
+  global $user;
+	
   // get all content types
   $types = node_get_types('names');
+  // Get all the roles allowed to use content_complete
+  $roles = user_roles(TRUE, 'access content complete');
   
   $form = array();
-  foreach ($types as $content_type => $content_name) {
-    $data = content_complete_admin_settings_form_data($content_type);
-    $type_set = empty($data['default']['type']) ? FALSE : TRUE;    
-
-    $id = $content_type;
-    
-    $form[$id] = array(
-      '#title' => $content_name,
-      '#type' => 'fieldset',
-      '#description' => t('If one or more fields are selected, completeness checks will be run for this content type.'),
-      '#collapsible' => TRUE, 
-      '#collapsed' => ! $type_set 
-    );
-
-    $form[$id]['fields'] = array(
-      '#type' => 'checkboxes', 
-      '#options' => $data['options'], 
-      '#default_value' => $data['default']['fields'] 
-    );
   
+  // See helper function for description
+  $roles_used = _content_complete_get_default_user();
+  	
+  // get all roles that have been chosen on the 'Roles' page
+  $roles = $user->content_complete_roles;
+  	
+  foreach ($roles as $roleid => $role) {
+	$form[$roleid] = array(
+	  '#title' => $role,
+	  '#type' => 'fieldset',
+	  '#collapsible' => TRUE,
+	  '#collapsed' => TRUE,
+  	);
+  	foreach ($types as $content_type => $content_name) {
+  	  $data = content_complete_admin_settings_form_data($content_type);
+  	  $id = $content_type;
+  	  $type_set = empty($data[$roleid]['default']['type']) ? FALSE : TRUE;
+  	  	
+  	  // Determine if there are default values, if not return an empty array
+  	  if (is_array($data[$roleid]['default']['fields'])) {
+  	    $default = $data[$roleid]['default']['fields'];
+  	  } else {
+  	    $default = array();
+  	  }
+  	  	
+  	  $form[$roleid][$id] = array(
+        '#title' => $content_name,
+        '#type' => 'fieldset',
+        '#description' => t('If one or more fields are selected, completeness checks will be run for this content type.'),
+        '#collapsible' => TRUE,
+        '#collapsed' => ! $type_set,
+      );
+        
+      $form[$roleid][$id]['fields'] = array(
+        '#type' => 'checkboxes',
+        '#options' => $data['options'],
+        '#default_value' => $default,
+      );        
+  	}
   }
   
   $form['submit'] = array(
     '#type' => 'submit', 
-    '#value' => t('Save') 
+    '#value' => t('Save')
   );
   
-  $form['#tree'] = TRUE; // return nested array of fields	
-
+  $form['#tree'] = TRUE; // return nested array of fields
+  
   return $form;
 }
 
@@ -62,26 +115,52 @@
  * Admin settings form submit
  */
 function content_complete_admin_settings_form_submit($form, &$form_state) {
+	
+  global $user;
+	
   if (is_array($form_state['values']) && ! empty($form_state['values'])) {
-    db_query("DELETE FROM {content_complete}");
-    foreach ($form_state['values'] as $content_type => $value) {
+  	
+  	$sql = "SELECT * FROM {content_complete}";
+  	$result = db_query($sql);
 
-      if (is_array($value) && isset($value['fields'])) {
-        //$content = array_filter($value['content']);
-        $fields = array_filter($value['fields']);
+	while ($rows = db_fetch_object($result)) {
+		$available[$rows->type][$rows->field_name]['name'] = $rows->field_name;
+		$available[$rows->type][$rows->field_name]['percent'] = $rows->percentage;
+		$available[$rows->type][$rows->field_name]['role'] = $rows->role;
+	}
+	
+	// Delete all values since we have saved them in the above array
+	db_query("DELETE FROM {content_complete}");
+  	
+  	foreach($form_state['values'] as $roleid => $content_types) {
+  	  if (is_array($content_types)) {
+  	    foreach ($content_types as $content_type => $value) {
+  		  $fields = array_filter($value['fields']);
+  	  	  foreach ($fields as $field) {
+  	  	    // Provide a default percentage
+  	  	    $percentage = 0;
+  	  	    // Already in the database, so maintain the percentage value
+  	  	    if ( $field == $available[$content_type][$field]['name'] && $available[$content_type][$field]['percent'] != 0 && $available[$content_type][$field]['role'] == $roleid ) {
+  		      $percentage = $available[$content_type][$field]['percent'];
+  		    }
+  			$sql = "INSERT INTO {content_complete} VALUES ('%s', '%s', %d, %d)";
+  			db_query($sql, $content_type, $field, $percentage, $roleid);
+  	  	  }	
+  	  	}
+  	  }
+  	}
 
-        foreach ($fields as $field) {
-          db_query("INSERT INTO {content_complete} VALUES ('%s', '%s')", $content_type, $field);
-        }
-
-      }
-    }
-
     drupal_set_message(t("Your settings have been saved."));
   }
 }
 
 function content_complete_admin_settings_form_data($content_type) {
+	
+  global $user;
+  
+  // get all roles allowed to use content_complete
+  $roles = user_roles(TRUE, 'access content complete');
+
   /**
    * Get the fields for this content type
    */
@@ -101,17 +180,310 @@
    * Put the default values
    */
   $default_type = $default_fields = array();
-  $tagged_fields = content_complete_get_tagged_fields($content_type);
-  if (! empty($tagged_fields)) {
-    $default_type[] = $content_type;
-    foreach ($tagged_fields as $tagged_field) {
-      $default_fields[] = $tagged_field;
+  
+  foreach ($roles as $roleid => $role) {
+    $temp[$roleid] = content_complete_get_tagged_fields($content_type, $roleid);
+  }
+  foreach ($temp as $roleid => $rows) {
+    // Make sure there is some data
+    if (count($rows) != 0) {
+      $tagged_fields[$roleid][$content_type] = $rows;
     }
   }
   
+  if (!empty($tagged_fields)) {
+   $default_type[] = $content_type;
+   foreach ($tagged_fields as $roleid => $fields) {
+     foreach ($fields as $type => $rows) {
+       foreach ($rows as $row) {
+         $default_fields[] = $row;
+       }
+     }
+     $data[$roleid]['default']['type'] = $default_type;
+     $data[$roleid]['default']['fields'] = $default_fields;
+   }
+  }
+  
   $data['options'] = $options;
-  $data['default']['type'] = $default_type;
-  $data['default']['fields'] = $default_fields;
   
   return $data;
 }
+
+/**
+ * Admin percentages form
+ */
+function content_complete_percentage_settings_form() {
+	
+  global $user;
+
+  // get all content types
+  $types = node_get_types('names');
+  
+  // See helper function for description
+  $roles_used = _content_complete_get_default_user();
+    
+  // get all roles that have been chosen on the 'Roles' page
+  $roles = $user->content_complete_roles;
+  
+  $form = array();
+  	
+  foreach ($roles as $roleid => $role) {
+    $form[$roleid] = array (
+      '#title' => $role,
+  	  '#type' => 'fieldset',
+  	  '#collapsible' => TRUE,
+  	  '#collapsed' => TRUE,
+  	);
+  	foreach ($types as $content_type => $content_name) {
+  	  $data = content_complete_percentage_settings_form_data($content_type);
+  	  $id = $content_type;
+  	  $type_set = empty($data[$roleid]['default']['type']) ? FALSE : TRUE;
+  	  	
+  	  // Only display content types that have been tagged
+  	  if (isset($data[$roleid]['default']['type'][0])) {
+  	    $found = true;
+  	    $form[$roleid][$id] = array(
+  	      '#title' => $content_name .' ('. $data[$roleid]['percentage'] .'%)',
+  	      '#type' => 'fieldset',
+  	      '#collapsible' => TRUE,
+  	      '#collapsed' => !$type_set,
+  	    );
+  	  }
+  	  	
+  	  // Create a textbox with percentage values for each field
+  	  if (is_array($data[$roleid]['default']['fields'])) {
+  	    foreach ($data[$roleid]['default']['fields'] as $fields) {
+  	      foreach ($fields as $key => $field) {
+  	        if ($key) {
+  	  	  	  $form[$roleid][$id]['fields'][$key] = array(
+  	  	  	    '#title' => $key,
+  	  	  	    '#type' => 'textfield',
+  	  	  	    '#size' => 5,
+  	  	  	    '#default_value' => $field,
+  	  	  	  );
+  	  	  	}  	  	  	
+  	  	  }
+  	  	}
+  	  }
+  	  	
+  	  $total_percentage += $data[$roleid]['percentage'];
+  	  	
+  	}
+  	  
+  	if ($total_percentage < 100) {
+      $warning = "You need a further " . (100 - $total_percentage) . "%";  		
+    } elseif ($total_percentage > 100) {
+      $warning = "You need to reduce " . ($total_percentage - 100) . "%";
+    } else {
+  	  $warning = false;
+    }
+      
+    if ($warning && $total_percentage != 0) {
+      drupal_set_message(t($role .": Total percentage is $total_percentage% - $warning"), 'warning', false);
+    }
+  	  
+  	$total_percentage = 0; // Reset the percentage
+  	  
+  }
+  
+  $form['submit'] = array(
+    '#type' => 'submit', 
+	'#value' => t('Save') 
+  );
+    
+  $form['#tree'] = TRUE; // return nested array of fields
+  
+  foreach ($roles as $roleid => $role) {
+  	// Since all roles were included we need to remove those that have
+  	// no data (i.e. only 4 attributes in the array)
+  	if (count($form[$roleid]) < 5) {
+  	  unset($form[$roleid]);
+    }
+  }
+	
+  if ($found) {
+    return $form;
+  }
+	
+}
+
+/**
+ * Admin percentages form submit
+ */
+function content_complete_percentage_settings_form_submit($form, &$form_state) {
+	
+  global $user;
+  	
+  foreach($form_state['values'] as $roleid => $values) {
+    if (is_array($values)) {
+  	  foreach ($values as $content_type => $value) {
+  	    if (is_array($value) && isset($value['fields'])) {
+  	  	  $fields = array_filter($value['fields']);
+  	  	  foreach ($fields as $field => $value) {
+  	  	    $sql = "UPDATE {content_complete} SET percentage = %d WHERE field_name = '%s' AND type = '%s' AND role = %d";
+			$result = db_query($sql, $value, $field, $content_type, $roleid);
+  	  	  }
+  	  	}
+  	  }
+  	}
+  }
+  
+  drupal_set_message(t("Your settings have been saved."));
+
+}
+
+function content_complete_percentage_settings_form_data($content_type) {
+	
+  global $user;  
+    
+  /**
+   * Put the default values
+   */
+  $default_type = $default_fields = array();
+
+  // get all roles allowed to use content_complete
+  $roles = user_roles(TRUE, 'access content complete');
+  
+  foreach ($roles as $roleid => $role) {
+    $temp[$roleid] = content_complete_get_tagged_fields($content_type, $roleid);
+  }
+  foreach ($temp as $roleid => $rows) {
+    // Make sure there is some data
+    if (count($rows) != 0) {
+      $tagged_fields[$roleid][$content_type] = $rows;
+    }
+  }
+    
+  if (!empty($tagged_fields)) {
+    $default_type[] = $content_type;
+    foreach ($tagged_fields as $roleid => $fields) {
+      foreach ($fields as $type => $fields) {
+   	    foreach ($fields as $field) {
+   	  	  $sql = "SELECT percentage FROM {content_complete} WHERE field_name = '%s' AND type = '%s' AND role = %d";
+          $result = db_query($sql, $field, $content_type, $roleid);
+          while ($rows = db_fetch_object($result)) {
+            $default_fields[$roleid][$field] = $rows->percentage;
+  	        $percentage += $rows->percentage;
+  	      }
+  	  	}
+  	  }
+  	    
+  	  $data[$roleid]['default']['type'] = $default_type;
+  	  $data[$roleid]['default']['fields'] = $default_fields;
+  	  $data[$roleid]['percentage'] = $percentage;
+  	    
+  	  $percentage = 0; // Reset the percentage
+  	    
+  	}
+  }
+  
+  return $data;
+  
+}
+
+/**
+ * Admin roles form
+ */
+function content_complete_roles_settings_form() {
+  
+  // Get all the roles allowed to use content_complete
+  $roles = user_roles(TRUE, 'access content complete');
+  
+  // See helper function for description
+  $roles_used = _content_complete_get_default_user();
+  
+  foreach ($roles as $roleid => $role) {
+  	// Exists in the roles_used variable, so check the checkbox
+  	if ($roles_used[$roleid] == $role) {
+  	  $value = 1;
+  	} else {
+  	  $value = 0;
+  	}
+  	
+  	$form['role'][$roleid] = array(
+  	  '#type' => 'checkbox',
+  	  '#title' => $role,
+  	  '#default_value' => $value,
+  	);
+  }
+  
+  $form['submit'] = array(
+	'#type' => 'submit',
+	'#value' => t('Save'),
+  );
+  
+  return $form;
+
+}
+
+/**
+ * Admin roles form submit
+ */
+function content_complete_roles_settings_form_submit($form, &$form_state) {
+	
+  global $user;
+  
+  $values = $form_state['values'];
+  
+  // Get the role name from the role ID
+  $sql_select = "SELECT name FROM {role} WHERE rid = %d";
+  // Delete the values from the database for each role ID 
+  $sql_delete = "DELETE FROM {content_complete} WHERE role = %d";
+  
+  foreach ($values as $id => $row) {
+  	// Value has been checked so add it to the roles_used array
+  	if ($row == 1) {
+  	  $result = db_query($sql_select, $id);
+  	  $name = db_fetch_object($result);
+  	  $roles_used[$id] = $name->name;
+  	// Value has been unchecked so delete it from the database
+  	} elseif (is_numeric($row)) {  		
+  	  $result = db_query($sql_delete, $id);
+  	}
+  }
+  
+  user_save($user, array('content_complete_roles' => $roles_used));
+  
+  drupal_set_message('Your settings have been saved.');
+}
+
+/**
+ * Helper function to see if content_complete_roles exists in the user object.
+ * If it doesn't then it is created with a default role. That role is authenticated
+ * user (if available) or the last possible value that has 'access content complete'
+ * permission.
+ * 
+ * @return $roles_used
+ * An array holding a default role which is the authenticated user or
+ * the last role which has 'access content complete' permission.
+ */
+function _content_complete_get_default_user() {
+	
+  global $user;
+  
+  // Get all the roles allowed to use content_complete
+  $roles = user_roles(TRUE, 'access content complete');
+	
+  // Safety check to make sure that 'content_complete_roles' exists in the user object
+  // If not then it is given a default role which is the authenticated user (if
+  // applicable) or the last possible value that has 'access content complete' permission
+  if (isset($user->content_complete_roles)) {
+  	$roles_used = $user->content_complete_roles;
+  } else {
+  	foreach ($roles as $roleid => $role) {
+  	  if ($role == 'authenticated user') {
+  	    $roles_used = array($roleid => $role);
+  	  }
+    }
+    // Authenticated user did not exist  
+    if (!is_array($roles_used)) {
+  	  foreach ($roles as $roleid => $role) {
+  	    $roles_used = array($roleid => $role);
+  	  }
+    }
+    user_save($user, array('content_complete_roles' => $roles_used));
+  }
+  
+  return $roles_used;
+
+}
\ No newline at end of file
Index: content_complete.install
===================================================================
--- content_complete.install	(revision 451)
+++ content_complete.install	(working copy)
@@ -25,6 +25,12 @@
       'field_name' => array(
         'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => t('{content_node_field}.field_name') 
       ) 
+      ,'percentage' => array(
+  		'type' => 'int', 'length' => '3', 'not null' => FALSE, 'default' => '0', 'description' => t('{content_node_field}.percentage')
+  	  )
+  	  ,'role' => array(
+  	    'type' => 'int', 'length' => '3', 'not null' => FALSE, 'default' => '2', 'description' => t('(content_node_field).role')
+  	  ),
     ) 
   );
   
@@ -33,4 +39,11 @@
 
 function content_complete_uninstall() {
   drupal_uninstall_schema('content_complete');
+}
+
+function content_complete_update_6100() {
+  $ret = array();
+  db_add_field($ret, 'content_complete', 'percentage', array('type' => 'int', 'default' => 0));
+  db_add_field($ret, 'content_complete', 'role', array('type' => 'int', 'default' => 2));
+  return $ret;
 }
\ No newline at end of file
Index: content_complete.module
===================================================================
--- content_complete.module	(revision 451)
+++ content_complete.module	(working copy)
@@ -20,17 +20,46 @@
 /**
  * Implementation of hook_menu()
  */
-function content_complete_menu() {  
+function content_complete_menu() {
+	
+  //the admin page
   $items['admin/settings/content_complete'] = array(
-    'title' => 'Content Complete', 
-    'description' => 'Tag CCK fields as required for percent complete handling.', 
-    'page callback' => 'content_complete_admin_settings', 
-    'access arguments' => array(
-      'administer content complete' 
-    ), 
+    'title' => 'Content Complete',
+    'description' => t('Tag CCK fields as required for percent complete handling.'),
+    'page callback' => 'content_complete_roles_settings',
+    'access arguments' => array('administer content complete'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'content_complete.admin.inc',
+  );
+	
+  $items['admin/settings/content_complete/fields'] = array(
+    'title' => 'Fields',
+    'description' => 'Tag CCK fields as required for percent complete handling.',
+    'page callback' => 'content_complete_admin_settings',
+    'access arguments' => array('administer content complete'),
+    'type' => MENU_LOCAL_TASK,
     'file' => 'content_complete.admin.inc'
   );
   
+  $items['admin/settings/content_complete/percentages'] = array(
+  	'title' => 'Percentages',
+  	'description' => 'After specifying the fields you can give each one a specific percentage.',
+  	'page callback' => 'content_complete_percentage_settings',
+  	'access arguments' => array('administer content complete'),
+  	'type' => MENU_LOCAL_TASK,
+  	'file' => 'content_complete.admin.inc'  
+  );
+  
+  $items['admin/settings/content_complete/roles'] = array(
+    'title' => 'Roles',
+    'description' => 'Select which roles you would like to be specified for each field.',
+    'page callback' => 'content_complete_roles_settings',
+    'access arguments' => array('administer content complete'),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'content_complete.admin.inc',
+    'weight' => -10,
+  );
+  
   return $items;
 }
 
@@ -47,18 +76,41 @@
           $blocks[$type]['info'] = t('Content Complete: !name', array('!name' => $name));
           $blocks[$type]['cache'] = BLOCK_NO_CACHE;
         }
+        $blocks['collate_all_profiles']['info'] = t('Content Complete: Collate all profiles');
+        $blocks['collate_all_profiles']['cache'] = BLOCK_NO_CACHE;
         return $blocks;
         break;
       case 'view':
         $type = $delta;
         $types = node_get_types('names');
-        if (! isset($types[$type]))
-          return;
-        $complete_data = content_complete_get_data($type);
+        $special_block = "collate_all_profiles";
+        
+        if (! isset($types[$type])){
+          if($type !== $special_block){
+            return;
+          }
+        }
+        
+        if($delta == $special_block) {
+          $result = db_query("SELECT distinct type FROM {content_complete}");
+          $content_types = array();
+          while ($data = db_fetch_object($result)) {
+            $content_types[] = $data->type;
+          }
+          $complete_data = content_complete_get_data($content_types);
+        } else {
+          $complete_data = content_complete_get_data($type);
+        }
+        
         $block['subject'] = t('!name', array(
           '!name' => $types[$type] 
           )
         );
+        
+        if (!isset($types[$type])) {
+        	$block['subject'] = t('Collate All Profiles');
+        }
+        
         // only display the block when 100% has not been reached
         if (! empty($complete_data) && $complete_data['percent'] != 100) {
           $block['content'] = theme('content_complete_profile_percent_complete', $complete_data);
@@ -134,18 +186,43 @@
  *   completed etc.
  */
 function content_complete_get_data($content_type, &$user = NULL) {
+  
+  $user_fields_original = array();
+  $user_fields = array();
+  $tagged_fields = array();
+  $fields = array();
   if (!$user) {
     global $user;
   }
   
-  $fields = content_complete_get_fields($content_type); // all fields
-  $tagged_fields = content_complete_get_tagged_fields($content_type); // fields tagged for completed (can be empty)
-  $user_fields = content_complete_get_user_fields($content_type, $user); // fields completed by the user (can be empty)  
+  if(!is_array($content_type)){
+    $fields = content_complete_get_fields($content_type); // all fields
+    $tagged_fields = content_complete_get_tagged_fields($content_type); // fields tagged for completed (can be empty)
+    $user_fields = content_complete_get_user_fields($content_type, $user); // fields completed by the user (can be empty)
+  } else {
+    foreach($content_type as $type) {
+      $fields = array_merge($fields, content_complete_get_fields($type)); // all fields
+      $tagged_fields = array_merge($tagged_fields, content_complete_get_tagged_fields($type));      
+      //store contents of content_complete_get_user_fields within $user_fields_original with a key of nid.
+      //this is used later on to retrieve the nid of a field element.
+      $tmp = content_complete_get_user_fields($type, $user);
+      $nid = $tmp[0]['nid']; //$nid associated with the user fields returned.
+      $user_fields_original[$type] = $tmp[0];
+      // Make sure the array has at least some content
+      if (count($tmp) > 0) {
+      	$user_fields = array_merge($user_fields, $tmp[0]);
+      }
+      #unset($user_fields['title']);
+      unset($user_fields['nid']);
+    }
+  }
 
   /**
    * Only consider the first instance for now
    */
   if (is_array($user_fields) && !empty($user_fields)) {
+  	  	
+  	if(!is_array($content_type))
     $user_fields = $user_fields[0];
   } 
   else {
@@ -158,29 +235,78 @@
   $total = 0;
   $nextfield_set = FALSE;
   
-  // compare the two arrays and compute percentages etc.
-  foreach ($tagged_fields as $key => $value) {
-    if ($user_fields[$value] == '') { // empty field
-      if ($nextfield_set === FALSE) {
-        $nextfield_set = TRUE;
-        $nextfield = $fields[$value]['label'];
-        $nextname = $value;
-      }
-    } 
-    else {
-      $complete++;
-    }
+  $incomplete_fields = array();
+  
+  if (!is_array($content_type)) {
+    foreach ($tagged_fields as $key => $value) {
+  	  if ($user_fields[$value] == '') { // empty field
+  	    $incomplete_fields[] = $value;
+  	    if ($nextfield_set === FALSE) {
+  	  	  $nextfield_set = TRUE;
+  	  	  $nextfield = $fields[$value]['label'];
+  	  	  $nextname = $value;
+  	    }
+  	  } else {
+  	    $complete++;
+  	  }
+    }  
   }
+  
+  $complete_data = array();
 
-  $dec = 0;
-  if (count($tagged_fields)) {
-    $dec = number_format(($complete / count($tagged_fields)), 2);
+  // Only work out the percentage if the content type is individual  
+  if (!is_array($content_type)) {
+  	$dec = 0;
+  	if (count($tagged_fields)) {
+      $dec = number_format(($complete / count($tagged_fields)), 2);
+  	}
+  	$percent = $dec * 100;
+  	if ($nextfield_set) {
+      $next = number_format((($complete + 1) / count($tagged_fields)), 2);
+      $nextpercent = $next * 100;
+  	}
+  } else {
+  	$complete_data['allprofiles'] = true;
+  	// Get each of the users' roles
+  	$roles = $user->roles;
+  	foreach ($roles as $roleid => $role) {
+  	
+  	  $sql = "SELECT * FROM {content_complete} WHERE field_name = '%s' AND type = '%s' AND role = %d";
+	
+	  foreach($user_fields_original as $individual_type => $individual_fields) {
+	    // Check to make sure there is at least some data in the array
+	    if (count($individual_fields) > 0) {
+	      foreach ($individual_fields as $individual_field => $individual_value) {
+		    // Exclude the 'nid' value as it shouldn't be included and make sure the field has data
+		    if ($individual_field != 'nid' && $individual_value != '') {
+			  $result = db_query($sql, $individual_field, $individual_type, $roleid);
+			  while ($log = db_fetch_object($result)) {
+			    $percent += $log->percentage;
+			  }
+		    // Field is empty, include in incomplete_fields
+		    } else {
+		  	  $sql_check = "SELECT field_name, percentage FROM {content_complete} WHERE type = '%s' AND role = %d";
+		  	  $result_check = db_query($sql_check, $individual_type, $roleid);
+		  	  while ($log = db_fetch_object($result_check)) {
+		  	    foreach ($tagged_fields as $id => $tagged_field) {
+		  	  	  // Only get those fields that are related to the specific role
+		  	  	  if ($log->field_name == $tagged_field) {
+		  	  	    // Make sure to only include the tagged fields
+		  	  	    if ($tagged_field == $individual_field) {
+		  	  	  	  $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['machine_name'] = $individual_field;
+				      $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['readable_name'] = $fields[$individual_field]['label'];
+				      $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['type'] = $individual_type;
+				      $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['percent'] = $log->percentage;
+		  	  	    }
+		  	  	  }
+		  	    }
+		  	  } 
+		    }
+		  }
+	    }
+	  }
+  	}
   }
-  $percent = $dec * 100;
-  if ($nextfield_set) {
-    $next = number_format((($complete + 1) / count($tagged_fields)), 2);
-    $nextpercent = $next * 100;
-  }
   
   $incomplete = count($tagged_fields) - $complete;
   $total = count($tagged_fields);
@@ -193,8 +319,7 @@
     if ($percent <= $leq_percent) break;
     $leq_percent+=25;
   }
-  
-  $complete_data = array();
+
   $complete_data['nid'] = $nid;
   $complete_data['percent'] = $percent;
   $complete_data['leq_percent'] = $leq_percent;
@@ -210,8 +335,8 @@
   if (module_exists('i18ncontent')) {
     $complete_data['name'] = tt("nodetype:type:$content_type:name", $type_names[$content_type]);
   }
-  else {
-    $complete_data['name'] = $type_names[$content_type];
+  elseif(!is_array($content_type)) {
+    $complete_data['name'] = $type_names[$content_type]; // put human readble name
   }
   
   return $complete_data;
@@ -302,13 +427,24 @@
  * @return 
  *   Array of fields that have been tagged for completion.
  */
-function content_complete_get_tagged_fields($content_type) {
+function content_complete_get_tagged_fields($content_type, $roleid = 0) {
+  
   $tagged = array();
-  $sql = "SELECT field_name FROM {content_complete} WHERE type = '%s'";
-  $result = db_query($sql, $content_type);
-  while ($data = db_fetch_object($result)) {
-    $tagged[] = $data->field_name;
+  
+  if ($roleid != 0) {
+    $sql = "SELECT field_name FROM {content_complete} WHERE type = '%s' AND role = %d";
+    $result = db_query($sql, $content_type, $roleid);
+    while ($data = db_fetch_object($result)) {
+      $tagged[] = $data->field_name;
+    }
+  } else {
+    $sql = "SELECT field_name FROM {content_complete} WHERE type = '%s'";
+    $result = db_query($sql, $content_type);
+    while ($data = db_fetch_object($result)) {
+      $tagged[] = $data->field_name;
+    }
   }
+    
   return $tagged;
 }
 
Index: content_complete.theme.inc
===================================================================
--- content_complete.theme.inc	(revision 451)
+++ content_complete.theme.inc	(working copy)
@@ -40,14 +40,29 @@
   $output .= '</div>';
   $output .= '</div>';
 
-  if ($complete_data['nextfield'] && $complete_data['nextpercent']) {
-    $output .= t('Filling out <i>!nextfield</i> will bring !typename to !complete%.', array(
-      '!nextfield' => l($complete_data['nextfield'], 'node/'. $complete_data['nid'] .'/edit', array(
-        'query' => 'content_complete_fieldname='. $complete_data['nextname'] 
-      )),
-      '!typename' => $complete_data['name'],
-      '!complete' => $complete_data['nextpercent']
-    ));
+  if(!isset($complete_data['allprofiles']) && !$complete_data['allprofiles']){
+    if ($complete_data['nextfield'] && $complete_data['nextpercent']) {
+      $output .= t('Filling out <i>!nextfield</i> will bring !typename to !complete%.', array(
+          '!nextfield' => l($complete_data['nextfield'], 'node/'. $complete_data['nid'] .'/edit', array(
+          'query' => 'content_complete_fieldname='. $complete_data['nextname']
+                 )),
+          '!typename' => $complete_data['name'],
+          '!complete' => $complete_data['nextpercent']
+      ));
+    }
+  } else {
+    if(isset($complete_data['incomplete_fields']) && count($complete_data['incomplete_fields'] != 0)){
+      foreach( $complete_data['incomplete_fields'] as $nid => $field_a ){
+        foreach( $field_a as $field_name => $name_a ){
+          $output .= "<li>Fill out ";
+          $output .= l($name_a['readable_name'], "node/$nid/edit");
+          $output .= " (+ " . $name_a['percent'] . "%)</li>";
+        }
+      }
+    // No data for this role so don't show anything
+    } else {
+      $output = '';
+    }
   }
   
   return $output;
