? yh.patch Index: tablemanager.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tablemanager/tablemanager.module,v retrieving revision 1.87 diff -u -u -p -r1.87 tablemanager.module --- tablemanager.module 15 Mar 2007 10:38:03 -0000 1.87 +++ tablemanager.module 10 Jul 2008 14:11:08 -0000 @@ -2346,12 +2346,16 @@ function tablemanager_csv() { * Allows a user to import a CSV file. */ function tablemanager_csv_form() { - $tables = tablemanager_loadtables(); - array_unshift($tables, 'New Table'); + + $tables[0] = t('New Table'); + $sql = db_query('SELECT tid, name FROM {tablemanager}'); + while ($row = db_fetch_object($sql)) { + $tables[$row->tid] = $row->name; + } $form['table'] = array( '#type' => 'select', '#title' => t('Add CSV to table'), - '#default_value' => 'New Table', + '#default_value' => 0, '#options' => $tables, ); $form['separator'] = array( @@ -2391,8 +2395,6 @@ function tablemanager_csv_form() { */ function tablemanager_csv_form_submit($form_id, $form) { global $user; - $tables = tablemanager_loadtables(); - array_unshift($tables, 'New Table'); if (!$form['csvfile']) { drupal_set_message(t('Error creating CSV table.')); watchdog('tablemanager', t('tablemanager: error creating CSV table'), WATCHDOG_ERROR); @@ -2402,7 +2404,7 @@ function tablemanager_csv_form_submit($f $whole = trim($form['csvfile']); $temp = explode("\n", $whole); foreach ($temp as $a) { - if (!$header && $form['table'] == '0') { + if (!$header && $form['table'] == 0) { if ($form['header'] == 1) { $header = explode($form['separator'], check_plain($a)); } @@ -2428,7 +2430,7 @@ function tablemanager_csv_form_submit($f } elseif (!$header) { $header = TRUE; - $tid = $tables[$form['table']]; + $tid = $form['table']; } $temp = check_markup($a, $form['format']); if (substr(trim($temp), 0, 3) == "

" && trim(substr(trim($temp), -4, 4) == "

")) { @@ -2455,7 +2457,7 @@ function tablemanager_csv_form_submit($f db_query("INSERT INTO {tablemanager_data} (tid, uid, data) VALUES (%d, %d, '%s')", $tid, $user->uid, $row); } // end foreach variable_set('tablemanager_table', $tid); - if ($form['table'] == '0') { + if ($form['table'] == 0) { drupal_set_message(t('CSV table has been created successfully.')); watchdog('tablemanager', t("tablemanager: added table '%table' from CSV file.", array('%table' => $tid)), WATCHDOG_NOTICE, l('view', 'tablemanager/' . $tid)); }