You are here

function anonymous_publishing_views_views_query_alter in Anonymous Publishing 7

Implements hook_views_query_alter().

File

modules/views/anonymous_publishing_views.views.inc, line 14
Provides integration with the Views module.

Code

function anonymous_publishing_views_views_query_alter(&$view, &$query) {
  foreach ($query->fields as $field_key => &$field_values) {
    if ($field_values['table'] == 'anonymous_publishing') {
      switch ($field_values['field']) {
        case 'byline':
          unset($query->fields[$field_key]);
          $query
            ->add_field(NULL, "(SELECT alias FROM {anonymous_publishing_emails} WHERE email = anonymous_publishing.email)", $field_key);
          break;
      }
    }
  }
}