function dba_verify in Database Administration 5
1 string reference to 'dba_verify'
- dba_admin_tables_verify_op in ./
dba.module - Menu callback to verify the administrator wants to backup, empty or drop the selected table(s) by means of a confirm form.
File
- ./
dba.module, line 1134 - Allows administrators direct access to their Drupal database. Written by Jeremy Andrews <jeremy@kerneltrap.org>, June 2004. PostgreSQL functionality provided by AAM <aam@ugpl.de> Major security audit, porting, and maintenance by Derek…
Code
function dba_verify($tables, $action) {
$quantity = count($tables);
if ($quantity) {
$form = array();
$table_list = theme('placeholder', implode(', ', $tables));
$table_id = format_plural($quantity, 'table', 'tables');
$substitutions = array(
'!tables' => $table_list,
'!table' => $table_id,
'!this' => format_plural($quantity, 'this', 'these'),
'!itself' => format_plural($quantity, 'itself', 'themselves'),
'!its' => format_plural($quantity, 'its', 'their'),
);
$form['tables'] = array(
'#type' => 'value',
'#value' => implode(',', $tables),
);
switch ($action) {
case 'backup':
if ($quantity == 1) {
$filename = reset($tables) . '.sql';
}
else {
$filename = 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.'),
);
$form = confirm_form($form, t('Backup !table to local computer?', array(
'!table' => $table_id,
)), 'admin/build/database', t('By clicking "Backup !table" you will be prompted to save the following !table to your local computer: !tables', array(
'!tables' => $table_list,
'!table' => $table_id,
)), t('Backup !table', array(
'!table' => $table_id,
)), t('Cancel'));
$form['#base'] = 'dba_verify_backup_form';
break;
case 'empty':
$form = confirm_form($form, t('Are you sure you want to delete all rows from the "!tables" !table?', $substitutions), 'admin/build/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.', $substitutions), t('Empty !table', array(
'!table' => $table_id,
)), t('Cancel'));
$form['#base'] = 'dba_verify_empty_form';
break;
case 'drop':
$form = confirm_form($form, t('Are you sure you want to drop the "!tables" !table?', $substitutions), 'admin/build/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.', $substitutions), t('Drop !table', array(
'!table' => $table_id,
)), t('Cancel'));
$form['#base'] = 'dba_verify_drop_form';
break;
}
}
return $form;
}