function dba_check_tables_form in Database Administration 5
1 string reference to 'dba_check_tables_form'
- dba_admin_tables_check in ./
dba.module - MySQL only: check the selected table(s).
File
- ./
dba.module, line 905 - 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_check_tables_form() {
// Setup a form value to remember what table(s) we're operating on.
$form['check_tables']['tables']['#type'] = 'hidden';
// First, see if we what the active table is, based solely on
// $_SESSION and the URL.
$tables = dba_get_active_tables(0);
unset($_SESSION['dba_tables']);
if (!empty($tables)) {
// We already know, so this is easy...
$form['check_tables']['tables']['#default_value'] = implode(',', $tables);
}
else {
// It must be in the form values, then. In this case, we need to
// call form_builder() to safely grab the data out of $_POST.
$form['check_tables'] = form_builder('dba_check_tables', $form['check_tables']);
if (!empty($form['check_tables']['tables']['#value'])) {
$form_tables = explode(',', $form['check_tables']['tables']['#value']);
$tables = dba_get_active_tables(0, $form_tables);
}
}
// Make sure we have something to do.
if (empty($tables)) {
drupal_set_message(t('You must select the tables to check.'), 'error');
drupal_goto('admin/build/database');
}
$form['check_options'] = array(
'#type' => 'fieldset',
'#title' => t('Actions'),
);
$form['check_options']['check_type'] = array(
'#type' => 'radios',
'#title' => t('Check type'),
'#default_value' => variable_get('dba_default_check_type', 'MEDIUM'),
'#options' => array(
'QUICK' => t('Quick'),
'FAST' => t('Fast'),
'CHANGED' => t('Changed'),
'MEDIUM' => t('Medium'),
'EXTENDED' => t('Extended'),
),
);
$form['check_options']['check'] = array(
'#type' => 'submit',
'#value' => t('Check again'),
);
// Most of the interesting stuff in this form has to be added via
// #pre_render, so that we can safely use validated form values to
// dynamically generate other form elements. In particular, we add
// a fieldset with the results of whatever operation we perform, and
// depending on the admin settings and the state of the tables, we
// might need to add a 'Repair' button, too.
$form['#pre_render'][] = 'dba_check_table_form_pre_render';
// We don't want to get redirected, which would run the queries twice.
$form['#redirect'] = false;
return $form;
}