function views_handler_filter_heartbeat_access::query in Heartbeat 6.3
Same name and namespace in other branches
- 6.4 views/handlers/views_handler_filter_heartbeat_access.inc \views_handler_filter_heartbeat_access::query()
Adding things to query object
File
- views/
handlers/ views_handler_filter_heartbeat_access.inc, line 104
Class
- views_handler_filter_heartbeat_access
- Filter by language
Code
function query() {
global $user;
if ($this->value['whoisuser'] == 1) {
if (arg(0) == 'heartbeat' && arg(1) == 'user' && is_numeric(arg(2))) {
$uid = arg(2);
}
elseif (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) != 'edit') {
$uid = arg(1);
}
else {
$uid = $user->uid;
}
}
else {
$uid = $user->uid;
}
$this
->ensure_my_table();
$info = $this
->operators();
//dsm($this->query);
$access = $this->value['access'];
// Make the sql limited to the access
$field = "{$this->table_alias}.{$this->real_field}";
$this->heartbeat_access = $access;
switch ($access) {
case HEARTBEAT_PUBLIC_TO_CONNECTED:
$uids = heartbeat_get_related_uids($uid);
$this->heartbeat_relations = $uids;
$this->query
->set_where_group('OR', 'orgroup');
$sql = "{$field} in( " . implode(',', $uids) . " ) AND {$this->table_alias}.access >= 0 ";
$this->query
->add_where('orgroup', $sql);
$sql = "{$this->table_alias}.uid_target = %d AND {$this->table_alias}.nid_target <> 0";
$this->query
->add_where('orgroup', $sql, $uid);
break;
case HEARTBEAT_PRIVATE:
$this->query
->set_where_group('OR', 'orgroup');
$uids = heartbeat_get_related_uids($uid);
$this->heartbeat_relations = $uids;
$sql = "{$field} = %d AND {$this->table_alias}.access = %d ";
$this->query
->add_where('orgroup', $sql, $uid, $access);
$sql = "({$this->table_alias}.uid_target = %d AND {$this->table_alias}.access > 0)";
$this->query
->add_where('orgroup', $sql, $uid);
break;
case HEARTBEAT_PUBLIC_TO_ALL:
$sql = "{$field} > %d AND {$this->table_alias}.access > 0";
$this->query
->add_where('andgroup', $sql, 0);
break;
default:
$sql = "{$field} = %d";
$this->query
->add_where('andgroup', $sql, $uid);
}
}