You are here

function commons_follow_views_query_alter in Drupal Commons 7.3

Implements hook_views_query_alter().

File

modules/commons/commons_follow/commons_follow.module, line 349

Code

function commons_follow_views_query_alter(&$view, &$query) {

  // Only act on the notifications page.
  if (arg(2) != 'notification-settings') {
    return;
  }
  global $user;
  $prefix = variable_get('message_subscribe_flag_prefix', 'subscribe') . '_';
  if (strpos($view->name, $prefix) === 0 && isset($view->args[0]) && $user->uid != $view->args[0]) {
    $flag_content_keys = array_keys($query->table_queue);
    foreach ($flag_content_keys as $key) {
      if (strpos($key, 'flagging') === 0) {

        //Convert the Send Email Query
        $join = $query->table_queue[$key]['join'];
        $join->extra[1] = array(
          'field' => 'uid',
          'value' => $view->args[0],
          'numeric' => TRUE,
        );
        $query->table_queue[$key]['join'] = $join;
      }
    }
  }
}