You are here

function persistent_login_admin_settings_validate in Persistent Login 7

Same name and namespace in other branches
  1. 6 persistent_login.pages.inc \persistent_login_admin_settings_validate()

Validate the module settings form.

1 string reference to 'persistent_login_admin_settings_validate'
persistent_login_admin_settings in ./persistent_login.pages.inc
Module settings form.

File

./persistent_login.pages.inc, line 87
Implementation of Persistent Login forms.

Code

function persistent_login_admin_settings_validate($form, &$form_state) {
  $form_values =& $form_state['values'];
  if (!preg_match('`^[0-9]+$`', $form_values['persistent_login_maxlife'])) {
    form_set_error('persistent_login_maxlife', t('%name: You should specify a valid integer value.', array(
      '%name' => $form['persistent_login_maxlife']['#title'],
    )));
  }
  if (!preg_match('`^[-_A-Za-z0-9]+$`', $form_values['persistent_login_cookie_prefix'])) {
    form_set_error('persistent_login_cookie_prefix', t('%name: Characters allowed: ascii letters ([A-Z], [a-z]), digits ([0-9]), hyphens ("-") or underscores ("_").', array(
      '%name' => $form['persistent_login_cookie_prefix']['#title'],
    )));
  }
  elseif ($form_values['persistent_login_cookie_prefix'] == 'SESS') {
    form_set_error('persistent_login_cookie_prefix', t('%name: Invalid value. "SESS" is already used by the Drupal session cookie.', array(
      '%name' => $form['persistent_login_cookie_prefix']['#title'],
    )));
  }
  if (!preg_match('`^[0-9]+$`', $form_values['persistent_login_history'])) {
    form_set_error('persistent_login_history', t('%name: You should specify a valid integer value.', array(
      '%name' => $form['persistent_login_history']['#title'],
    )));
  }
}