You are here

class GroupsActivity in Heartbeat 6.4

Same name and namespace in other branches
  1. 7 modules/heartbeat_og/streams/groupsactivity.inc \GroupsActivity

Class GroupsActivity Concrete class to prepare messages for activity in groups

Hierarchy

Expanded class hierarchy of GroupsActivity

1 string reference to 'GroupsActivity'
og_activity_heartbeat_register_access_types in modules/og_activity/og_activity.module
Implementation of hook_heartbeat_register_access_types()

File

modules/og_activity/groupsactivity.inc, line 16

View source
class GroupsActivity extends HeartbeatAccess {

  /**
   * Skip active user.
   * We never want to skip the active user.
   */
  public function skipActiveUser() {
    return FALSE;
  }

  /**
   * Override of the prepareStream function
   *
   * @param $text
   * @return HeartbeatParser object
   */
  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
    $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.*,\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.in_group = 1\n      AND 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    ";

    // 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 timestamp DESC";
    $heartbeat = $this
      ->createHeartbeatParser();
    return $heartbeat;
  }
  public function dressUpMessages(HeartbeatParser $heartbeat) {
    $heartbeat->raw_messages = $this
      ->resultSql();
    return $heartbeat;
  }

  /**
   * Function to add a part of a sql to a query built by views UI
   *
   * @param object $view The view handler object by reference to add our part to the query
   */
  public function addViewQuery(&$view) {
    $view->query
      ->set_where_group('and', 'andgroup');
    $view->query
      ->add_where('andgroup', "{$view->table_alias}.in_group = %d ", 1);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupsActivity::addViewQuery public function Function to add a part of a sql to a query built by views UI Overrides HeartbeatAccess::addViewQuery
GroupsActivity::dressUpMessages public function Overrides HeartbeatAccess::dressUpMessages
GroupsActivity::prepareStream protected function Override of the prepareStream function Overrides HeartbeatAccess::prepareStream
GroupsActivity::skipActiveUser public function Skip active user. We never want to skip the active user. Overrides HeartbeatAccess::skipActiveUser
HeartbeatAccess::$stream public property
HeartbeatAccess::$_actor protected property
HeartbeatAccess::$_errors protected property
HeartbeatAccess::$_has_errors protected property
HeartbeatAccess::$_offset_sql protected property
HeartbeatAccess::$_page protected property
HeartbeatAccess::$_uid protected property
HeartbeatAccess::$_whoisuser_type protected property
HeartbeatAccess::$_whoisuser_types protected property
HeartbeatAccess::checkDeniedMessages protected function Check denied messages
HeartbeatAccess::configurationForm public function ConfigurationForm Basic configuration form for streams.
HeartbeatAccess::construct public function Fake constructor to hook this method instead of the constructor. 2
HeartbeatAccess::createHeartbeatParser protected function createHeartbeatParser
HeartbeatAccess::fetchMessages public function
HeartbeatAccess::finishMessages protected function finishMessages
HeartbeatAccess::getAccess final public function getAccess
HeartbeatAccess::getActiveUser public function Function to retrieve the active user.
HeartbeatAccess::getErrors public function
HeartbeatAccess::getOffsetSql final public function getOffsetSql
HeartbeatAccess::getStream public function Get HeartbeatStream object with all configurations
HeartbeatAccess::hasAccess protected function hasAccess 4
HeartbeatAccess::hasErrors public function hasErrors
HeartbeatAccess::isPage public function Getter function for heartbeat page/blocks
HeartbeatAccess::resultSql protected function resultSql 1
HeartbeatAccess::setError protected function setError
HeartbeatAccess::setOffsetSql final public function setOffsetSql
HeartbeatAccess::TYPE_ACTOR constant
HeartbeatAccess::TYPE_USER_PROFILE constant
HeartbeatAccess::whoIsActor protected function proctected fuinction whoIsActor Calculate the user of whom we want to see activity for. Set the actor of the stream. 1
HeartbeatAccess::__construct public function Constructor