You are here

class MembersActivity in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 modules/og_activity/membersactivity.inc \MembersActivity

Concrete class MembersActivity Defines a stream displaying all activity from members in a group.

Hierarchy

Expanded class hierarchy of MembersActivity

File

modules/heartbeat_og/streams/membersactivity.inc, line 12
Defines a stream for Member Activity.

View source
class MembersActivity extends HeartbeatStream {
  protected $nid = 0;
  protected $og_context = NULL;
  protected $group = NULL;
  public function construct() {
    $this
      ->detectGroup();
  }

  /**
   * detectGroup
   *
   * Detects the group for a given node ID.
   */
  private function detectGroup() {

    // First check the contextual arguments that could have been sent along
    // with ajax posts to get the context of the current node.
    if (!empty($_GET['contextualArguments']) && isset($_GET['contextualArguments']['og_etid'])) {
      $this
        ->setGroup($_GET['contextualArguments']['og_etid']);
    }
    elseif ($og_context = og_context()) {
      $this->og_context = $og_context;
      if (isset($og_context->etid)) {
        $this
          ->setGroup($og_context->etid);
      }
    }
  }

  /**
   * modifyActivityMessage().
   */
  public function modifyActivityMessage(HeartbeatActivity $heartbeatActivity) {

    // Add the content node context.
    $heartbeatActivity->nid = $this->nid;
    $heartbeatActivity->in_group = 1;
  }

  /**
   * setGroup
   *
   * Sets the group for a given node ID.
   * @param Integer $nid
   *   The group node ID.
   */
  private function setGroup($nid) {
    $this->nid = $nid;
    $this->group = node_load($this->nid);
  }

  /**
   * hasAccess
   *
   * @param $text
   * @return boolean to indicate the access to the stream
   */
  public function hasAccess() {
    return $this->nid > 0 ? TRUE : FALSE;
  }

  /**
   * Implementation of queryAlter().
   */
  protected function queryAlter() {
    if (empty($this->og_context->gid)) {
      $this->nid = 0;
      return;
    }
    $members = array();
    $result = db_query("SELECT u.uid FROM {users} u LEFT JOIN {og_membership} om ON u.uid = om.etid AND om.entity_type = 'user' " . "WHERE om.gid = :gid AND u.status <> '0' AND om.state = '1' ", array(
      ':gid' => $this->og_context->gid,
    ));
    foreach ($result as $row) {
      $members[$row->uid] = $row->uid;
    }

    //$this->query->condition('ha.in_group', 0, '<>');
    if (!empty($members)) {
      $this->query
        ->condition('ha.uid', $members, 'IN');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HeartbeatStream::$ajax protected property
HeartbeatStream::$canPage protected property
HeartbeatStream::$config public property
HeartbeatStream::$contextual_arguments public property
HeartbeatStream::$exclude_og protected property
HeartbeatStream::$language protected property
HeartbeatStream::$latest_activity_id protected property
HeartbeatStream::$messages public property
HeartbeatStream::$messages_max protected property
HeartbeatStream::$needsModal protected property
HeartbeatStream::$oldest_date protected property
HeartbeatStream::$prefix public property
HeartbeatStream::$query protected property
HeartbeatStream::$suffix public property
HeartbeatStream::$templates public property
HeartbeatStream::$templates_denied protected property
HeartbeatStream::$viewed protected property
HeartbeatStream::$viewer protected property
HeartbeatStream::$view_mode protected property
HeartbeatStream::$_errors protected property
HeartbeatStream::$_has_errors protected property
HeartbeatStream::$_offset_time protected property
HeartbeatStream::$_page protected property
HeartbeatStream::$_uid protected property
HeartbeatStream::$_whoisuser_type protected property
HeartbeatStream::$_whoisuser_types protected property
HeartbeatStream::addError public function addError
HeartbeatStream::canPostActivityStatuses public function canPostActivityStatuses(). TODO Remove this here. The stream plugins should be stored in the stream object. This kind of access will become much easier to implement.
HeartbeatStream::checkAccess protected function Function to check access on messages This behaviour is set by a heartbeat message configuration to overrule the chosen display access type
HeartbeatStream::createQuery protected function createQuery(). 1
HeartbeatStream::excludeOg public function excludeOg().
HeartbeatStream::execute public function Function that reorganizes a query result of messages into a stream of heartbeat activity objects.
HeartbeatStream::executeQuery protected function executeQuery
HeartbeatStream::executeViews public function executeViews().
HeartbeatStream::getAjax public function getAjax().
HeartbeatStream::getConfig public function getConfig().
HeartbeatStream::getCurrentLanguages public function getCurrentLanguages().
HeartbeatStream::getErrors public function
HeartbeatStream::getLatestActivityId public function getLatestActivityId()
HeartbeatStream::getMessages public function Get the messages.
HeartbeatStream::getOffsetTime final public function getOffsetTime
HeartbeatStream::getTemplate final public function getTemplate().
HeartbeatStream::getViewed public function getViewed().
HeartbeatStream::getViewedId public function getViewedId().
HeartbeatStream::getViewer public function getViewer().
HeartbeatStream::hasErrors public function hasErrors
HeartbeatStream::hasMoreMessages public function Function to check if more/older messages can be loaded
HeartbeatStream::isAjax public function isAjax().
HeartbeatStream::isPage public function isPage().
HeartbeatStream::needsModal public function needsModal(). Returns a boolean to indicate whether modal window is needed on the page.
HeartbeatStream::numberOfMessages public function numberOfMessages().
HeartbeatStream::parseMessages public function Create the well-formed activity messages from a result. HeartbeatParser will do most of the work here.
HeartbeatStream::render public function Render().
HeartbeatStream::result public function result Prepares a query, makes it available to alter it and finally executes it.
HeartbeatStream::setAjax public function setAjax().
HeartbeatStream::setAvailableTemplates protected function setAvailableTemplates()
HeartbeatStream::setConfig public function setConfig().
HeartbeatStream::setContextualArguments protected function setContextualArguments().
HeartbeatStream::setError protected function setError Alias for addError.
HeartbeatStream::setIsPage public function setIsPage().
HeartbeatStream::setItemsMax public function Set the maximum number of items to fetch.
HeartbeatStream::setLanguage public function setLanguage().
HeartbeatStream::setLatestActivityId public function setLatestActivityId().
HeartbeatStream::setOffsetTime final public function setOffsetTime
HeartbeatStream::setViewed public function setViewed().
HeartbeatStream::setViewer public function setViewer().
HeartbeatStream::setViewMode public function setViewMode().
HeartbeatStream::skipActiveUser public function skipActiveUser().
HeartbeatStream::VIEWED constant
HeartbeatStream::VIEWER constant
HeartbeatStream::viewsQueryAlter public function viewsQueryAlter 5
HeartbeatStream::__construct final public function Constructor
MembersActivity::$group protected property
MembersActivity::$nid protected property
MembersActivity::$og_context protected property
MembersActivity::construct public function Fake constructor to hook this method instead of the constructor. Overrides HeartbeatStream::construct
MembersActivity::detectGroup private function detectGroup
MembersActivity::hasAccess public function hasAccess Overrides HeartbeatStream::hasAccess
MembersActivity::modifyActivityMessage public function modifyActivityMessage(). Overrides HeartbeatStream::modifyActivityMessage
MembersActivity::queryAlter protected function Implementation of queryAlter(). Overrides HeartbeatStream::queryAlter
MembersActivity::setGroup private function setGroup