function follow_url_validate in Follow 6
Same name and namespace in other branches
- 7.2 follow.inc \follow_url_validate()
- 7 follow.module \follow_url_validate()
Validates the url field to verify it's actually a url.
1 string reference to 'follow_url_validate'
- _follow_links_form_link in ./follow.module 
- Helper function to create an individual link form element.
File
- ./follow.module, line 584 
- Allows users to add links to their social network profiles.
Code
function follow_url_validate($form) {
  $url = trim($form['#value']);
  $networks = follow_networks_load($form['#follow_uid']);
  $info = $networks[$form['#follow_network']];
  // @see follow_network_regex().
  $regex_callback = isset($info['regex callback']) && function_exists($info['regex callback']) ? $info['regex callback'] : 'follow_network_regex';
  $regex = $regex_callback($info);
  $parsed = follow_parse_url($url);
  if ($url && !preg_match($regex, $parsed['path'])) {
    if (!empty($info['domain'])) {
      $message = t('The specified url is invalid for the domain %domain.  Make sure you use http://.', array(
        '%domain' => $info['domain'],
      ));
    }
    else {
      $message = t('The specified path is invalid.');
    }
    form_error($form, $message);
  }
}