--- phpbb2drupal.module	Sun Feb 10 17:03:30 2008
+++ phpbb2drupal.module.php	Fri Mar 07 06:08:22 2008
@@ -212,15 +212,46 @@ function phpbb2drupal_admin_settings() {
     '#default_value' => variable_get('phpbb2drupal_tested', 0),
     '#description' => '',
   ); 
-
+   
+   //PHPBB Version settings
+   $form['version'] = array(
+   '#type' => 'fieldset',
+   '#title'=> t('PHPBB Version Select'),
+   '#collapsible' => TRUE,
+   '#collapsed' => TRUE,
+   );
+   $output = '<p>'.t('Select which phpbb version you are importing from.').'</p>';
+   $form['version']['intro'] = array('#value' => $output);
+   $output = '';
+   $versions = array(
+    "PHPBB2"=> "phpbb2.x",
+    "PHPBB3" => "phpbb3.x",
+   ); 
+   $phpbb_version = variable_get('phpbb2drupal_version', 'PHPBB2');
+    $form['version']['phpbb2drupal_version'] = array(
+    '#type' => 'radios',
+    '#title' => t('phpBB Selection'),
+    '#default_value' => variable_get('phpbb2drupal_version', 'PHPBB2'),
+	'#options' => $versions,
+  );
+    if (!$phpbb_version) {
+    $ready_for_migration = 0;
+    $form['version']['#collapsed']= FALSE;
+	$output .= '<p class="marker">';
+	$output .= t('Please ensure you have selected!');
+	$output .= '</p>';
+  }
+  $form['version']['result'] = array('#value' => $output);
+  
+    
   // Input format settings
   $form['input'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Input Format settings'),
+    '#title' => t('Input format settings'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
-  $output = '<p>'. t('Select which <a href="@link">input format</a> should the imported messages be set:', array('@link' => url('admin/filters'))) .'</p>';
+  $output .= '<p>'. t('Select which <a href="@link">input format</a> should the imported messages be set:', array('@link' => url('admin/filters'))) .'</p>';
   $form['input']['intro'] = array('#value' => $output);
   $output = '';
 
@@ -244,7 +275,6 @@ function phpbb2drupal_admin_settings() {
   $output .= '<p><em>'. t('This setting will be applied to all posts and private messages.') .'</em></p>';
   $form['input']['result'] = array('#value' => $output);
 
-
   // BBcode settings
   $form['bbcode'] = array(
     '#type' => 'fieldset',
@@ -381,7 +411,26 @@ function phpbb2drupal_admin_settings() {
     '#description' => t('What prefix is used for your phpBB2 tables?'),
   );
   $pre = variable_get('phpbb2drupal_table_prefix', 'phpbb_');
+  switch($phpbb_version)
+  { 
+    case 'PHPBB2': 
+	{
+		$tables = array($pre.'categories', $pre.'forums', $pre.'posts', $pre.'posts_text', $pre.'topics', $pre.'users');
+		break;
+	}
+	case 'PHPBB3': 
+	{
+		$tables = array($pre .'forums', $pre .'posts', $pre .'topics', $pre .'users');
+		break;
+	}
+	
+	default:
+	$tables = array($pre.'categories', $pre.'forums', $pre.'posts', $pre.'posts_text', $pre.'topics', $pre.'users');
+  }
+  
+  /*
   $tables = array($pre.'categories', $pre.'forums', $pre.'posts', $pre.'posts_text', $pre.'topics', $pre.'users');
+  */
   $result = _phpbb2drupal_check_tables($tables, 'phpbb', 0);
   $output .= $result['html'];
   
@@ -389,7 +438,7 @@ function phpbb2drupal_admin_settings() {
     $ready_for_migration = 0;
     $form['phpbb2']['#collapsed']= FALSE;
     $output .= '<span class="marker">';
-    $output .= t("Some tables couldn't be found. Please correct the errors so that the phpBB2 tables can be accessed.");
+    $output .= t("Some tables couldn't be found. This can be caused by an incorrect prefix or if your phpbb version is incorrectly set. Please correct the errors so that the phpBB2 tables can be accessed.");
     $output .= '</span>';
   }
   $form['phpbb2']['result'] = array('#value' => $output);
@@ -1808,7 +1857,9 @@ function phpbb2drupal_import_cleanup() {
   variable_del('phpbb2drupal_encode');
   variable_del('phpbb2drupal_encoding_phpbb');
   variable_del('phpbb2drupal_encoding_drupal');
-
+  /* added by rayneitami */
+    variable_del('phpbb2drupal_version');
+  /* end custom section*/
   db_query('DELETE FROM {cache}');
 }
 
@@ -2040,4 +2091,5 @@ function phpbb2drupal_replace_url() {
   }
 
   variable_set('phpbb2drupal_replace_url_successful', '1');
-}
\ No newline at end of file
+}
+?>
\ No newline at end of file
