You are here

function views_plugin_row_heartbeat_view::pre_render in Heartbeat 7

Implements pre_render($values).

Here the stream is build, but letting users create the stream custom. If they do so, the default access checks which heartbeat normally does in the query will not be executed. If they configured the stream to behave like a heartbeat stream, then Heartbeat will take over the base query.

Overrides views_plugin_row::pre_render

File

views/views_plugin_row_heartbeat_view.inc, line 107
Contains the heartbeat activity view row style plugin.

Class

views_plugin_row_heartbeat_view
Plugin which performs a heartbeat_activity_view on the resulting object.

Code

function pre_render($values) {
  $uaids = array();
  foreach ($values as $row) {
    $uaids[] = $row->{$this->field_alias};
  }

  // We create a stream, however the query does not need to run since
  // views took care of that part. By creating a stream we can provide
  // the general flow to display everything.
  if ($heartbeatStream = heartbeat_stream('viewsactivity', $this->display->display_plugin == 'page', $GLOBALS['user'])) {
    $heartbeatStream->rowPlugin = TRUE;

    // Use the views limit instead of heartbeats stream setting.
    if (isset($this->view->query->limit)) {
      $heartbeatStream->config->num_load_max = $this->view->query->limit;
    }

    // Load activities by using the heartbeat loader.
    $this->activities = heartbeat_stream_views_build($heartbeatStream, $uaids);

    // Store the stream for later usage.
    $this->stream = $heartbeatStream;
    if ($heartbeatStream
      ->hasErrors()) {
      drupal_set_message(implode('<br />', $heartbeatStream
        ->getErrors()));
    }
  }
}