From 68925abe6a9bc251f04ac602a126d969f352c992 Mon Sep 17 00:00:00 2001
From: samuelsov <samuel@symbiotic.coop>
Date: Fri, 6 Nov 2015 11:56:09 -0500
Subject: [PATCH] CRM-17521 - look for civicrm.settings.php using aliases in
 sites/sites.php

---
 civicrm.config.php | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/civicrm.config.php b/civicrm.config.php
index 6d9d95c..2fdc15b 100644
--- a/civicrm.config.php
+++ b/civicrm.config.php
@@ -81,6 +81,13 @@ function civicrm_conf_init() {
         exit( );
     }
 
+    // since drupal 7, alias could be defined in sites/sites.php
+    if ( file_exists( $confdir . "/sites.php" ) ) {
+      include $confdir . "/sites.php";
+    } else {
+      $sites = array();
+    }
+
     $phpSelf  = array_key_exists( 'PHP_SELF' , $_SERVER ) ? $_SERVER['PHP_SELF' ] : '';
     $httpHost = array_key_exists( 'HTTP_HOST', $_SERVER ) ? $_SERVER['HTTP_HOST'] : '';
 
@@ -93,6 +100,11 @@ function civicrm_conf_init() {
                 $conf = "$confdir/$dir";
                 return $conf;
             }
+            // check for alias
+            if (isset($sites[$dir]) && file_exists("$confdir/{$sites[$dir]}/civicrm.settings.php")) {
+              $conf = "$confdir/{$sites[$dir]}";
+              return $conf;
+            }
         }
     }
 

