Index: modules/dba/dba.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/dba/dba.module,v retrieving revision 1.40 diff -u -p -r1.40 dba.module --- modules/dba/dba.module 26 May 2006 05:23:54 -0000 1.40 +++ modules/dba/dba.module 19 Nov 2006 08:28:06 -0000 @@ -39,7 +39,6 @@ function dba_menu($may_cache) { $items[] = array('path' => 'admin/database', 'title' => t('database'), 'callback' => 'dba_admin_overview', 'access' => $access); - // tabs $items[] = array('path' => 'admin/database/table', 'title' => t('tables'), 'callback' => 'dba_admin_overview', 'type' => MENU_DEFAULT_LOCAL_TASK); @@ -54,40 +53,60 @@ function dba_menu($may_cache) { } else if (strstr(drupal_get_path_alias($_GET['q']), 'admin/database')) { // you can only view or describe one table at a time - $tables = dba_get_active_tables($edit, 0); - $quantity = sizeof(explode(',', $tables)); - - // subtabs - $items[] = array('path' => "admin/database/table/$tables/view", - 'title' => t('view'), 'callback' => 'dba_admin_tables_view', - 'access' => $access && $tables && $quantity == 1, - 'type' => MENU_LOCAL_TASK, 'weight' => 0); - $items[] = array('path' => "admin/database/table/$tables/describe", - 'title' => t('describe'), 'callback' => 'dba_admin_tables_describe', - 'access' => $access && $tables && $quantity == 1, - 'type' => MENU_LOCAL_TASK, 'weight' => 2); - $items[] = array('path' => "admin/database/table/$tables/check", - 'title' => t('check'), 'callback' => 'dba_admin_tables_check', - 'access' => $access && $tables && $quantity > 0 && _is_mysql(), - 'type' => MENU_LOCAL_TASK, 'weight' => 4); - $items[] = array('path' => "admin/database/table/$tables/optimize", - 'title' => t('optimize'), 'callback' => 'dba_admin_tables_optimize', - 'access' => $access && $tables && $quantity > 0 && _is_mysql(), - 'type' => MENU_LOCAL_TASK, 'weight' => 4); - - // subtabs for dbas with administer permissions - $items[] = array('path' => "admin/database/table/$tables/backup", + $tables = dba_get_active_tables(array(), 0); + if (!empty($tables)) { + // regular subtabs + $items[] = array('path' => "admin/database/table/$tables/view", + 'title' => t('view'), 'callback' => 'dba_admin_tables_view', + 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 0); + $items[] = array('path' => "admin/database/table/$tables/describe", + 'title' => t('describe'), 'callback' => 'dba_admin_tables_describe', + 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 2); + if (_is_mysql()) { + $items[] = array('path' => "admin/database/table/$tables/check", + 'title' => t('check'), 'callback' => 'dba_admin_tables_check', + 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 4); + $items[] = array('path' => "admin/database/table/$tables/optimize", + 'title' => t('optimize'), 'callback' => 'dba_admin_tables_optimize', + 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 4); + } + // subtabs for dbas with administer permissions + $items[] = array('path' => "admin/database/table/$tables/backup", + 'title' => t('backup'), 'callback' => 'dba_admin_tables_backup', + 'access' => user_access('dba administer database'), + 'type' => MENU_LOCAL_TASK, 'weight' => 8); + $items[] = array('path' => "admin/database/table/$tables/empty", + 'title' => t('empty'), 'callback' => 'dba_admin_tables_empty', + 'access' => user_access('dba administer database'), + 'type' => MENU_LOCAL_TASK, 'weight' => 8); + $items[] = array('path' => "admin/database/table/$tables/drop", + 'title' => t('drop'), 'callback' => 'dba_admin_tables_drop', + 'access' => user_access('dba administer database'), + 'type' => MENU_LOCAL_TASK, 'weight' => 10); + } + // administrative callbacks + $items[] = array('path' => "admin/database/backup", 'title' => t('backup'), 'callback' => 'dba_admin_tables_backup', - 'access' => user_access('dba administer database') && $tables && - $quantity > 0, 'type' => MENU_LOCAL_TASK, 'weight' => 8); - $items[] = array('path' => "admin/database/table/$tables/empty", - 'title' => t('empty'), 'callback' => 'dba_admin_tables_empty', - 'access' => user_access('dba administer database') && $tables && - $quantity > 0, 'type' => MENU_LOCAL_TASK, 'weight' => 8); - $items[] = array('path' => "admin/database/table/$tables/drop", + 'access' => user_access('dba administer database'), 'weight' => 15, + 'type' => arg(2) == 'backup' ? MENU_LOCAL_TASK : MENU_CALLBACK); + $items[] = array('path' => "admin/database/drop", 'title' => t('drop'), 'callback' => 'dba_admin_tables_drop', - 'access' => user_access('dba administer database') && $tables && - $quantity > 0, 'type' => MENU_LOCAL_TASK, 'weight' => 10); + 'access' => user_access('dba administer database'), 'weight' => 15, + 'type' => arg(2) == 'drop' ? MENU_LOCAL_TASK : MENU_CALLBACK); + $items[] = array('path' => "admin/database/empty", + 'title' => t('empty'), 'callback' => 'dba_admin_tables_empty', + 'access' => user_access('dba administer database'), 'weight' => 15, + 'type' => arg(2) == 'empty' ? MENU_LOCAL_TASK : MENU_CALLBACK); + if (_is_mysql()) { + $items[] = array('path' => "admin/database/check", + 'title' => t('check'), 'callback' => 'dba_admin_tables_check', + 'access' => user_access('dba administer database'), 'weight' => 15, + 'type' => arg(2) == 'check' ? MENU_LOCAL_TASK : MENU_CALLBACK); + $items[] = array('path' => "admin/database/optimize", + 'title' => t('optimize'), 'callback' => 'dba_admin_tables_optimize', + 'access' => user_access('dba administer database'), 'weight' => 15, + 'type' => arg(2) == 'optimize' ? MENU_LOCAL_TASK : MENU_CALLBACK); + } } return $items; } @@ -207,58 +226,6 @@ function dba_auto_backup() { dba_mail_backup($attachment); } } - - } -} - -function dba_backup() { - $op = $_POST['op']; - if (empty($op)) { - $op = arg(2); - } - $edit = $_POST['edit']; - - switch ($op) { - case t('Backup table'): - case t('Backup tables'): - if (user_access('dba administer database')) { - $database = dba_get_database(); - - Header("Content-type: application/octet-stream"); - Header("Content-Disposition: attachment; filename=". $edit['file_name']); - echo "-- Drupal dba.module database dump\n"; - echo "--\n"; - echo "-- Database: $database\n"; - echo "-- Date: ". format_date(time(), 'large') ."\n\n"; - foreach (explode(',', $edit['tables']) as $table) { - dba_backup_table($table, $edit['add_drop_table']); - } - } - exit(0); - break; - default: - $output = dba_backup_verify($edit); - break; - } - - print theme('page', $output); -} - -function dba_backup_verify($edit) { - $tables = dba_get_active_tables($edit, 0); - $quantity = sizeof(explode(',', $tables)); - if ($quantity) { - $display = ''. str_replace(',', ', ', $tables) .''; - $form['tables'] = array('#type' => 'hidden', '#value' => "$tables"); - $filename = ($quantity == 1 ? $tables .'.sql' : variable_get('dba_default_filename', 'backup.sql')); - $form['file_name'] = array('#type' => 'textfield', '#title' => t('Backup filename'), '#default_value' => $filename, '#size' => 40, '#maxlength' => 255, '#description' => t("Please specify the filename you wish to give your database backup. Once you click 'Backup %table' below your web browser will allow you to save the database backup to your local computer.", array('%table' => format_plural($quantity, 'table', 'tables')))); - $form['add_drop_table'] = array('#type' => 'checkbox', '#title' => t('Add DROP TABLE'), '#default_value' => 0, '#description' => t('Check this box if you wish to add DROP TABLE IF EXISTS before each table schema. This will allow you to quickly restore from a backup without having to manually drop all tables first.')); - return confirm_form('dba_backup_verify_form', $form, - t('Backup %table to local computer?', array('%table' => format_plural($quantity, 'table', 'tables'))), - 'admin/database', - t('By clicking "backup %table" you will be prompted to save the following %table to your local computer: %tables', array('%tables' => $display, '%table' => format_plural($quantity, 'table', 'tables'))), - t('Backup %table', array('%table' => format_plural($quantity, 'table', 'tables'))), - t('Cancel')); } } @@ -309,11 +276,9 @@ function dba_admin_tables_view() { */ function dba_admin_tables_describe() { $output = ''; - if (user_access('dba view database')) { $output = dba_table_describe(arg(3)); } - print theme('page', $output); } @@ -321,10 +286,9 @@ function dba_admin_tables_describe() { * MySQL only: check/repair the selected table. */ function dba_admin_tables_check() { + // TODO $output = ''; - if (user_access('dba administer database')) { - $edit = $_POST['edit']; $op = $_POST['op']; switch ($op) { case 'Repair': @@ -344,12 +308,11 @@ function dba_admin_tables_check() { */ function dba_admin_tables_optimize() { $output = ''; - if (user_access('dba administer database')) { $edit = $_POST['edit']; $output = dba_tables_optimize($edit); + unset($_SESSION['dba_tables']); } - print theme('page', $output); } @@ -357,127 +320,86 @@ function dba_admin_tables_optimize() { * Backup the selected table(s). */ function dba_admin_tables_backup() { - $output = ''; - - if (user_access('dba administer database')) { - $edit = $_POST['edit']; - $op = $_POST['op']; - switch ($op) { - case t('Backup table'): - case t('Backup tables'): - $output = dba_backup(); - break; - default: - $output = dba_backup_verify($edit); - break; - } - } - - print theme('page', $output); + dba_admin_tables_verify_op('backup'); } /** * Empty the selected table(s). */ function dba_admin_tables_empty() { - $output = ''; - - if (user_access('dba administer database')) { - $edit = $_POST['edit']; - $op = $_POST['op']; - switch ($op) { - // Empty button from the database overview page - case t('Empty'): - if (dba_get_active_tables($edit, 0)) { - $output = dba_verify($edit, 'empty'); - } - else { - drupal_set_message(t('Unable to \'empty\', no table selected.'), 'error'); - drupal_goto('admin/database'); - } - break; - case 'Empty table': - $table = $edit['tables']; - dba_delete_table($edit['tables']); - drupal_goto("admin/database/table/$table/view"); - break; - case t('Empty tables'): - $tables = dba_get_active_tables($edit, 0); - foreach (explode(',', $tables) as $table) { - dba_delete_table($table); - } - drupal_goto('admin/database'); - break; - default: - $output = dba_verify($edit, 'empty'); - break; - } - } - - print theme('page', $output); + dba_admin_tables_verify_op('empty'); } /** * Drop the selected table(s). */ function dba_admin_tables_drop() { - $output = ''; - - if (user_access('dba administer database')) { - $edit = $_POST['edit']; - $op = $_POST['op']; - switch ($op) { - // Drop button from the database overview page - case t('Drop'): - if (dba_get_active_tables($edit, 0)) { - $output = dba_verify($edit, 'drop'); - } - else { - drupal_set_message(t('Unable to \'drop\', no table selected.'), 'error'); - $output = dba_database_overview(); - } - break; - case t('Drop table'): - case t('Drop tables'): - dba_drop_table($edit['tables']); - drupal_goto('admin/database'); - break; - default: - $output = dba_verify($edit, 'drop'); - } - } + dba_admin_tables_verify_op('drop'); +} +function dba_admin_tables_verify_op($op) { + $edit = $_POST['edit']; + $tables = dba_get_active_tables($edit, 0); + unset($_SESSION['dba_tables']); + if (empty($tables)) { + drupal_set_message(t('You must select the tables to %op.', array('%op' => _dba_ops($op))), 'error'); + drupal_goto('admin/database'); + } + $edit['tables'] = $tables; + $output = dba_verify($edit, $op); print theme('page', $output); } + // dba module specific functions function dba_admin_overview() { - $output = dba_database_overview(); - - print theme('page', $output); + return dba_database_overview_form(); } -function dba_database_overview() { +function theme_dba_form_database_overview($form) { + $output = ''; $rows = array(); $database = dba_get_database(); - drupal_set_title(t('View database \'%database\'', array('%database' => "$database"))); + drupal_set_title(t('View database %database', array('%database' => theme('placeholder', $database)))); // it'd be great to use the pager and tablesort, but doesn't appear possible - $header = array('', t('tables'), t('rows')); + $header = array('', t('tables'), t('rows'), t('actions')); $tables = dba_get_tables(); foreach ($tables as $table) { $action = NULL; $count = dba_get_row_count($table); + $action = '['. l(t('view'), "admin/database/table/$table/view", array('title' => t('View all rows of table %table', array('%table' => theme('placeholder', $table))))) .']'; + $action .= ' ['. l(t('describe'), "admin/database/table/$table/describe", array('title' => t('Describe table %table', array('%table' => theme('placeholder', $table))))) .']'; + + if (_is_mysql()) { + $action .= ' ['. l(t('check'), "admin/database/table/$table/check", array('title' => t('Check integrity of table %table', array('%table' => theme('placeholder', $table))))) .']'; + $action .= ' ['. l(t('optimize'), "admin/database/table/$table/optimize", array('title' => t('Optimize performance of table %table', array('%table' => theme('placeholder', $table))))) .']'; + } if (user_access('dba administer database')) { - // TODO: - //$checkbox = form_checkbox('', $table, 1, $edit['$table']); + $action .= ' ['. l(t('backup'), "admin/database/table/$table/backup", array('title' => t('Backup all data from table %table to file', array('%table' => theme('placeholder', $table))))) .']'; + $action .= ' ['. l(t('empty'), "admin/database/table/$table/empty", array('title' => t('Delete all rows from table %table', array('%table' => theme('placeholder', $table))))) .']'; + $action .= ' ['. l(t('drop'), "admin/database/table/$table/drop", array('title' => t('Drop table %table', array('%table' => theme('placeholder', $table))))) .']'; } - $rows[] = array($checkbox, l($table, "admin/database/table/$table/view"), $count, $action); + $checkbox = form_render($form[$table]); + $rows[] = array($checkbox, $table, $count, $action); } - - $output .= dba_select_all_js(); +// $output .= dba_select_all_js(); $output .= theme('table', $header, $rows); - $output .= dba_select_all_js(); +// $output .= dba_select_all_js(); + $output .= form_render($form); + drupal_set_html_head(checkoff_head()); + return $output; +} + +function dba_database_overview_form() { + $tables = dba_get_tables(); + foreach ($tables as $table) { + $form[$table] = array( + '#type' => 'checkbox', + '#title' => '', + '#default_value' => 0, + ); + } if (_is_mysql()) { $form['check'] = array('#type' => 'submit', '#value' => t('Check')); $form['optimize'] = array('#type' => 'submit', '#value' => t('Optimize')); @@ -487,11 +409,35 @@ function dba_database_overview() { $form['empty'] = array('#type' => 'submit', '#value' => t('Empty')); $form['drop'] = array('#type' => 'submit', '#value' => t('Drop')); } + return drupal_get_form('dba_form_database_overview', $form); +} - drupal_set_html_head(checkoff_head()); - $output .= drupal_get_form('dba_form_database_overview', $form); - return $output; - //return form ($output,'POST', NULL, array('name' => 'db_form')); +function dba_form_database_overview_submit($form_id, $form_values) { + $op = isset($_POST['op']) ? $_POST['op'] : ''; + $output = ''; + $tables = dba_get_active_tables($form_values, 0); + if (empty($tables)) { + drupal_set_message(t('Unable to %op, no table selected.', array('%op' => theme('placeholder', $op))), 'error'); + return; + } + $_SESSION['dba_tables'] = $tables; + switch ($op) { + case t('Check'): + drupal_goto('admin/database/check'); + break; + case t('Optimize'): + drupal_goto('admin/database/optimize'); + break; + case t('Backup'): + drupal_goto('admin/database/backup'); + break; + case t('Empty'): + drupal_goto('admin/database/empty'); + break; + case t('Drop'): + drupal_goto('admin/database/drop'); + break; + } } function dba_select_all_js() { @@ -821,9 +767,10 @@ function dba_check_tables($edit, $action } $type = $edit['check_type']; - $tables = dba_get_active_tables($edit); + $tables = dba_get_active_tables($edit, 0); + unset($_SESSION['dba_tables']); if ("$action" == 'check') { - drupal_set_title(t('Performing %type table check.', array('%type' => $type))); + drupal_set_title(t('Performing %type table check', array('%type' => $type))); $result = dba_check_table($tables, $type); } else { @@ -872,24 +819,34 @@ function dba_check_tables($edit, $action } $form['check_options']['tables'] = array('#type' => 'hidden', '#value' => $tables); $output .= drupal_get_form('dba_check_form', $form); - return $output; } function dba_tables_optimize($edit) { - $tables = dba_get_active_tables($edit); - $quantity = sizeof(explode(',', $tables)); - $query = 'OPTIMIZE TABLE '. str_replace(',', ', ', $tables) .';'; - drupal_set_message($query); - $result = db_query($query); - - $header = array(t('Table'), t('Operation'), t('Message type'), t('Message text')); - $rows = array(); - while ($row = db_fetch_object($result)) { - $rows[] = (array)($row); + $tables = dba_get_active_tables($edit, 0); + if (empty($tables)) { + $quantity = 0; } - $output .= theme('table', $header, $rows); + else { + $quantity = sizeof(explode(',', $tables)); + } + drupal_set_title(t('Optimizing %table', array('%table' => format_plural($quantity, t('table'), t('tables'))))); + if (!$quantity) { + drupal_set_message(t('You must select the tables to optimize.'), 'error'); + drupal_goto('admin/database'); + } + else { + $query = 'OPTIMIZE TABLE '. str_replace(',', ', ', $tables) .';'; + drupal_set_message($query); + $result = db_query($query); + $header = array(t('Table'), t('Operation'), t('Message type'), t('Message text')); + $rows = array(); + while ($row = db_fetch_object($result)) { + $rows[] = (array)($row); + } + $output = theme('table', $header, $rows); + } return $output; } @@ -916,6 +873,9 @@ function dba_get_active_tables($edit, $d $tables = implode(',', $tables); } } + if (empty($tables) && (isset($_SESSION['dba_tables']))) { + $tables = $_SESSION['dba_tables']; + } return $tables; } @@ -923,41 +883,105 @@ function dba_verify($edit, $action) { $tables = dba_get_active_tables($edit, 0); $quantity = sizeof(explode(',', $tables)); if ($quantity) { - $display = ''. str_replace(',', ', ', $tables) .''; + $form = array(); + $table_list = theme('placeholder', str_replace(',', ', ', $tables)); + $table_id = format_plural($quantity, t('table'), t('tables')); + $substitutions = array('%tables' => $table_list, '%table' => $table_id, '%this' => format_plural($quantity, t('this'), t('these')), '%itself' => format_plural($quantity, t('itself'), t('themselves')), '%its' => format_plural($quantity, t('its'), t('their'))); $form['tables'] = array('#type' => 'hidden', '#value' => $tables); switch ($action) { + case 'backup': + $filename = ($quantity == 1 ? $tables .'.sql' : variable_get('dba_default_filename', 'backup.sql')); + $form['file_name'] = array('#type' => 'textfield', '#title' => t('Backup filename'), '#default_value' => $filename, '#size' => 40, '#maxlength' => 255, '#description' => t("Please specify the filename you wish to give your database backup. Once you click 'Backup %table' below your web browser will allow you to save the database backup to your local computer.", array('%table' => format_plural($quantity, 'table', 'tables')))); + $form['add_drop_table'] = array('#type' => 'checkbox', '#title' => t('Add DROP TABLE'), '#default_value' => 0, '#description' => t('Check this box if you wish to add DROP TABLE IF EXISTS before each table schema. This will allow you to quickly restore from a backup without having to manually drop all tables first.')); + $output = confirm_form('dba_verify_backup_form', $form, + t('Backup %table to local computer?', array('%table' => $table_id)), + 'admin/database', + t('By clicking "Backup %table" you will be prompted to save the following %table to your local computer: %tables', array('%tables' => $display, '%table' => $table_id)), + t('Backup %table', array('%table' => $table_id)), + t('Cancel')); + + break; case 'empty': - $output = confirm_form('dba_verify_form', $form, - t('Are you sure you want to delete all rows from the "%tables" %table?', array('%tables' => $display, '%table' => format_plural($quantity, 'table', 'tables'))), + $output = confirm_form('dba_verify_empty_form', $form, + t('Are you sure you want to delete all rows from the "%tables" %table?', $substitutions), 'admin/database', - t('By clicking "empty %table" you will completely remove all data from %this %table, though the %table %itself will not be dropped. This action cannot be undone.', array('%tables' => $display, '%table' => format_plural($quantity, 'table', 'tables'), '%this' => format_plural($quantity, 'this', 'these'), '%itself' => format_plural($quantity, 'itself', 'themselves'))), - t('Empty %table', array('%table' => format_plural($quantity, 'table', 'tables'))), + t('By clicking "Empty %table" you will completely remove all data from %this %table, though the %table %itself will not be dropped. This action cannot be undone.', $substitutions), + t('Empty %table', array('%table' => $table_id)), t('Cancel')); break; case 'drop': - $output = confirm_form('dba_verify_form', $form, - t('Are you sure you want to drop the "%tables" %table?', array('%tables' => $display, '%table' => format_plural($quantity, 'table', 'tables'))), + $output = confirm_form('dba_verify_drop_form', $form, + t('Are you sure you want to drop the "%tables" %table?', $substitutions), 'admin/database', - t('By clicking "drop %table" you will be completely removing %this %table and all %its data from the database. This action cannot be undone.', array('%tables' => $display, '%table' => format_plural($quantity, 'table', 'tables'), '%this' => format_plural($quantity, 'this', 'these'), '%its' => format_plural($quantity, 'its', 'their'))), - t('Drop %table', array('%table' => format_plural($quantity, 'table', 'tables'))), + t('By clicking "Drop %table" you will be completely removing %this %table and all %its data from the database. This action cannot be undone.', $substitutions), + t('Drop %table', array('%table' => $table_id)), t('Cancel')); break; - case 'backup': - $filename = ($quantity == 1 ? $tables .'.sql' : variable_get('dba_default_filename', 'backup.sql')); - $form['file_name'] = array('#type' => 'textfield', '#title' => t('Backup filename'), '#default_value' => $filename, '#size' => 40, '#maxlength' => 255, '#description' => t("Please specify the filename you wish to give your database backup. Once you click 'Backup %table' below your web browser will allow you to save the database backup to your local computer.", array('%table' => format_plural($quantity, 'table', 'tables')))); - $output = confirm_form('dba_verify_form', $form, - t('Backup %table to local computer?', array('%table' => format_plural($quantity, 'table', 'tables'))), - 'admin/database', - t('By clicking "backup %table" you will be prompted to save the following %table to your local computer: %tables', array('%tables' => $display, '%table' => format_plural($quantity, 'table', 'tables'))), - t('Backup %table', array('%table' => format_plural($quantity, 'table', 'tables'))), - t('Cancel')); - break; - } } return $output; } +function dba_verify_backup_form_submit($form_id, $form_values) { + if (is_array($form_values['tables'])) { + $tables = $form_values['tables']; + } + else { + $tables = explode(',', $form_values['tables']); + } + $file_name = $form_values['file_name']; + if (user_access('dba administer database')) { + $database = dba_get_database(); + Header("Content-type: application/octet-stream"); + Header("Content-Disposition: attachment; filename=". $file_name); + echo "-- Drupal dba.module database dump\n"; + echo "--\n"; + echo "-- Database: $database\n"; + echo "-- Date: ". format_date(time(), 'large') ."\n\n"; + foreach ($tables as $table) { + dba_backup_table($table, $form_values['add_drop_table']); + } + $quantity = sizeof($tables); + $display = implode(', ', $tables); + drupal_set_message(t("Saved %tables to %filename.", array('%filename' => theme('placeholder', $file_name), '%tables' => theme('placeholder', $display)))); + exit(0); + } +} + +function dba_verify_empty_form_submit($form_id, $form_values) { + if (is_array($form_values['tables'])) { + $tables = $form_values['tables']; + } + else { + $tables = explode(',', $form_values['tables']); + } + if (user_access('dba administer database')) { + foreach ($tables as $table) { + dba_delete_table($table); + } + } + if (sizeof($tables) > 1) { + drupal_goto('admin/database'); + } + drupal_goto("admin/database/table/$table/view"); +} + +function dba_verify_drop_form_submit($form_id, $form_values) { + if (is_array($form_values['tables'])) { + $tables = $form_values['tables']; + } + else { + $tables = explode(',', $form_values['tables']); + } + if (user_access('dba administer database')) { + foreach ($tables as $table) { + dba_drop_table($table); + } + } + drupal_goto('admin/database'); +} + + /********** * dba api * **********/ @@ -1295,4 +1319,15 @@ class mime_mail { $mail->send(); } -?> +function _dba_ops($op) { + $ops = array( + 'drop' => t('drop'), + 'describe' => t('describe'), + 'optimize' => t('optimize'), + 'check' => t('check'), + 'backup' => t('backup'), + 'empty' => t('empty'), + 'view' => t('view'), + ); + return $op ? $ops[$op] : $ops; +}