You are here

function flag_handler_field_ops::pre_render in Flag 6

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

Find out if the flag applies to each item seen on the page. It's done in a separate DB query to to avoid complexity and to make 'many to one' tests (e.g. checking user roles) possible without causing duplicate rows.

File

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

Class

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

Code

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

    // User has no permission to use this flag.
    return;
  }
  $ids = array();
  foreach ($values as $row) {
    $content_id = $row->{$this->aliases['content_id']};
    if (isset($content_id)) {
      $ids[$content_id] = TRUE;
    }
  }
  $this->flag_applies = $ids ? $flag
    ->applies_to_content_id_array(array_keys($ids)) : array();
}