function hansel_action_add_link_to_user_get_crumbs in Hansel breadcrumbs 8
Same name and namespace in other branches
- 7 hansel.actions.inc \hansel_action_add_link_to_user_get_crumbs()
Callback for the "add link to user" breadcrumb action to generate the crumbs.
Parameters
array $arguments:
Return value
array
2 string references to 'hansel_action_add_link_to_user_get_crumbs'
- hansel_hansel_action_types in ./
hansel.module - Implements hook_hansel_action_types().
- hook_hansel_action_types in ./
hansel.hooks.inc - Define action types.
File
- ./
hansel.actions.inc, line 111 - Hansel breadcrumb actions
Code
function hansel_action_add_link_to_user_get_crumbs($arguments) {
global $user;
$links = array();
// Check if we have to use the realname integration.
if (module_exists('realname')) {
$use_realname = isset($arguments['realname']) && $arguments['realname'];
}
else {
$use_realname = FALSE;
}
if (drupal_strtolower(hansel_arg(0)) == 'user' && is_numeric(hansel_arg(1))) {
if (!empty($arguments['you']) && $user->uid == hansel_arg(1) && $user->uid) {
$links[] = array(
'title' => isset($arguments['translate']) && $arguments['translate'] ? t($arguments['you']) : $arguments['you'],
'href' => 'user/' . $user->uid,
);
}
else {
$cid = 'user:' . hansel_arg(1) . ':' . ($use_realname ? 'real' : 'std');
if ($data = hansel_cache_get($cid)) {
return $data;
}
if ($account = user_load(hansel_arg(1))) {
$links[] = array(
'title' => $use_realname ? $account->realname : $account->name,
'href' => 'user/' . $account->uid,
);
}
hansel_cache_set($cid, $links);
}
}
elseif (drupal_strtolower(hansel_arg(0)) == 'node' && is_numeric(hansel_arg(1))) {
if ($node = node_load(hansel_arg(1))) {
if (!empty($arguments['you']) && $node->uid == $user->uid && $node->uid) {
$links[] = array(
'title' => isset($arguments['translate']) && $arguments['translate'] ? t($arguments['you']) : $arguments['you'],
'href' => 'user/' . $user->uid,
);
}
else {
$cid = 'user:' . hansel_arg(1) . ':' . ($use_realname ? 'real' : 'std');
if ($data = hansel_cache_get($cid)) {
return $data;
}
if ($account = user_load($node->uid)) {
$links[] = array(
'title' => $use_realname ? $account->realname : $account->name,
'href' => 'user/' . $account->uid,
);
}
hansel_cache_set($cid, $links);
}
}
}
return $links;
}