You are here

views_sort_expression.module in Views Sort Expression 7

Same filename and directory in other branches
  1. 8 views_sort_expression.module

File

views_sort_expression.module
View source
<?php

/**
 * Implements of hook_views_api().
 */
function views_sort_expression_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'views_sort_expression') . '/views',
  );
}

/**
 * Implements hook_views_post_build().
 *
 * Remove views_sort_expression from group by if it was configured as a group by
 * manually
 *
 */
function views_sort_expression_views_post_build(&$view) {
  foreach ($view->sort as $handler) {
    if ($handler instanceof views_sort_expression_handler) {
      if ($handler->options['aggregate']) {
        $alias = $handler->real_field . '_' . $handler->position;
        $group_by =& $view->build_info['query']
          ->getGroupBy();
        unset($group_by[$alias]);
      }
    }
  }
}