You are here

function htaccess_admin_settings_generate_validate in Htaccess 7.2

Admin htaccess generate validation handler.

1 string reference to 'htaccess_admin_settings_generate_validate'
htaccess_generate in ./htaccess.admin.inc
Admin htaccess generate form.

File

./htaccess.admin.inc, line 424
Administration pages.

Code

function htaccess_admin_settings_generate_validate($form, &$form_state) {
  $profile_name = $form_state['values']['htaccess_settings_generate_name'];
  if (preg_match('/[^a-z0-9]/', $profile_name)) {
    form_error($form, t('The name of the profile must be lowercase and without any special character.'));
  }

  // The name of the profile must be unique
  $htaccess_name = db_select('htaccess', 'h')
    ->fields('h')
    ->condition('name', $profile_name, '=')
    ->execute()
    ->fetchAssoc();
  if ($htaccess_name) {
    form_error($form, t('The profile @profile already exists.', array(
      '@profile' => $profile_name,
    )));
  }
}