You are here

public function heartbeatParser::build_sets in Heartbeat 6.4

Same name and namespace in other branches
  1. 6.3 includes/heartbeatparser.inc \heartbeatParser::build_sets()
  2. 7 includes/heartbeatparser.inc \heartbeatParser::build_sets()

build sets of messages

File

includes/heartbeatparser.inc, line 353
HeartbeatParser object

Class

heartbeatParser
Class heartbeatParser

Code

public function build_sets($messages_raw) {

  // The start is the end of the current day.
  $renewal_time = $_SERVER['REQUEST_TIME'] - (3600 * date("H") + 60 * date("i") + date("s")) + 24 * 3600;

  // Retrieve variables to put on the object.
  $show_time = variable_get('heartbeat_show_message_times', 1);
  $time_info_grouped = variable_get('heartbeat_show_time_grouped_items', 1);

  // Check access on the buttons and put their state onto the object
  $delete_access = _heartbeat_activity_stream_delete_access();
  $actor_access = variable_get('heartbeat_activity_stream_actor_delete', 1) && user_access('delete own heartbeat activity logs');
  $raw_messages = array();
  foreach ($messages_raw as $key => $message) {

    // Set basic properties for all messages.
    $message->display_time = isset($message->template->variables['heartbeat_show_message_times']) ? $message->template->variables['heartbeat_show_message_times'] : $show_time;
    $message->time_info_grouped = $time_info_grouped;
    $message->delete_access = $delete_access;
    $message->actor_access = $actor_access;

    // if the time with the gap exceeds the starttime.
    if ($renewal_time >= $message->timestamp) {

      // reset the start time of the set
      $renewal_time = $message->timestamp - $this->_timespan_gap;
    }
    $this->_sets[$renewal_time][$key] = $message;
  }
}