You are here

function flag_flag_link in Flag 5

Same name and namespace in other branches
  1. 6.2 flag.module \flag_flag_link()
  2. 6 flag.module \flag_flag_link()
  3. 7.3 flag.module \flag_flag_link()
  4. 7.2 flag.module \flag_flag_link()

Implementation of hook_flag_link().

When Flag uses a link type provided by this module, it will call this implementation of hook_flag_link(). It returns a single link's attributes, using the same structure as hook_link(). Note that "title" is provided by the Flag configuration if not specified here.

Parameters

$flag: The full flag object of for the flag link being generated.

$action: The action this link will perform. Either 'flag' or 'unflag'.

$content_id: The ID of the node, comment, user, or other object being flagged.

Return value

An array defining properties of the link.

File

./flag.module, line 192
The Flag module.

Code

function flag_flag_link(&$flag, $action, $content_id) {
  $token = flag_get_token($content_id);
  return array(
    'href' => "flag/" . ($flag->link_type == 'confirm' ? 'confirm/' : '') . "{$action}/{$flag->name}/{$content_id}",
    'query' => drupal_get_destination() . ($flag->link_type == 'confirm' ? '' : '&token=' . $token),
  );
}