You are here

function uuid_link_replace_callback in UUID Link 6

Replace callback for uuid link tokens.

1 string reference to 'uuid_link_replace_callback'
uuid_link_filter_prepare in ./uuid_link.module
Filter prepare callback. Replaces [uuid-link:xxxx] with links.

File

./uuid_link.module, line 195
Provides a filter and UI for adding links to entities that are not affected by changes in URL alias.

Code

function uuid_link_replace_callback($matches) {
  $url = NULL;
  $type = $matches[1];
  $uuid = $matches[2];
  if ($type == 'node' && ($nid = uuid_link_get_nid($uuid))) {
    $url = url("node/{$nid}");
  }
  elseif ($type == 'user' && ($uid = uuid_link_get_uid($uuid))) {
    $url = url("user/{$uid}");
  }
  if (empty($url)) {
    $url = '#uuid-link-not-found';
  }
  return $url;
}