You are here

function multiple_email_handler_filter_current::query in Multiple E-mail Addresses 7

Same name and namespace in other branches
  1. 6 views/multiple_email_handler_filter_current.inc \multiple_email_handler_filter_current::query()
  2. 2.x views/multiple_email_handler_filter_current.inc \multiple_email_handler_filter_current::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter_boolean_operator::query

File

views/multiple_email_handler_filter_current.inc, line 18
filter heandler for matching e-mail addresses to cck e-mail field.

Class

multiple_email_handler_filter_current
Filter handler for the current user's e-mail addresses to match a field.

Code

function query() {
  $this
    ->ensure_my_table();
  $where = "{$this->table_alias}.{$this->real_field} ";

  // get the current user's addresses
  global $user;
  $emails = multiple_email_load_addresses($user->uid);
  $addresses = array();
  foreach ($emails as $email) {
    if (is_object($email) && $email->confirm_code) {
      $addresses[] = $email->email;
    }
  }
  if (empty($this->value)) {
    $where .= 'NOT ';
  }
  $where .= "IN ('" . implode("','", $addresses) . "') ";
  $this->query
    ->add_where($this->options['group'], $where);
}