You are here

function flickrapi_admin_settings_validate in Flickr API 7

Same name and namespace in other branches
  1. 5 flickrapi.module \flickrapi_admin_settings_validate()
  2. 6 flickrapi.module \flickrapi_admin_settings_validate()
  3. 7.2 flickrapi.admin.inc \flickrapi_admin_settings_validate()

Validator for the admin settings form.

1 string reference to 'flickrapi_admin_settings_validate'
flickrapi_admin_settings in ./flickrapi.admin.inc
Admin settings form

File

./flickrapi.admin.inc, line 135
Admin settings form and OAuth authentication integration

Code

function flickrapi_admin_settings_validate($form, &$form_state) {
  $key = trim($form_state['values']['flickrapi_api_key']);
  $secret = trim($form_state['values']['flickrapi_api_secret']);
  $cache = $form_state['values']['flickrapi_cache'];
  $cache_dir = $form_state['values']['flickrapi_cache_path'];
  if ($key && preg_match('/^[A-Fa-f\\d]{32}$/', $key) != 1) {
    form_set_error('flickrapi_api_key', t('This does not appear to be a Flickr API key.'));
  }
  if ($secret && preg_match('/^[A-Fa-f\\d]{16}$/', $secret) != 1) {
    form_set_error('flickrapi_api_secret', t('This does not appear to be a Flickr API secret.'));
  }
  if ($cache && !file_prepare_directory($cache_dir)) {
    form_set_error('flickrapi_cache_path', t('Cache folder does not exist or it is not writable.'));
  }
}