--- front_page_old.module	2006-04-17 19:01:02.000000000 +0200
+++ front_page_new.module	2006-08-17 08:47:04.000000000 +0200
@@ -67,16 +67,36 @@ function front_page_settings() {
 
   $form['anon'] = array('#type' => 'fieldset','#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Front Page settings for Anonymous Users (visitors not logged in)'),);
   $form['anon']['front_page_text'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => variable_get('front_page_text', ''), '#cols' => 60, '#rows' => 20, '#description' => t('Paste your HTML or TEXT here for visitors to your site who are not 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.'));
-  $form['anon']['front_page_size'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_page_size','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. Useful if you want to use a FLASH based front-end to your site or a splash-page for a pay-per-view website.<br><strong>REDIRECT</strong> will automatically redirect visitors not logged in to a specific page specified in the REDIRECT TO box.</p>'),);
-  $form['anon']['front_page_anon_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect to'), '#default_value' => variable_get('front_page_anon_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['anon']['front_page_type'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_page_size','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. Useful if you want to use a FLASH based front-end to your site or a splash-page for a pay-per-view website.<br><strong>REDIRECT</strong> will automatically redirect visitors not logged in to a specific page specified in the REDIRECT TO box.</p>'),);
+  $form['anon']['front_page_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect to'), '#default_value' => variable_get('front_page_anon_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['anon']['front_page_php'] = array('#type' => 'checkbox', '#title' => t('Allow embedded PHP code in front page for anonymous users'), '#return_value' => 1, '#default_value' => variable_get('front_page_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['authenticated'] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Front Page settings for Authenticated Users (visitors already logged in)'));
-  $form['authenticated']['front_page_text_yes'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => variable_get('front_page_text_yes', ''), '#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.'));
-  $form['authenticated']['front_page2_size'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_page2_size','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>'),);
-  $form['authenticated']['front_page_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect to'), '#default_value' => variable_get('front_page_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['authenticated']['front_page_php_yes'] = array('#type' => 'checkbox', '#title' => t('Allow embedded PHP code in front page for authenticated users'), '#return_value' => 1, '#default_value' => variable_get('front_page_php_yes',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['authenticated']['front_page2_text'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => variable_get('front_page2_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.'));
+  $form['authenticated']['front_page2_type'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_page2_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>'),);
+  $form['authenticated']['front_page2_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect to'), '#default_value' => variable_get('front_page2_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['authenticated']['front_page2_php'] = array('#type' => 'checkbox', '#title' => t('Allow embedded PHP code in front page for authenticated users'), '#return_value' => 1, '#default_value' => variable_get('front_page2_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['veteran'] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => FALSE, '#title' => t('Front Page settings for Veteran Users (previously inactive users)'));
+  $form['veteran']['front_page3_time'] = array(
+	  '#type' => 'select', 
+	  '#title' => t('Inactive for'), 
+	  '#default_value' => variable_get('front_page3_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 redirecting returning users to this message.<p> '),
+	  );
+  $form['veteran']['front_page3_text'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => variable_get('front_page3_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.'));
+  $form['veteran']['front_page3_type'] = array('#type' => 'select', '#title' => t('Select type'), '#default_value' => variable_get('front_page3_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>'),);
+  $form['veteran']['front_page3_redirect'] = array('#type' => 'textfield', '#title' => t('Redirect to'), '#default_value' => variable_get('front_page3_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['veteran']['front_page3_php'] = array('#type' => 'checkbox', '#title' => t('Allow embedded PHP code in front page for veteran users'), '#return_value' => 1, '#default_value' => variable_get('front_page3_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['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.'));  
@@ -96,30 +116,64 @@ function front_page_settings() {
 
  
 function front_page() {
-	//this checks to see if you are overriding HOME links on the site
-	if (variable_get('front_page_breadcrumb',0)) {
+	
+/* 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_page3_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);
-	   }
-  }
+	  $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 (!$user->uid || variable_get("front_page2_size", "drupal") == "same"){
+  
+  /*
+  * show this if the user is not logged in or if the authenticated user is to get the same output as 
+  * anonymous users
+  */
+  if (!$user->uid || variable_get("front_page2_type", "drupal") == "same" || variable_get("front_page3_type", "drupal") == "same"){
     $output = variable_get("front_page_text", "drupal");
     
+    /* if PHP code execution is allowed then use eval */
     if (variable_get('front_page_php', 0)) {
       $output = drupal_eval($output);
     }
-		$fpsize = variable_get("front_page_size", "drupal");
-		switch ($fpsize) {
+	$fptype = variable_get("front_page_type", "drupal");
+	switch ($fptype) {
         case "themed":
 		    print theme('page', $output);
 		    return;
@@ -128,33 +182,66 @@ function front_page() {
 		    print $output;
 		    return;
 	  
-	    case "redirect":
-        $output = variable_get("front_page_anon_redirect", "drupal");
+	case "redirect":
+        $output = variable_get("front_page_redirect", "drupal");
         break;
     }
   }
-  else {
-    $output = variable_get("front_page_text_yes", "drupal");
-
-    // If PHP content is allowed, execute it.
-    if (variable_get('front_page_php_yes',0)) {
-      $output = drupal_eval($output);
-    }
-    $fpsize = variable_get("front_page2_size", "drupal");
-		switch ($fpsize) {
-      case "themed":
-			  print theme('page', $output);
-		    return;
+  
+  /* check for text in authenticated user textarea. Check for logged and last accessed time.  */
+  else if ((trim(variable_get("front_page2_text", "")) != "") && ($user->uid ) && ($user->access > $check_time)){
+    
+	  $output = variable_get("front_page2_text", "drupal");
+	  
+	  /* If PHP content is allowed, execute it*/
+	  if (variable_get('front_page2_php',0)) {
+		  $output = drupal_eval($output);
+	  }
+
+	/* Get the type of output format that will be used to display the content */
+	$fptype = variable_get("front_page2_type", "drupal");
+	switch ($fptype) {
+		case "themed":
+			print theme('page', $output);
+			return;
+		case "full":
+			print $output;
+			return;
+		case "redirect":
+			$output = variable_get("front_page2_redirect", "drupal");
+			break;
 		
-      case "full":
-			  print $output;
-			  return;
-
-	  case "redirect":
-      $output = variable_get("front_page_redirect", "drupal");
-      break;
-    }
+	}
+  }
+  
+  /* This section is a one time catch for users returning after a set period. 
+  *  Once view the access time is reset and the visitor gets the authenticated 
+  *   or anonymous user area if set
+  */
+  else if (trim(variable_get("front_page3_text", "")) != "" && ($user->access < $check_time)){
+    
+	  $output = variable_get("front_page3_text", "drupal");
+	  
+	  /* If PHP content is allowed, execute it*/
+	  if (variable_get('front_page3_php',0)) {
+		  $output = drupal_eval($output);
+	  }
+	  
+	  /* Get the type of output format that will be used to display the content */
+	  $fptype = variable_get("front_page3_type", "drupal");
+	  switch ($fptype) {
+    		case "themed":
+			print theme('page', $output);
+			return;
+		case "full":
+			print $output;
+			return;
+		case "redirect":
+			$output = variable_get("front_page3_redirect", "drupal");
+			break;
+	  }
   }
+  
   // redirect
   drupal_goto($path = $output, $query = NULL, $fragment = NULL);
   
