function dba_check_table_form_pre_render in Database Administration 5
1 string reference to 'dba_check_table_form_pre_render'
- dba_check_tables_form in ./dba.module
File
- ./dba.module, line 967
- 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_table_form_pre_render($form_id, &$form) {
if (form_get_errors()) {
return;
}
$action = isset($_POST['op']) ? $_POST['op'] : 'check';
$type = $form['check_options']['check_type']['#value'];
$tables = explode(',', $form['check_tables']['tables']['#value']);
if ($action == t('Repair')) {
drupal_set_title(t('Performing table repair.'));
$result = dba_repair_tables($tables);
}
else {
drupal_set_title(t('Performing %type table check', array(
'%type' => check_plain($type),
)));
$result = dba_check_tables($tables, $type);
}
$repair = array();
$header = array(
t('Table'),
t('Operation'),
t('Message type'),
t('Message text'),
);
while ($row = db_fetch_object($result)) {
$rows[] = (array) $row;
if ($row->Msg_type == 'status') {
$status = $row->Msg_text;
if ($status != 'OK' && $status != 'Table is already up to date') {
$repair_table = explode('.', $row->Table);
$repair[] = $repair_table[1];
}
}
}
$output .= theme('table', $header, $rows);
if ($repair) {
$output .= '<h3>' . t('One or more tables need repairs.') . '</h3>';
$to_repair = 1;
}
else {
$output .= '<h3>' . t('No repairs are required.') . '</h3>';
$to_repair = 0;
}
$form['check_results'] = array(
'#type' => 'fieldset',
'#title' => t('Result'),
'#weight' => -5,
);
$form['check_results']['result'] = array(
'#type' => 'markup',
'#value' => $output,
);
$form['check_results'] = form_builder('dba_check_tables', $form['check_results']);
if (user_access('dba administer database')) {
$repair_option = variable_get('dba_repair', 0);
if ($repair_option == 0 && $to_repair || $repair_option == 1) {
$form['check_options']['repair'] = array(
'#type' => 'submit',
'#value' => t('Repair'),
'#weight' => 20,
);
if (!$repair_option) {
$form['check_options']['repair_tables'] = array(
'#type' => 'hidden',
'#value' => implode(',', $repair_tables),
);
}
}
}
$form['check_options']['check_type']['#default_value'] = $type;
$form['check_options'] = form_builder('dba_check_tables', $form['check_options']);
}