You are here

function flickr_admin_settings_validate in Flickr 5

Same name and namespace in other branches
  1. 6 flickr.admin.inc \flickr_admin_settings_validate()
  2. 7 flickr.admin.inc \flickr_admin_settings_validate()

File

./flickr.module, line 141

Code

function flickr_admin_settings_validate($form_id, $form) {
  $key = trim($form['flickr_api_key']);
  $sec = trim($form['flickr_api_secret']);
  $uid = trim($form['flickr_default_userid']);
  if ($key && preg_match('/^[A-Fa-f\\d]{32}$/', $key) != 1) {
    form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
  }
  if ($sec && preg_match('/^[A-Fa-f\\d]{16}$/', $sec) != 1) {
    form_set_error('flickr_api_secret', t('This does not appear to be a Flickr API secret.'));
  }
  if ($uid) {
    if (flickr_is_nsid($uid)) {

      // it's already a uid
    }
    else {
      $user = flickr_user_find_by_username($uid);
      if (!$user) {
        form_set_error('flickr_default_userid', t('%uid is not a Flickr user id and it does not appear to be a valid user name.', array(
          '%uid' => $uid,
        )));
      }
    }
  }
}