You are here

function node_expire_default_settings_form_validate in Node expire 6

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

Implementation of hook_form_validate().

1 string reference to 'node_expire_default_settings_form_validate'
node_expire_default_settings_form in ./node_expire.admin.inc
Configuration form for default expirations for node_expire

File

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

Code

function node_expire_default_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')) {

    // The only field we have to check is the expiration date
    foreach ($form_state['values'] as $key => $val) {
      if (is_array($val) and isset($val['expire']) and $val['expiremode'] != NODE_EXPIRE_ONUPDATE) {
        if (($thetime = strtotime($val['expire'])) === FALSE) {
          form_set_error($key . '][expire', t('The entered expiration date is invalid.'));
        }
        elseif ($thetime <= time()) {
          form_set_error($key . '][expire', t('The entered expiration date occurrs in the past.'));
        }
      }
    }
  }
}