? front_page.1.63+patch.module
? front_page.module.patch
? po
Index: front_page.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/front/front_page.module,v
retrieving revision 1.28.2.1
diff -u -r1.28.2.1 front_page.module
--- front_page.module	10 Jul 2007 04:36:08 -0000	1.28.2.1
+++ front_page.module	15 Aug 2007 09:21:00 -0000
@@ -1,62 +1,63 @@
 <?php
-// $Id: front_page.module,v 1.28.2.1 2007/07/10 04:36:08 augustin Exp $ 
-/** 
- *  
+// $Id: front_page.module,v 1.28.2.1 2007/07/10 04:36:08 augustin Exp $
+/**
+ *
  * This module allows the user to set a custom front page
  * to the Drupal installation.
- * 
+ *
  * This version works with Drupal 4.7 and will not work with Drupal 4.5 or Drupal 4.6
  *
  *
  * This module was developed by various members of the drupal community
  * and is maintained by Dublin Drupaller.
- * 
+ *
  * If you have any ideas/patches or requests, please post them on the drupal.org
  * site or email us at gus(at)modernmediamuse.com
  *
  *
  * Updated September 11th with a front page by role type option by Dublin Drupaller
  *
- *   
- */ 
-/** 
- * Implementation of hook_help(). 
- * 
- * This is the explanatory text that appears in your administer - modules page 
+ *
+ */
+/**
+ * Implementation of hook_help().
+ *
+ * This is the explanatory text that appears in your administer - modules page
  * where you switch on/off modules
- */ 
- 
- function front_page_help($section) { 
-  switch ($section) { 
-    case 'admin/modules#description': 
-      // This description is shown in the listing at admin/modules. 
-      return t('Allows you to setup custom front pages for your site. After enabling this module, click on %link to setup your custom front pages.', array('%link'=>l('admin/settings/front_page', 'admin/settings/front_page'))); 
-       case 'admin/settings/front_page': 
-      // This description is shown in the listing at admin/modules and if there are more than 2 roles, a special note on how to use the front_page by role is displayed. 
+ */
+
+function front_page_help($section) {
+  switch ($section) {
+    case 'admin/modules#description':
+      // This description is shown in the listing at admin/modules.
+      return t('Allows you to setup custom front pages for your site. After enabling this module, click on %link to setup your custom front pages.',
+        array('%link' => l('admin/settings/front_page', 'admin/settings/front_page')));
+    case 'admin/settings/front_page':
+      // This description is shown in the listing at admin/modules and if there are more than 2 roles, a special note on how to use the front_page by role is displayed.
       $roles = "";
       $roles = user_roles();
       if (count($roles) >= 3) {
-      krsort($roles);
-      $special_note .= "<fieldset><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>";
+        krsort($roles);
+        $special_note .= "<fieldset><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 .= "<strong>". $role_id ."</strong> ". $role_name ." |  ";
         }
-       $special_note .=  '<p>The default setting for new roles is SAME AS AUTHENTICATED USERS.</p></fieldset>';
+      $special_note .=  '<p>The default setting for new roles is SAME AS AUTHENTICATED USERS.</p></fieldset>';
       }
-      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<br><em>Authenticated User</em> - visitor who is logged in</p>'. $special_note .'</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<br /><em>Authenticated User</em> - visitor who is logged in</p>'. $special_note .'</p>');
+  }
+}
+
+/**
  * this function sets the necessary paths etc. so drupal
  * knows where to find the front_page
- * 
+ *
  * in your Administer - Settings make sure default front page is set
  * to front_page
- * 
- * Please note that I have left the Title blank below so nothing appears above the 
+ *
+ * Please note that I have left the Title blank below so nothing appears above the
  * page when it is displayed.
- */ 
+ */
 function front_page_menu($may_cache) {
   if ($may_cache) {
     $items = array();
@@ -66,219 +67,335 @@
       'callback' => 'front_page',
       'access' => TRUE,
       'type' => MENU_SUGGESTED_ITEM);
-  } 
+  }
   return $items;
 }
-/** 
+/**
  * this function sets up the admin/settings/front_page settings page
- * 
- */ 
+ *
+ */
 function front_page_settings() {
  // Load any existing settings and build the by redirect by role form
-  $form['byrole'] = array('#type' => 'fieldset','#title' => t('Home pages'),'#description' => t('Designate a home page for each role. "Splash" pages will be used only when users are connecting from external sites. Spash pages must be in the form "node/x" where x is the id of a node, e.g., "node/21" (without the quotes). Only the body of the node will be displayed. Home pages are displayed when users follow internal home links, or for external links where there is no splash page designated, and may point to any page on the site.'),'#theme' => 'front_page_roles','#collapsible' => TRUE,'#tree' => TRUE);
+  $form['byrole'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Home pages'),
+    '#description' => t('Designate a home page for each role. "Splash" pages will be used only when users are connecting from external sites. Splash pages must be in the form "node/x" where x is the id of a node, e.g., "node/21" (without the quotes). Only the body of the node will be displayed. Home pages are displayed when users follow internal home links, or for external links where there is no splash page designated, and may point to any page on the site.'),
+    '#theme' => 'front_page_roles',
+    '#collapsible' => TRUE,
+    '#tree' => TRUE);
 // build the form for roles
   $roles = user_roles();
   foreach (element_children($roles) as $role) {
   $rolename = $roles[$role];
-  $form[$role] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Front Page for '. $rolename .''));
-  $form[$role]['front_'. $role .'_text'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => variable_get('front_'. $role .'_text', ''), '#cols' => 60, '#rows' => 20, '#description' => t('Paste your HTML or TEXT here for visitors to your site who are already logged in. <br><br>You can paste in the full HTML code for a complete page and include a different style sheet in the HEAD of the document if you want a completely different layout and style to the rest of your site.'));
-  if ($role == 2) {$form[$role]['front_'. $role .'_type'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_'. $role .'_type','themed'), '#options' => array('themed' => t('themed'), 'full' => t('full'), 'redirect' => t('redirect'),'same' => t('same'),), '#description' => t('<P><strong>THEMED</strong> means your default layout, theme and stylesheet will be loaded with your custom front_page. <br><strong>FULL</strong> allows you to have a completely different layout, style sheet etc.<br><strong>REDIRECT</strong> will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.<br><strong>SAME</strong> will display the same content as for Anonymous (not logged in) users.</p>'),);}
-  if ($role > 2) {$form[$role]['front_'. $role .'_type'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_'. $role .'_type','sameasauth'), '#options' => array('themed' => t('themed'), 'full' => t('full'), 'redirect' => t('redirect'),'sameasauth' => t('same as authenticated users'),), '#description' => t('<P><strong>THEMED</strong> means your default layout, theme and stylesheet will be loaded with your custom front_page. <br><strong>FULL</strong> allows you to have a completely different layout, style sheet etc.<br><strong>REDIRECT</strong> will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.<br><strong>SAME AS AUTHENTICATED</strong> will display the same content as for Authenticated (logged in) users.</p>'),);}
-  else {$form[$role]['front_'. $role .'_type'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_'. $role .'_type','themed'), '#options' => array('themed' => t('themed'), 'full' => t('full'), 'redirect' => t('redirect'),), '#description' => t('<P><strong>THEMED</strong> means your default layout, theme and stylesheet will be loaded with your custom front_page. <br><strong>FULL</strong> allows you to have a completely different layout, style sheet etc.<br><strong>REDIRECT</strong> will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.</p>'),);}
-  $form[$role]['front_'. $role .'_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect to'), '#default_value' => variable_get('front_'. $role .'_redirect', 'node'), '#cols' => 20, '#rows' => 1, '#description' => t('If you have selected <strong>REDIRECT</strong> you need to specify where the user should be pointed to.  If you are not using clean URLs, specify the part after "?q=".  If unsure, specify "node".'));  
-  $form[$role]['front_'. $role .'_php'] = array('#type' => 'checkbox', '#title' => t('Allow embedded PHP code in front page for authenticated users'), '#return_value' => 1, '#default_value' => variable_get('front_'. $role .'_php',0), '#description' => t('If this option is enabled, the body text can have embedded &lt;?php...?&gt; tags with PHP code inside. Click on the special Handbook pages for tips on <a href="http://drupal.org/node/23220">Using PHP snippets in your front_page</a>.')); 
-  }  
- 
- 
- $form['special_notice'] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Custom notice for Authenticated Users who haven\'t visited the site for a set period'));
- $form['special_notice']['special_notice_time'] = array(
-	  '#type' => 'select', 
-	  '#title' => t('Been away for'), 
-	  '#default_value' => variable_get('special_notice_time',''), 
-	  '#options' => array(
-		  'one day' =>t('one day') ,
-		  'one week' =>t('one week') , 
-		  'one month' =>t('one month'), 
-		  'three months' => t('three months'),
-		  'six months' => t('six months'),
-		  'one year' => t('one year'),), 
-	  '#description' => t('<p>The length of time to check for when users see the special notice which will be displayed as a <em>mission</em> style notice on the front page.<p> '),
-	  );
-  $form['special_notice']['special_notice_text'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => variable_get('special_notice_text', ''), '#cols' => 60, '#rows' => 10, '#description' => t('Paste your HTML or TEXT here. It will be displayed as a <em>mission</em> style notice on the front page.'));
-   
-  
-  $form['override'] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Override your HOME breadcrumb links'));
-  $form['override']['front_page_breadcrumb'] = array('#type' => 'checkbox', '#title' => t('Redirect your site HOME links'), '#return_value' => 1, '#default_value' => variable_get('front_page_breadcrumb',0), '#description' => t('Check this box if you want to redirect users who click on any HOME links (including the HOME breadcrumb link). Useful if you have a splash page you don\'t want users brought back to when they click on HOME links from within your site.')); 
-  $form['override']['front_page_breadcrumb_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect your site HOME links to'), '#default_value' => variable_get('front_page_breadcrumb_redirect', ''), '#cols' => 20, '#rows' => 1, '#description' => t('Specify where the user should be redirected to. An example would be <em>node/12</em>. Leave blank when you\'re not using HOME redirect.'));  
-  
-  $form['site'] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => FALSE, '#title' => t('Activate your front_page settings'));
-  $form['site']['site_frontpage'] = array('#type'          => 'textfield', '#title'         => t('Default Front page'), '#default_value' => variable_get('site_frontpage', 'node'), '#cols'          => 20, '#rows'          => 1, '#description'   => t('Once you are happy how your pages <a href="%url">look</a> change your default front page setting from <em>%node</em> to <em>%front_page</em>.', array('%url' => base_path() . 'front_page', '%node' => 'node', '%front_page' => 'front_page')),);  
-  return $form; 
+  $form[$role] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#title' => t('Front Page for '. $rolename .''));
+  $form[$role]['front_'. $role .'_text'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Body'),
+    '#default_value' => variable_get('front_'. $role .'_text', ''),
+    '#cols' => 60,
+    '#rows' => 20,
+    '#description' => t('Paste your HTML or TEXT here for visitors to your site who are already logged in. <br /><br />You can paste in the full HTML code for a complete page and include a different style sheet in the HEAD of the document if you want a completely different layout and style to the rest of your site.'));
+  if ($role == 2) {
+    $form[$role]['front_'. $role .'_type'] = array(
+      '#type' => 'select',
+      '#title' => t('Select type'),
+      '#default_value' => variable_get('front_'. $role .'_type', 'themed'),
+      '#options' => array(
+        'themed' => t('themed'),
+        'full' => t('full'),
+        'redirect' => t('redirect'),
+        'same' => t('same')
+        ),
+      '#description' => t('<p><strong>THEMED</strong> means your default layout, theme and stylesheet will be loaded with your custom front_page. <br /><strong>FULL</strong> allows you to have a completely different layout, style sheet etc.<br /><strong>REDIRECT</strong> will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.<br /><strong>SAME</strong> will display the same content as for Anonymous (not logged in) users.</p>')
+      );
+  }
+  if ($role > 2) {
+    $form[$role]['front_'. $role .'_type'] = array(
+      '#type' => 'select',
+      '#title' => t('Select type'),
+      '#default_value' => variable_get('front_'. $role .'_type', 'sameasauth'),
+      '#options' => array(
+        'themed' => t('themed'),
+        'full' => t('full'),
+        'redirect' => t('redirect'),
+        'sameasauth' => t('same as authenticated users')
+        ),
+      '#description' => t('<p><strong>THEMED</strong> means your default layout, theme and stylesheet will be loaded with your custom front_page. <br /><strong>FULL</strong> allows you to have a completely different layout, style sheet etc.<br /><strong>REDIRECT</strong> will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.<br /><strong>SAME AS AUTHENTICATED</strong> will display the same content as for Authenticated (logged in) users.</p>')
+      );
+  }
+  else {
+    $form[$role]['front_'. $role .'_type'] = array(
+      '#type' => 'select',
+      '#title' => t('Select type'),
+      '#default_value' => variable_get('front_'. $role .'_type', 'themed'),
+      '#options' => array(
+        'themed' => t('themed'),
+        'full' => t('full'),
+        'redirect' => t('redirect')
+        ),
+      '#description' => t('<p><strong>THEMED</strong> means your default layout, theme and stylesheet will be loaded with your custom front_page. <br /><strong>FULL</strong> allows you to have a completely different layout, style sheet etc.<br /><strong>REDIRECT</strong> will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.</p>')
+      );
+  }
+  $form[$role]['front_'. $role .'_redirect'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Redirect to'),
+    '#default_value' => variable_get('front_'. $role .'_redirect', 'node'),
+    '#cols' => 20,
+    '#rows' => 1,
+    '#description' => t('If you have selected <strong>REDIRECT</strong> you need to specify where the user should be pointed to.  If you are not using clean URLs, specify the part after "?q=".  If unsure, specify "node".')
+    );
+  $form[$role]['front_'. $role .'_php'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow embedded PHP code in front page for authenticated users'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('front_'. $role .'_php', 0),
+    '#description' => t('If this option is enabled, the body text can have embedded &lt;?php...?&gt; tags with PHP code inside. Click on the special Handbook pages for tips on <a href="http://drupal.org/node/23220">Using PHP snippets in your front_page</a>.')
+    );
+  }
+
+
+  $form['special_notice'] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#title' => t('Custom notice for Authenticated Users who haven\'t visited the site for a set period')
+    );
+  $form['special_notice']['special_notice_time'] = array(
+    '#type' => 'select',
+    '#title' => t('Been away for'),
+    '#default_value' => variable_get('special_notice_time', ''),
+    '#options' => array(
+      'one day'      => t('one day') ,
+      'one week'     => t('one week'),
+      'one month'    => t('one month'),
+      'three months' => t('three months'),
+      'six months'   => t('six months'),
+      'one year'     => t('one year')
+      ),
+    '#description' => t('<p>The length of time to check for when users see the special notice which will be displayed as a <em>mission</em> style notice on the front page.<p> '),
+    );
+  $form['special_notice']['special_notice_text'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Body'),
+    '#default_value' => variable_get('special_notice_text', ''),
+    '#cols' => 60,
+    '#rows' => 10,
+    '#description' => t('Paste your HTML or TEXT here. It will be displayed as a <em>mission</em> style notice on the front page.')
+    );
+
+  $form['override'] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#title' => t('Override your HOME breadcrumb links')
+    );
+  $form['override']['front_page_breadcrumb'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Redirect your site HOME links'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('front_page_breadcrumb', 0),
+    '#description' => t('Check this box if you want to redirect users who click on any HOME links (including the HOME breadcrumb link). Useful if you have a splash page you don\'t want users brought back to when they click on HOME links from within your site.')
+    );
+  $form['override']['front_page_breadcrumb_redirect'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Redirect your site HOME links to'),
+    '#default_value' => variable_get('front_page_breadcrumb_redirect', ''),
+    '#cols' => 20,
+    '#rows' => 1,
+    '#description' => t('Specify where the user should be redirected to. An example would be <em>node/12</em>. Leave blank when you\'re not using HOME redirect.')
+    );
+
+  $form['site'] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#title' => t('Activate your front_page settings')
+    );
+  $form['site']['site_frontpage'] = array(
+    '#type'          => 'textfield',
+    '#title'         => t('Default Front page'),
+    '#default_value' => variable_get('site_frontpage', 'node'),
+    '#cols'          => 20,
+    '#rows'          => 1,
+    '#description'   => t('Once you are happy how your pages <a href="%url">look</a> change your default front page setting from <em>%node</em> to <em>%front_page</em>.',
+      array(
+        '%url' => base_path() . 'front_page',
+        '%node' => 'node',
+        '%front_page' => 'front_page')
+        )
+    );
+  return $form;
 }
-/** 
- * print out the page
- * 
- * this function loads up the front page and displays it 
+
+/**
+ * print out the front page
+ *
+ * this function loads up the front page and displays it
  *
- */ 
- 
+ * @return void
+ */
+
 function front_page() {
-	
-/* Set a default value for landing zone if no front_page variables are filled. If the module is turned on 
-*  but empty in certain areas then a redirection loop will occur. This default prevents this
-*/
-$output = 'node';
-/* Set the time to check against the last access of the user by the variable set in settings.*/
-switch(variable_get('front_special_notice_time','')){
-		case 'one day' :
-			$check_time = (time() -  (24 * 60 * 60));
-			break;
-		case 'one week' :
-			$check_time =(time() -  (7 * 24 * 60 * 60));
-			break;
-		case 'one month' :
-			$check_time =(time() -  (30 * 24 * 60 * 60));
-			break;
-		case 'three months' :
-			$check_time =(time() -  (90 * 24 * 60 * 60));
-			break;
-		case 'six months' :
-			$check_time =(time() -  (180 * 24 * 60 * 60));
-			break;
-		case 'one year' :
-			$check_time =(time() -  (360 * 24 * 60 * 60));
-			break;
-	}
-	
-//this checks to see if you are overriding HOME links on the site
-if (variable_get('front_page_breadcrumb',0)) {
-	  // This checks to see if the referer is an internal HOME link or not.
-	  $newhome =  variable_get('front_page_breadcrumb_redirect','node');
-	  $ref = $_SERVER["HTTP_REFERER"];
-	  global $user, $base_url;
-	  $parsed_url=parse_url($base_url);
-	  $domain = $parsed_url['host'];
-	  if (stristr($ref, $domain)) {
-		  drupal_goto($path = $newhome, $query = NULL, $fragment = NULL);
-	  }
- }
-  			
+  /* Set a default value for landing zone if no front_page variables are filled. If the module is turned on
+   *  but empty in certain areas then a redirection loop will occur. This default prevents this
+   */
+  $output = 'node';
+
+  /* Set the time to check against the last access of the user by the variable set in settings.*/
+  switch (variable_get('front_special_notice_time', '')) {
+    case 'one day' :
+      $check_time = (time() -  (24 * 60 * 60));
+      break;
+    case 'one week' :
+      $check_time =(time() -  (7 * 24 * 60 * 60));
+      break;
+    case 'one month' :
+      $check_time =(time() -  (30 * 24 * 60 * 60));
+      break;
+    case 'three months' :
+      $check_time =(time() -  (90 * 24 * 60 * 60));
+      break;
+    case 'six months' :
+      $check_time =(time() -  (180 * 24 * 60 * 60));
+      break;
+    case 'one year' :
+      $check_time =(time() -  (360 * 24 * 60 * 60));
+      break;
+    }
+
+  // this checks to see if you are overriding HOME links on the site
+  if (variable_get('front_page_breadcrumb', 0)) {
+    // This checks to see if the referer is an internal HOME link or not.
+    $newhome =  variable_get('front_page_breadcrumb_redirect', 'node');
+    $ref = $_SERVER["HTTP_REFERER"];
+
+    global $user, $base_url;
+    $parsed_url=parse_url($base_url);
+    $domain = $parsed_url['host'];
+    if (stristr($ref, $domain)) {
+      drupal_goto($path = $newhome, $query = NULL, $fragment = NULL);
+    }
+  }
+
   // the following is the code that loads the front_page settings
-  
   global $user;
-  
+
   /*
-  * if the user is not logged in
-  */
+   * if the user is not logged in
+   */
   if (!$user->uid) {
-  
-  /* if the user is not logged in load up the page for anonymous users */ 
-  $output = variable_get("front_1_text", "drupal");
-    
+    /* if the user is not logged in load up the page for anonymous users */
+    $output = variable_get("front_1_text", "drupal");
+
     /* if PHP code execution is allowed then use eval */
     if (variable_get('front_1_php', 0)) {
       $output = drupal_eval($output);
     }
-	$fptype = variable_get("front_1_type", "drupal");
-	switch ($fptype) {
-        case "themed":
-		    print theme('page', $output);
-		    return;
-		
-        case "full":
-		    print $output;
-		    return;
-	  
-	      case "redirect":
+    $fptype = variable_get("front_1_type", "drupal");
+    switch ($fptype) {
+      case "themed":
+        print theme('page', $output);
+        return;
+
+      case "full":
+        print $output;
+        return;
+
+      case "redirect":
         $output = variable_get("front_1_redirect", "drupal");
         drupal_goto($path = $output, $query = NULL, $fragment = NULL);
         break;
     }
   }
-   
-   
-   $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.
-   $siteroles = count($roles);
-     
- /* this is where the new 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
-     if (array_key_exists($role_id, $user->roles)){ // if the current visitor has a role type that matches and if the front page setting for that role type is not empty.
-       if ((variable_get("special_notice_text", "") != "") && ($user->access < $check_time)){
+
+  $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.
+  $siteroles = count($roles);
+
+  /* this is where the new 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
+      if (array_key_exists($role_id, $user->roles)) { // if the current visitor has a role type that matches and if the front page setting for that role type is not empty.
+        if ((variable_get("special_notice_text", "") != "") && ($user->access < $check_time)) {
           $output = '<div id="mission">';
           $output .= variable_get("special_notice_text", "");
           $output .= '</div>';
           $output .= variable_get("front_". $role_id ."_text", "");
           }
-         else {$output = variable_get("front_". $role_id ."_text", "");} 
-      /* if PHP code execution is allowed then use eval */
-         if (variable_get("front_". $role_id ."_php", 0)) {
-          $output = drupal_eval($output);
-         }
-	    $fptype = variable_get("front_". $role_id ."_type", "drupal");//check whether it is a themed or full front page.
-	    switch ($fptype) {
-        case "themed":
-		    print theme('page', $output);
-		    return;
-		
-        case "full":
-		    print $output;
-		    return;
-		    
-		    case "same": 
-		    $output = variable_get("front_1_text", "drupal");
-        /* if PHP code execution is allowed then use eval */
-        if (variable_get('front_1_php', 0)) {
-          $output = drupal_eval($output);
-         }
-	      $fptype = variable_get("front_1_type", "drupal");
-	        switch ($fptype) {
-          case "themed":
-		      print theme('page', $output);
-		      return;
-		
-          case "full":
-		      print $output;
-		      return;
-	  
-	        case "redirect":
-          $output = variable_get("front_1_redirect", "drupal");
-          drupal_goto($path = $output, $query = NULL, $fragment = NULL);
-          break;
-         }
-         
-          case "sameasauth": 
-		    $output = variable_get("front_2_text", "drupal");
+        else {
+          $output = variable_get("front_". $role_id ."_text", "");
+        }
         /* if PHP code execution is allowed then use eval */
-        if (variable_get("front_2_php", 0)) {
+        if (variable_get("front_". $role_id ."_php", 0)) {
           $output = drupal_eval($output);
-         }
-	      $fptype = variable_get("front_2_type", "drupal");
-	        switch ($fptype) {
+        }
+        $fptype = variable_get("front_". $role_id ."_type", "drupal"); //check whether it is a themed or full front page.
+        switch ($fptype) {
           case "themed":
-		      print theme('page', $output);
-		      return;
-		
+            print theme('page', $output);
+            return;
+
           case "full":
-		      print $output;
-		      return;
-	  
-	        case "redirect":
-          $output = variable_get("front_2_redirect", "drupal");
-          drupal_goto($path = $output, $query = NULL, $fragment = NULL);
-          break;
-         }
-	  
-	      case "redirect":
-        $output = variable_get("front_". $role_id ."_redirect", "drupal");
-        drupal_goto($path = $output, $query = NULL, $fragment = NULL);
-        break;
-         
-     }
+            print $output;
+            return;
+
+          case "same":
+            $output = variable_get("front_1_text", "drupal");
+            /* if PHP code execution is allowed then use eval */
+            if (variable_get('front_1_php', 0)) {
+              $output = drupal_eval($output);
+            }
+            $fptype = variable_get("front_1_type", "drupal");
+            switch ($fptype) {
+              case "themed":
+                print theme('page', $output);
+                return;
+
+              case "full":
+                print $output;
+                return;
+
+              case "redirect":
+                $output = variable_get("front_1_redirect", "drupal");
+                drupal_goto($path = $output, $query = NULL, $fragment = NULL);
+                break;
+              }
+              // no need to "break;" because none of the previous cases returns
+
+          case "sameasauth":
+            $output = variable_get("front_2_text", "drupal");
+
+            /* if PHP code execution is allowed then use eval */
+            if (variable_get("front_2_php", 0)) {
+              $output = drupal_eval($output);
+            }
+            $fptype = variable_get("front_2_type", "drupal");
+            switch ($fptype) {
+              case "themed":
+                print theme('page', $output);
+                return;
+
+              case "full":
+                print $output;
+                return;
+
+              case "redirect":
+                $output = variable_get("front_2_redirect", "drupal");
+                drupal_goto($path = $output, $query = NULL, $fragment = NULL);
+                break;
+            }
+
+          case "redirect":
+            $output = variable_get("front_". $role_id ."_redirect", "drupal");
+            drupal_goto($path = $output, $query = NULL, $fragment = NULL);
+            break;
+        }
+      }
     }
-   }
   }
-}
+}
\ No newline at end of file
