You are here

public function scald_views_handler_filter_actions::query in Scald: Media Management made easy 7

Same name and namespace in other branches
  1. 6 includes/scald_views_handler_filter_actions.inc \scald_views_handler_filter_actions::query()

Overrides query.

Change the operator before querying.

Overrides views_handler_filter::query

File

includes/scald_views_handler_filter_actions.inc, line 74
Provides a filter allowing to restrict the results by atoms actions.

Class

scald_views_handler_filter_actions
@file Provides a filter allowing to restrict the results by atoms actions.

Code

public function query() {
  if (is_array($this->value)) {
    $values = drupal_map_assoc($this->value);
    $bitmask = 0;
    $actions = scald_actions();
    foreach ($actions as $name => $action) {
      if (!empty($values[$name])) {
        $bitmask |= $action['bitmask'];
      }
    }
  }
  else {
    $bitmask = $this->value;
  }
  switch ($this->operator) {
    case '&':
      $this->operator = ' & ' . $bitmask . ' = ';
      $this->value = $bitmask;
      break;
    case 'in':
      $this->operator = ' & ' . $bitmask . ' >';
      $this->value = 0;
      break;
    case 'not in':
      $this->operator = ' & ' . $bitmask . ' = ';
      $this->value = 0;
      break;
  }
  parent::query();
}