You are here

function domain_grant_all in Domain Access 5

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

Activate the hidden grant for searches.

Parameters

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

Return value

TRUE or FALSE, depending on whether the grants should be executed for this page.

4 calls to domain_grant_all()
domain_db_rewrite_sql in ./domain.module
Implement hook_db_rewrite_sql().
domain_node_access_explain in ./domain.module
Implement hook_node_access_explain for devel.module
domain_node_grants in ./domain.module
Implement hook_node_grants.
domain_url_rewrite_outbound in ./settings_custom_url.inc
Forces absolute paths for domains when needed.
1 string reference to 'domain_grant_all'
domain_configure_form in ./domain_admin.inc
FormsAPI for configuring the domain module.

File

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

Code

function domain_grant_all($reset = FALSE) {
  static $grant;
  if (!isset($grant) || $reset) {
    $grant = FALSE;

    // Search is the easy case, so we check it first.
    if (variable_get('domain_search', 0) && arg(0) == 'search') {
      $grant = TRUE;
    }

    // On cron runs, we normally have to disable Domain Access.  See http://drupal.org/node/197488.
    if (!$grant && variable_get('domain_cron_rule', 1)) {
      $ref = explode('/', request_uri());
      $script = array_pop($ref);
      if ($script == 'cron.php') {
        $grant = TRUE;
      }
    }
    if (!$grant) {

      // We check the paths registered by the special pages setting.
      $pages = variable_get('domain_grant_all', "user/*/track");
      $regexp = '/^(' . preg_replace(array(
        '/(\\r\\n?|\\n)/',
        '/\\\\\\*/',
        '/(^|\\|)\\\\<front\\\\>($|\\|)/',
      ), array(
        '|',
        '.*',
        '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
      ), preg_quote($pages, '/')) . ')$/';

      // Compare with the internal and path alias (if any).
      $page_match = preg_match($regexp, $_GET['q']);
      if (!$page_match) {
        $path = drupal_get_path_alias($_GET['q']);
        if ($path != $_GET['q']) {
          $page_match = preg_match($regexp, $path);
        }
      }
      if ($page_match) {
        $grant = TRUE;
      }
    }
  }
  return $grant;
}