--- front_page.module.orig	2009-05-13 13:03:00.000000000 -0400
+++ front_page.module	2009-05-13 13:26:17.000000000 -0400
@@ -22,19 +22,25 @@
 function front_page_help($section) { 
   switch ($section) { 
     case 'admin/settings/front': 
-      $roles = user_roles();
+			$roles = user_roles();
       $special_note = '';
       if (count($roles) >= 3) {
-        krsort($roles);
-        $special_note = '<fieldset>'. t('<legend>front page by role usage</legend><p><strong>Note:</strong>When using the front pages by role option, please note that if a user has multiple roles the first role match will determine which front page they see. Here is the order that the roles will be checked (from left to right).</p>') .'<p>';
-        foreach ($roles as $role_id => $role_name) {
-          $special_note .= "<strong>". $role_id ."</strong> ". $role_name ." |  ";
-        }
-        $special_note .= '</p>'. t('<p>The default setting for new roles is SAME AS AUTHENTICATED USERS.</p>') . '</fieldset>';
+        $special_note .= t('<p>The default setting for new roles is SAME AS AUTHENTICATED USERS.</p>');
       }
       return  t('<p>Setup custom front pages for your site. Click on the option to expand the form and customise your settings.</p><p><em>Anonymous User</em> = visitor not logged in  | <em>Authenticated User</em> = visitor who is logged in</p>') . $special_note; 
    } 
 }
+
+function front_page_display_roles_order() {
+  $roles = user_roles();
+
+	foreach ($roles as $role_id => $role_name) {
+    $special_note .= "<strong>". $role_id ."</strong> ". $role_name ." |  ";
+  }
+
+
+
+}
 /** 
  * this function sets the necessary paths etc. so drupal
  * knows where to find the front_page
@@ -63,6 +69,21 @@
  */ 
 function front_page_admin() {
   // Load any existing settings and build the by redirect by role form
+	$form['order'] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#title' => t('Set the order in which your roles will be prioritized'),
+  );
+  
+  $form['order']['frontpage_role_order'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Role Order'),
+    '#default_value' => variable_get('frontpage_role_order', front_page_default_role_order()),
+    '#size' => 40,
+    '#description' => t("If a user is in more than one role, the front page corresponding to the first role id listed (that they are a member of) will be used. Enter a space seperated list of role ids. Remove ids for roles that you don't want checked."),
+  );
+
   $form['byrole'] = array(
     '#type' => 'fieldset',
     '#title' => t('Home pages'),
@@ -246,12 +267,19 @@
     '#description' => t('Change this setting to <em>front_page</em> to activate your front page settings.'),
     '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
   );
+
   
     
  return system_settings_form($form);
 }
 
 
+function front_page_default_role_order() {
+	$rids = array_flip(user_roles());
+	rsort($rids);
+	return implode(' ',$rids);
+}
+
 /***********************************************
  * Function to handle the display of the front page.
  ***********************************************/
@@ -326,14 +354,15 @@
    
    
   $roles = ""; //make sure the roles variable is clear
-  $roles = user_roles(); //load up the user roles for the site
-  krsort($roles); //reverse the order of role types so it checks the highest or more recent role type first.
+  $roles = variable_get('frontpage_role_order',front_page_default_role_order());
+	$roles = explode(' ',$roles);
   $siteroles = count($roles);
      
   /* this is where the front page by role stuff happens  */
   if ($user->uid) { //if the user is logged in and the site has more than 2 roles setup
-    foreach ($roles as $role_id => $role_name) { // run through each role type starting at the most recent working backwards
+    foreach ($roles as $role_id) { // run through each role 
       // if the current visitor has a role type that matches and if the front page setting for that role type is not empty.
+			drupal_set_message("Checking $role_id");
       if (array_key_exists($role_id, $user->roles)) { 
         if ((variable_get("special_notice_text", "") != "") && ($user->access < $check_time)) {
           $output = '<div id="mission">';
