You are here

public function HeartbeatStream::setViewed in Heartbeat 7

setViewed().

1 call to HeartbeatStream::setViewed()
HeartbeatStream::__construct in includes/heartbeatstream.inc
Constructor

File

includes/heartbeatstream.inc, line 273
HeartbeatStream 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

HeartbeatStream
Abstract class HeartbeatStream This base class has final template methods which are used by the derived concretes. The HeartbeatStream is a state object that is given to the HeartbeatStreamBuilder to set the access to the current request.

Code

public function setViewed($account) {

  // If an account is given, then the stream is build for that user.
  if (isset($account)) {
    $this->_whoisuser_type = self::VIEWED;
    $this->viewed = $account;
  }
  else {

    // If the logged-in user is watching the stream on a profile page,
    // the viewed user needs to be changed.
    // This could be through ajax or normal.
    $args = arg();
    if (!empty($_GET['viewed_uid']) && is_numeric($_GET['viewed_uid']) && ($account = user_load($_GET['viewed_uid']))) {
      $this->_whoisuser_type = self::VIEWED;
      $this->viewed = $account;
    }
    elseif ($args[0] == 'user' && is_numeric($args[1])) {

      // TODO Change this to access denied if not available.
      if (!empty($args[2])) {

        //if (!empty($args[2]) && $args[2] == $this->config->settings['stream_profile_path']) {
        $this->_whoisuser_type = self::VIEWED;
        $this->viewed = user_load($args[1]);
      }
      else {
        $this->_whoisuser_type = self::VIEWER;
        $this->viewed = $this->viewer;
      }
    }
    else {
      $this->_whoisuser_type = self::VIEWER;
      $this->viewed = $this->viewer;
    }
  }
  drupal_add_js(array(
    'viewed_uid' => $this->viewed->uid,
  ), "setting");
  $this->_uid = $this->viewed->uid;
}