ogheartbeat.inc in Heartbeat 6.4
File
modules/og_activity/ogheartbeat.inc
View source
<?php
heartbeat_include('HeartbeatAccess');
class OgHeartbeat extends HeartbeatAccess {
protected $_gid = 0;
protected $_group_access = FALSE;
protected $group = NULL;
public function construct() {
$this
->setGroup();
}
public function skipActiveUser() {
return FALSE;
}
protected function hasAccess() {
if (isset($this->group) && (og_is_group_member($this->group) || $this->group->og_private == 0)) {
$this->_group_access = TRUE;
}
if (!isset($this->group)) {
$this
->setError('We are not in a group context.');
}
return $this->_group_access;
}
public function getGroup() {
return $this->group;
}
private function setGroup($nid = 0) {
if ($nid != 0) {
$this->_gid = $nid;
$this->group = node_load($nid);
return;
}
elseif (!empty($_REQUEST['group_nid'])) {
$this->_gid = $_REQUEST['group_nid'];
$this->group = node_load($this->_gid);
}
if (module_exists('spaces_og')) {
if ($space = spaces_get_space()) {
if ($space->type == 'og') {
$this->_gid = $space->id;
$this->group = $space->group;
return;
}
}
}
if ($group = og_get_group_context()) {
$this->_gid = $group->nid;
$this->group = $group;
return;
}
if (arg(0) == 'node' && is_numeric(arg(1))) {
if ($node = node_load(arg(1))) {
if (og_is_group_type($node->type)) {
$this->_gid = $node->nid;
$this->group = $node;
return;
}
elseif (og_is_group_post_type($node->type)) {
$this->_gid = current($node->og_groups);
$this->group = node_load($this->_gid);
return;
}
}
}
}
public function dressUpMessages(HeartbeatParser $heartbeat) {
$sql = " AND ua.nid <> 0 AND (ua.nid = %d OR ua.nid_target = %d) ";
$heartbeat->raw_messages = $this
->resultSql($sql, array(
$this->_gid,
$this->_gid,
));
return $heartbeat;
}
public function addViewQuery(&$view) {
$field = "{$view->table_alias}.{$view->real_field}";
$view->query
->set_where_group('AND', 'extra');
$sql = "{$view->table_alias}.nid <> 0 AND ( {$view->table_alias}.nid = %d OR {$view->table_alias}.nid_target = %d ) ";
$view->query
->add_where('extra', $sql, $this->_gid, $this->_gid);
}
}
Classes
Name |
Description |
OgHeartbeat |
Class OgHeartbeat
Concrete class to prepare messages for the current user
and all of his/her relations. |