You are here

function dlike_flag_link in Drupal like (Flag counter) 7.2

Same name and namespace in other branches
  1. 7.3 dlike.module \dlike_flag_link()
  2. 7 dlike.module \dlike_flag_link()

This function is part of flag.module file. This function is overridden here.

2 calls to dlike_flag_link()
dlike_comment_view in ./dlike.module
Implementation of hook_comment_view().
dlike_node_view in ./dlike.module
Implementation of hook_node_view().

File

./dlike.module, line 171

Code

function dlike_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;
    }
    $dlike_append = dlike_append($type, $flag
      ->get_content_id($object), $flag->name);

    // 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) . $dlike_append,
      'html' => TRUE,
    );
  }
  if (isset($links)) {
    return $links;
  }
}