You are here

function node_expire_default_settings_form_validate in Node expire 5

Same name and namespace in other branches
  1. 6 node_expire.admin.inc \node_expire_default_settings_form_validate()

Implementation of hook_form_validate()

File

./node_expire.module, line 494
Alerts administrators of possibly outdated materials and optionally unpublishes them.

Code

function node_expire_default_settings_form_validate($form_id, $form_values) {

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

    // The only field we have to check is the expiration date
    foreach ($form_values as $key => $val) {
      if (is_array($val) && isset($val['expire']) && $val['expiration_type'] != 'onupdate') {
        if (($thetime = strtotime($val['expire'])) === false) {
          form_set_error($key . '][expire', t('The entered expiration date is invalid.'));
        }
        else {
          if ($thetime <= time()) {
            form_set_error($key . '][expire', t('The entered expiration date occurrs in the past.'));
          }
        }
      }
    }
  }
}