You are here

public function HeartbeatActivity::set_data in Heartbeat 6.3

Set data into members

1 call to HeartbeatActivity::set_data()
HeartbeatActivity::__construct in includes/heartbeatactivity.inc
constructor

File

includes/heartbeatactivity.inc, line 46

Class

HeartbeatActivity
Class to handle user activity data

Code

public function set_data($data) {
  if (is_object($data)) {
    $data = (array) $data;
  }
  foreach ($data as $key => $value) {
    if (isset($this->{$key})) {
      $this->{$key} = $value;
    }
    if (isset($this->{'m_' . $key})) {
      $this->{'m_' . $key} = $value;
    }
  }

  // Data variables are more complicated
  if (isset($data['variables']) && is_string($data['variables'])) {
    $this->m_variables_string = $data['variables'];
  }

  // if the data variables have not been included
  // as normal members, do so now to be available when asked for
  // @see __get
  if ($this->m_variables_array == array() && $this->m_variables_string != '') {
    $this->m_variables_array = heartbeat_decode_message_variables($this->m_variables_string);
  }
  $this->m_concat_args = heartbeat_decode_message_variables($data['concat_args']);
}