From d5085e1294781344a4a38409e13c40ba8b050fc6 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Thu, 22 Sep 2011 16:18:41 +0000 Subject: [PATCH] [gh-229] Merging from testing into staging git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1071 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- README-UNL.txt | 16 +++++++++++++++- includes/bootstrap.inc | 18 ++++++++++++++++++ sites/example.sites.php | 10 ++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/README-UNL.txt b/README-UNL.txt index ef1f2911..bd522239 100644 --- a/README-UNL.txt +++ b/README-UNL.txt @@ -3,6 +3,10 @@ Hacks of Core: includes/bootstrap.inc function drupal_settings_initialize() * UNL change: include a "global" settings file that applies to all sites. + +function conf_path() + * UNL change: Add $default_domains array support for sites.php to list which domains are ok to use with 'unl.edu.*' site_dirs. + If no $default_domains array is defined in sites.php, this code will do nothing. ------------------------------------ @@ -20,4 +24,14 @@ used to allow public files to be accessed without the sites/<site_dir>/files pre modules/image/image.field.inc * theme_image_formatter ignores attributes so classes can't be added to an image in a theme (needed for photo frame) * http://drupal.org/node/1025796#comment-4298698 - * http://drupal.org/files/issues/1025796.patch \ No newline at end of file + * http://drupal.org/files/issues/1025796.patch + +------------------------------------ + +sites/sites.php + * Added support for $default_domains array. See includes/bootstrap.inc conf_path(). + +------------------------------------ + +sites/example.sites.php + * Added an example of the $default_domains array. diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index d6510862..33ce1d40 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -363,6 +363,9 @@ function conf_path($require_settings = TRUE, $reset = FALSE) { $confdir = 'sites'; $sites = array(); + // UNL Change + $default_domains = array(); + // End UNL Change if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) { // This will overwrite $sites with the desired mappings. include(DRUPAL_ROOT . '/' . $confdir . '/sites.php'); @@ -373,6 +376,21 @@ function conf_path($require_settings = TRUE, $reset = FALSE) { for ($i = count($uri) - 1; $i > 0; $i--) { for ($j = count($server); $j > 0; $j--) { $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i)); + // UNL Change + // Since we're truncating site_dir domains to just unl.edu, we need to skip any site_dir that + // Starts with "unl.edu" unless we're on the default site's domain (ie: unlcms.unl.edu) + if (substr($dir, 0, 7) == 'unl.edu' && count($default_domains) > 0) { + $is_primary_domain = FALSE; + foreach ($default_domains as $default_domain) { + if (substr($_SERVER['HTTP_HOST'], 0, strlen($default_domain)) == $default_domain) { + $is_primary_domain = TRUE; + } + } + if (!$is_primary_domain) { + continue; + } + } + // End UNL Change if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) { $dir = $sites[$dir]; } diff --git a/sites/example.sites.php b/sites/example.sites.php index 08c1020f..06f392e8 100644 --- a/sites/example.sites.php +++ b/sites/example.sites.php @@ -41,3 +41,13 @@ */ # $sites['devexample.com'] = 'example.com'; # $sites['localhost.example'] = 'example.com'; + + +/** + * Default domains + * + * Used to specify which domains are allowed to use "universal" site dirs + * (starting with unl.edu). The purpose is to prevent sites like + * unlcms.unl.edu/ncard from showing up at bike.unl.edu/ncard. + */ +# $default_domains = array('example.unl.edu', 'example-test.unl.edu'); \ No newline at end of file -- GitLab