diff --git a/domain.module b/domain.module index 1c40938..4526c83 100644 --- a/domain.module +++ b/domain.module @@ -1606,7 +1606,7 @@ function domain_get_node_domains($nodes, $reset = FALSE) { foreach ($result as $data) { if ($data->realm == 'domain_id') { // Transform the 0 to -1, since we use -1 in forms. - ($data->gid == 0) ? $gid = -1 : $gid = $data->gid; + ($data->gid == 0) ? $gid = -1 : $gid = $data->gid; $records[$data->nid]['domain_id'][$gid] = $gid; } elseif ($data->realm == 'domain_site') { @@ -3012,7 +3012,13 @@ function domain_alter_node_query(QueryAlterableInterface $query, $type) { // it to the table containing the nid which can be either the node // table or a field value table. if ($type == 'node') { - $access_alias = $query->join('node_access', 'na', '%alias.nid = ' . $nalias . '.nid'); + // We want to do a left join if we are left joining the base table. + if ($tableinfo['join type'] == 'LEFT') { + $access_alias = $query->leftJoin('node_access', 'na', '%alias.nid = ' . $nalias . '.nid'); + } + else { + $access_alias = $query->join('node_access', 'na', '%alias.nid = ' . $nalias . '.nid'); + } } else { $access_alias = $query->leftJoin('node_access', 'na', '%alias.nid = ' . $nalias . '.entity_id'); @@ -3032,7 +3038,17 @@ function domain_alter_node_query(QueryAlterableInterface $query, $type) { } $count = count($grant_conditions->conditions()); - if ($type == 'node') { + // If we are left joining node_access, then our conditions should allow + // for null values in the node_access table + if ($type == 'node' && $tableinfo['join type'] == 'LEFT') { + $grant_base_condition = db_or()->isNull($access_alias . '.gid'); + if ($count) { + $grant_base_condition->condition($grant_conditions); + } + $grant_base_condition->condition($access_alias . '.grant_' . $op, 1, '>='); + $query->condition($grant_base_condition); + } + elseif ($type == 'node') { if ($count) { $query->condition($grant_conditions); }