diff --git a/README-UNL.txt b/README-UNL.txt index ef1f291147e41d9f08c60cb5bb756568d30d71ac..bd52223901ad9a87f01fa66147856cb5d5cc67f9 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 d65108627d8fc7964caedf60a39bed5ab2ba1841..33ce1d40e005fb21486cd31cc2eb087b485f7c97 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 08c1020ff4398b19279672e90301ee2bf1aa2129..06f392e874c330970dd150ab4f78695f62f7dd8d 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