You are here

function _heartbeat_group_views_messages in Heartbeat 6.4

Same name and namespace in other branches
  1. 6.3 views/heartbeat_views.module \_heartbeat_group_views_messages()

Helper function to group and merge message built by views.

1 call to _heartbeat_group_views_messages()
_heartbeat_render_view in views/heartbeat_views.module
Helper function to (re-)render the messages from views.

File

views/heartbeat_views.module, line 176

Code

function _heartbeat_group_views_messages($name, $messages, $stream) {
  heartbeat_include('HeartbeatParser');
  $heartbeat = HeartbeatParser::instantiate($name);
  if (!empty($stream->grouping_seconds)) {
    $timespan = $stream->grouping_seconds;
  }
  else {
    $timespan = variable_get('heartbeat_activity_grouping_seconds', 7200);
  }
  $heartbeat
    ->set_timespan_gap($timespan);
  $heartbeat
    ->build_sets($messages);
  $heartbeat
    ->merge_sets();
  $messages = $heartbeat
    ->get_messages();
  $num_total_messages = count($messages);

  // From here we know the number of messages actualy loaded (and allowed)
  $messages = array_values(array_slice($messages, 0, $stream->limit_sql));

  // Give contributes modules the last chance to hook into the messages
  if (empty($stream->name)) {
    heartbeat_include('heartbeatstream', 'heartbeat');
    heartbeat_include('publicheartbeat', 'heartbeat');
    $heartbeatAccess = new PublicHeartbeat(new HeartbeatStream(heartbeat_stream_load('publicheartbeat')));
  }
  else {
    $class = $stream->name;
    heartbeat_include($stream->name, $stream->module);
    $heartbeatAccess = new $class($stream);
  }

  // Let other module load additions.
  $hook = 'heartbeat_load';
  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;

    // $messages should be implemented by reference!!!
    $function($messages, $heartbeatAccess);
  }

  // Let other modules retheme or completely rebuild messages.
  $hook = 'heartbeat_theme_alter';
  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;
    $result = $function($messages, $heartbeatAccess);
  }

  // let other modules hook into the theming of the components.
  $hook = 'heartbeat_view';
  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;

    // $messages should be implemented by reference!!!
    $function($messages, $heartbeatAccess);
  }
  return $messages;
}