domain_grant_all

Definition

domain_grant_all($reset= FALSE)
domain.module, line 1190

Description

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.

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)) {
      $script = array_pop(explode('/', request_uri()));
      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;
}