function flag_link in Flag 7.2
Same name and namespace in other branches
- 5 flag.module \flag_link()
- 6.2 flag.module \flag_link()
- 6 flag.module \flag_link()
Implements hook_link().
This hook does not exist in Drupal 7, it is called from flag_entity_view().
1 call to flag_link()
- flag_entity_view in ./
flag.module - Implements hook_entity_view().
File
- ./
flag.module, line 237 - The Flag module.
Code
function flag_link($type, $object = NULL, $teaser = FALSE) {
if (!isset($object) || !flag_fetch_definition($type)) {
return;
}
global $user;
// Get all possible flags for this content-type.
$flags = flag_get_flags($type);
foreach ($flags as $flag) {
$content_id = $flag
->get_content_id($object);
if (!$flag
->uses_hook_link($teaser)) {
// Flag is not configured to show its link here.
continue;
}
if (!$flag
->access($content_id) && (!$flag
->is_flagged($content_id) || !$flag
->access($content_id, 'flag'))) {
// User has no permission to use this flag or flag does not apply to this
// content. The link is not skipped if the user has "flag" access but
// not "unflag" access (this way the unflag denied message is shown).
continue;
}
// The flag links are actually fully rendered theme functions.
// The HTML attribute is set to TRUE to allow whatever the themer desires.
$links['flag-' . $flag->name] = array(
'title' => $flag
->theme($flag
->is_flagged($content_id) ? 'unflag' : 'flag', $content_id),
'html' => TRUE,
);
}
if (isset($links)) {
return $links;
}
}