diff --git a/spaces_og/plugins/space_og.inc b/spaces_og/plugins/space_og.inc index 2ea251b..949b4e2 100644 --- a/spaces_og/plugins/space_og.inc +++ b/spaces_og/plugins/space_og.inc @@ -31,9 +31,7 @@ class space_og extends space_type_purl { */ function activate() { if (parent::activate()) { - // TODO determine what replaces this in D7. - // og_set_group_context($this->group); - // og_set_language($this->group); + og_context($this->group_type, $this->group); // Handle theme switching for OG if (!empty($this->group->og_theme)) { @@ -196,6 +194,22 @@ class space_og extends space_type_purl { // Spaces OG views filter function views_filter(&$query, $base_table = '', $relationship = '') { switch ($base_table) { + case 'node': + case 'users': + case 'taxonomy_term_data': + if ($this->group_type == 'node') { + $join = new views_join(); + $join->construct('field_data_' . OG_AUDIENCE_FIELD, $base_table, 'nid', OG_AUDIENCE_FIELD . '_target_id'); + + $table = $query->ensure_table('field_data_' . OG_AUDIENCE_FIELD, $base_table, $join); + if ($table) { + $where_group = key($query->where); + $query->add_where($where_group, $table . ".$join->field", $this->group->nid, '='); + $query->add_where($where_group, $table . '.entity_type', $base_table, '='); + } + } + break; + case 'og_membership': if (!isset($query->space_og_proccessed)) { // Add our view arguments to the first where group.