You are here

function node_expire_settings_form_validate in Node expire 6

Same name and namespace in other branches
  1. 5 node_expire.module \node_expire_settings_form_validate()

Implementation of hook_form_validate().

1 string reference to 'node_expire_settings_form_validate'
node_expire_settings_form in ./node_expire.admin.inc
Configuration form for node_expire

File

./node_expire.admin.inc, line 109
Module settings.

Code

function node_expire_settings_form_validate(&$form, &$form_state) {

  // Only validate the form if we're saving changes. We don't care about values if we're just resetting them anyway.
  if ($form_state['values']['op'] == t('Save configuration')) {

    // Is the CC address valid?
    if ($form_state['values']['node-expire-cc'] and !valid_email_address($form_state['values']['node-expire-cc'])) {
      form_set_error('node-expire-cc', t('The entered carbon copy address is invalid.'));
    }

    // Count instances of !start_section!
    $matches = array();
    preg_match_all('/!start_section!/', $form_state['values']['node-expire-body'], $matches);
    if (count($matches[0]) > 1) {
      form_set_error('node-expire-body', t('The tag "!start_section!" can only be used once.'));
    }

    // Make sure instances of !start_section! match !stop_section!
    $matches2 = array();
    preg_match_all('/!stop_section!/', $form_state['values']['node-expire-body'], $matches2);
    if (count($matches[0]) != count($matches2[0])) {
      form_set_error('node-expire-body', t('The tag "!stop_section!" is missing or doesn\'t match with "!start_section!".'));
    }
  }
}