You are here

function db_maintenance_admin_settings_validate in DB Maintenance 5.2

Same name and namespace in other branches
  1. 6.2 db_maintenance.module \db_maintenance_admin_settings_validate()
  2. 7.2 db_maintenance.admin.inc \db_maintenance_admin_settings_validate()

File

./db_maintenance.module, line 292
Optimizes database tables during cron runs.

Code

function db_maintenance_admin_settings_validate($formid, &$form) {
  if (!is_dir($form['db_maintenance_backup_directory'])) {
    form_set_error('db_maintenance_backup_directory', t('Backup directory does not exist or is not a directory.'));
  }
  elseif (!is_writable($form['db_maintenance_backup_directory'])) {
    form_set_error('db_maintenance_backup_directory', t('Backup directory is not writable.'));
  }
  if (!is_file($form['db_maintenance_path_to_tar'])) {
    form_set_error('db_maintenance_path_to_tar', t('Path to tar is incorrect.'));
  }
  elseif (!is_executable($form['db_maintenance_path_to_tar'])) {
    form_set_error('db_maintenance_path_to_tar', t('tar is not executable.'));
  }
  if (!is_file($form['db_maintenance_path_to_mysqldump'])) {
    form_set_error('db_maintenance_path_to_mysqldump', t('Path to mysqldump is incorrect.'));
  }
  elseif (!is_executable($form['db_maintenance_path_to_mysqldump'])) {
    form_set_error('db_maintenance_path_to_mysqldump', t('mysqldump is not executable.'));
  }
  $emails = explode(',', $form['db_maintenance_email_notify']);
  if (!empty($emails)) {
    $bad = array();
    foreach ($emails as $email) {
      $email = trim($email);
      if (!valid_email_address($email)) {
        $bad[] = $email;
      }
    }
    if (!empty($bad)) {
      form_set_error('db_maintenance_email_notify', t('The following email address(es) were invalid; @badmail', array(
        '@badmail' => implode(', ', $bad),
      )));
    }
  }
}