You are here

function domain_set_default_grant in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain.module \domain_set_default_grant()
  2. 6.2 domain.module \domain_set_default_grant()
  3. 7.2 domain.module \domain_set_default_grant()

Ensure that the 'domain_all' grant is present.

Parameters

$reset: A boolean flag indicating whether to reset the static variable or not.

3 calls to domain_set_default_grant()
DomainInstallTest::testDomainGrantAll in tests/domain.test
domain_enable in ./domain.module
Upon enabling this module, store the default view grant in the {node_access} table. Then it assigns all users to the primary domain.
_domain_store_grants in ./domain.module
Store node_access records in the {domain_access} table.

File

./domain.module, line 2242
Core module functions for the Domain Access suite.

Code

function domain_set_default_grant($reset = FALSE) {
  $check =& drupal_static(__FUNCTION__, NULL);
  if (is_null($check) || $reset) {
    $check = (bool) db_query_range("SELECT 1 FROM {node_access} WHERE realm = :realm AND gid = :gid", 0, 1, array(
      ':realm' => 'domain_all',
      ':gid' => 0,
    ))
      ->fetchField();
    if (empty($check)) {
      db_insert('node_access')
        ->fields(array(
        'nid' => 0,
        'gid' => 0,
        'realm' => 'domain_all',
        'grant_view' => 1,
        'grant_update' => 0,
        'grant_delete' => 0,
      ))
        ->execute();
    }
  }
}