function heartbeat_stream in Heartbeat 7
Prepares a heartbeat stream.
Parameters
$stream_name Name of the stream.:
8 calls to heartbeat_stream()
- HeartbeatActivity::hasAccess in includes/
heartbeatactivity.inc - hasAccess().
- heartbeat_activity_older in ./
heartbeat.pages.inc - JavaScript callback to load older messages.
- heartbeat_activity_poll in ./
heartbeat.pages.inc - Callback to poll for newer messages. Each stream is displayed within a context.
- heartbeat_block_view in ./
heartbeat.module - Implements hook_block_view().
- heartbeat_messages_page in ./
heartbeat.pages.inc - Page callback function to load an activity stream page
File
- ./
heartbeat.streams.inc, line 7
Code
function heartbeat_stream($stream_name, $page = 0, $account = NULL) {
static $streams;
try {
if (!isset($streams[$stream_name])) {
// Load a configuration object for the stream.
$streamConfig = heartbeat_stream_config_load($stream_name);
// Load the stream if access to it is granted.
if (_heartbeat_stream_has_access($streamConfig)) {
$heartbeatStream = HeartbeatStreamFactory::getStream($streamConfig, $page, $account);
// Add settings that need to be set for each stream.
drupal_add_js(array(
'heartbeatPollNewerMessages' => array(
$streamConfig->class => $streamConfig->poll_messages,
),
), 'setting');
drupal_add_js(array(
'heartbeatPollTypes' => array(
$streamConfig->class => $streamConfig->poll_messages_type,
),
), 'setting');
// Give other modules a chance to take action when the stream is loaded.
module_invoke_all('heartbeat_stream_load', $heartbeatStream);
if ($heartbeatStream instanceof HeartbeatStream && !$heartbeatStream
->hasErrors()) {
$streams[$stream_name] = $heartbeatStream;
}
else {
$streams[$stream_name] = FALSE;
}
}
else {
$streams[$stream_name] = FALSE;
}
}
} catch (HeartbeatInvalidStreamException $h) {
drupal_set_message($h
->getMessage());
drupal_not_found();
}
return $streams[$stream_name];
}