You are here

function heartbeat_stream_view in Heartbeat 6.4

Same name and namespace in other branches
  1. 7 heartbeat.streams.inc \heartbeat_stream_view()

Helper function to load a heartbeat stream / access type

4 calls to heartbeat_stream_view()
heartbeat_activity_poll in ./heartbeat.pages.inc
Callback to poll for newer messages.
heartbeat_block in ./heartbeat.module
Implementation of hook_blocks().
heartbeat_messages_page in ./heartbeat.pages.inc
Page callback function to load an activity stream page.
heartbeat_message_activity in ./heartbeat.pages.inc
Page callback for one activity message.

File

./heartbeat.module, line 1724

Code

function heartbeat_stream_view($access_type, $page = FALSE, $offset = 0, $ajax = FALSE, $account = NULL) {

  // Message streams for each access type
  if ($type = _heartbeat_access_type_has_access($access_type)) {
    heartbeat_include('HeartbeatStream');
    heartbeat_include('HeartbeatMessageBuilder');
    heartbeat_include('HeartbeatParser');
    heartbeat_include($type['class'], $type['module'], $type['path']);
    $accesstype = $type['class'];
    $realname = isset($type['realname']) ? $type['realname'] : $accesstype;
    $stream = new HeartbeatStream($type);
    $heartbeatAccess = new $accesstype($stream, $page, $account);

    // Set the js variable to poll for newer messages

    //if ($heartbeatAccess->stream->poll_messages == 100) {

    // Use XMPP to serve the activity

    //}
    drupal_add_js(array(
      'heartbeatPollNewerMessages' => array(
        drupal_strtolower($realname) => $heartbeatAccess->stream->poll_messages,
      ),
    ), 'setting');
    $heartbeatAccess
      ->setOffsetSql($offset);
    $context = HeartbeatMessageBuilder::get_instance($heartbeatAccess);
    if (!$context
      ->hasErrors()) {
      return $context;
    }
  }
  return NULL;
}