You are here

protected function HeartbeatStream::setAvailableTemplates in Heartbeat 7

setAvailableTemplates()

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

File

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

protected function setAvailableTemplates() {

  // Load the available templates for this stream.
  ctools_include('export');
  $templates = ctools_export_crud_load_all('heartbeat_messages');

  // Deny messages that have been denied through stream configuration.
  foreach ($this->config->messages_denied as $denied_message) {
    if (!empty($denied_message)) {
      $this->templates_denied[$denied_message] = $denied_message;
    }
  }

  // Prepare the allowed templates for this stream.
  foreach ($templates as $key => $template) {

    // Restrict templates to roles.
    if ($template
      ->hasRoleRestrictions()) {
      foreach ($template->roles as $rid) {
        if (!isset($this->viewer->roles[$rid])) {
          $this->templates_denied[$key] = $key;
          break;
        }
      }
      if (isset($this->templates_denied[$key])) {
        continue;
      }
    }
    $this->templates[$template->perms][$template->message_id] = $template;

    //$this->templates[$template->message_id] = $template;
  }
}