You are here

function flag_handler_field_ops::render in Flag 6

Same name and namespace in other branches
  1. 6.2 includes/flag_handler_field_ops.inc \flag_handler_field_ops::render()
  2. 7.3 includes/views/flag_handler_field_ops.inc \flag_handler_field_ops::render()
  3. 7.2 includes/flag_handler_field_ops.inc \flag_handler_field_ops::render()

File

includes/flag_handler_field_ops.inc, line 119
Contains the flag Ops field handler.

Class

flag_handler_field_ops
Views field handler for the Flag operations links (flag/unflag).

Code

function render($values) {
  $flag = $this
    ->get_flag();
  if (!$flag
    ->user_access()) {

    // User has no permission to use this flag.
    return;
  }
  $content_id = $values->{$this->aliases['content_id']};
  $is_flagged = $values->{$this->aliases['is_flagged']};
  if (!isset($this->flag_applies[$content_id])) {

    // Flag does not apply to this content.
    return;
  }
  if (!empty($this->options['link_type'])) {
    $flag->link_type = $this->options['link_type'];
  }
  return $flag
    ->theme($is_flagged ? 'unflag' : 'flag', $content_id);
}