protected function HeartbeatAccess::prepareStream in Heartbeat 6.4
prepareStream
Parameters
$text:
Return value
HeartbeatParser object
1 call to HeartbeatAccess::prepareStream()
- HeartbeatAccess::fetchMessages in includes/
heartbeataccess.inc
2 methods override HeartbeatAccess::prepareStream()
- GroupsActivity::prepareStream in modules/
og_activity/ groupsactivity.inc - Override of the prepareStream function
- SingleHeartbeat::prepareStream in includes/
singleheartbeat.inc - prepareStream
File
- includes/
heartbeataccess.inc, line 241 - HeartbeatAccess object is the object that takes stream configuration to create a stream of activity objects. It is the controlling organ at the pre-query, query and post-query phases.
Class
- HeartbeatAccess
- Abstract class heartbeataccess This base class has final template methods which are used by the derived concretes. The HeartbeatAccess is a state object that is given to the HeartbeatMessageBuilder to set the access to the current request.
Code
protected function prepareStream() {
global $user, $language;
$this->stream->offset_sql = $this->_offset_sql;
// Prevent already assigned language to be overriden
if (empty($this->stream->language)) {
$this->stream->language = $language->language;
}
// Sql parts
// If users are involved (uid or uid_target) in heartbeat_activity
// check if they are not blocked (status = 1).
$this->stream->sql_start = "SELECT\n hm.hid AS 'hid', hm.message AS 'message_orig',\n hm.message_concat AS 'message_concat_orig',\n hm.attachments AS 'attachments', hm.concat_args,\n hm.custom AS 'custom', hm.description as 'description',\n hm.perms, hm.variables AS 'variables_orig',\n ua.*, ua_users.*,\n ua.access AS 'access',\n 1 AS 'count'\n FROM {heartbeat_activity} ua\n LEFT JOIN {heartbeat_messages} hm ON ua.message_id = hm.message_id\n LEFT JOIN {users} ua_users ON ua.uid = ua_users.uid\n LEFT JOIN {users} ua_target_users ON ua.uid_target = ua_target_users.uid\n WHERE\n ua.language = '%s'\n AND (ua_users.uid = 0 OR ua_users.status = 1)\n AND (ua_target_users.uid = 0 OR ua_target_users.status = 1)\n ";
// Skip the first user if configured that way.
if (variable_get('heartbeat_skip_admin', 0) == 1) {
$this->stream->sql_start .= "AND ua.uid != 1 ";
}
// Calls with an offset uaid will fetch newer messages
if ($this->stream->latest_uaid > 0) {
$this->stream->sql_start .= "AND (ua.uaid > %d ) ";
}
else {
$this->stream->sql_start .= "AND (ua.timestamp < %d ";
// Add sql to delete too old messages if set
if ($this->stream->oldest_date) {
//$this->stream->sql_start .= "AND ua.timestamp > %d ";
}
$this->stream->sql_start .= ")";
}
$this
->checkDeniedMessages();
$this->stream->sql_end = " ORDER BY ua.timestamp DESC, ua.uaid DESC";
$heartbeat = $this
->createHeartbeatParser();
return $heartbeat;
}