diff --git a/client/hosting_client.access.inc b/client/hosting_client.access.inc index 3249cf1..60773f8 100644 --- a/client/hosting_client.access.inc +++ b/client/hosting_client.access.inc @@ -219,6 +219,9 @@ function hosting_client_node_grants($account, $op) { elseif ($op == 'update' && user_access('edit ' . $type, $account)) { $grants[$cache_id]['hosting ' . $type] = array_keys($account->client_id); } + elseif ($op == 'view' && !user_access('view ' . $type, $account)) { + $grants[$cache_id]['hosting ' . $type] = array_keys($account->client_id); + } } } return isset($grants[$cache_id]) ? $grants[$cache_id] : array(); @@ -282,9 +285,18 @@ function hosting_client_node_access_records($node) { } } } + else { + // When $node->clients isn't set on a platform, all clients have access. + $results = db_query("select nid from {hosting_client} c"); + foreach ($results as $row) { + if ($row->nid != HOSTING_ADMIN_CLIENT) { + $gids[] = $row->nid; + } + } + } } - // Lookup databaaes hosted on this server. + // Lookup databases hosted on this server. $databases = hosting_get_sites_on_db_server($node->nid); foreach ($databases as $nid => $dbname) { $node = node_load($nid); @@ -311,6 +323,15 @@ function hosting_client_node_access_records($node) { } } } + else { + // When $node->clients isn't set, all clients have access. + $results = db_query("select nid from {hosting_client} c"); + foreach ($results as $row) { + if ($row->nid != HOSTING_ADMIN_CLIENT) { + $grants[] = array_merge($base_grant, array('gid' => $row->nid, 'grant_update' => 0)); + } + } + } break; default: diff --git a/client/hosting_client.install b/client/hosting_client.install index 3dac200..7e91bae 100644 --- a/client/hosting_client.install +++ b/client/hosting_client.install @@ -354,3 +354,21 @@ function hosting_client_update_6004() { $ret[] = update_sql("UPDATE {hosting_site} SET client = %d WHERE client = 0", HOSTING_DEFAULT_CLIENT); return $ret; } + +/** + * Implements hook_update_N(). + * + * Re-build node access. + */ +function hosting_client_update_7001(&$sandbox) { + // node_access_rebuild from the the update hook fails without the following defintion. + if (!defined('HOSTING_ADMIN_CLIENT')) { + define('HOSTING_ADMIN_CLIENT', variable_get('hosting_admin_client', 1)); + } + // @see https://gist.github.com/johnennewdeeson/6d4a6d667538e6149f56 + _node_access_rebuild_batch_operation($sandbox); + $sandbox['#finished'] = $sandbox['sandbox']['progress'] >= $sandbox['sandbox']['max']; + if ($sandbox['#finished']) { + node_access_needs_rebuild(FALSE); + } +}