--- /templates/CRM/common/civicrm.settings.php.template +++ /templates/CRM/common/civicrm.settings.php.template @@ -52,6 +52,60 @@ */ define( 'CIVICRM_UF' , '%%cms%%' ); + /** + * Pantheon Systems: + * + * Repopulate needed variables based on the Pantheon environment if applicable. + * http://www.kalamuna.com/news/civicrm-pantheon + * + */ +if (!empty($_SERVER['PRESSFLOW_SETTINGS'])) { + $env = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE); + if (!empty($env['conf']['pantheon_binding'])) { + $pantheon_db = $env['databases']['default']['default']; + $pantheon_conf = $env['conf']; + + //user name and password + $db_string = $pantheon_db['driver'] . '://' . $pantheon_db['username'] . ':' . $pantheon_db['password'] . '@'; + //host + $db_string .= 'dbserver.' . $pantheon_conf['pantheon_environment'] . '.' . $pantheon_conf['pantheon_site_uuid'] . '.drush.in' . ':' . $pantheon_db['port']; + // database + $db_string .= '/' . $pantheon_db['database'] . '?new_link=true'; + + // define the database strings + define('CIVICRM_UF_DSN', $db_string); + define('CIVICRM_DSN', $db_string); + + // define the file paths + global $civicrm_root; + + $civicrm_root = '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/code/%%modulePath%%'; + define('CIVICRM_TEMPLATE_COMPILEDIR', '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/files/private/civicrm/templates_c/'); + + // Use Drupal base url and path + global $base_url, $base_path; + define( 'CIVICRM_UF_BASEURL', $base_url . '/'); + define( 'CIVICRM_SITE_KEY', '%%siteKey%%' ); + + if ( $pantheon_conf['pantheon_environment'] == 'dev' || $pantheon_conf['pantheon_environment'] == 'test' ){ + /** + * This setting logs all emails to a file. Useful for debugging any mail (or civimail) issues. + * This will not send any email, so ensure this is commented out in production + */ + define( 'CIVICRM_MAIL_LOG', '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/code/sites/default/files/civicrm/templates_c/mail.log' ); + } + + // Add this line only once above any settings overrides + global $civicrm_setting; + $civicrm_setting['Directory Preferences']['uploadDir'] = '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/files/private/civicrm/upload/'; + $civicrm_setting['Directory Preferences']['customFileUploadDir'] = '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/files/private/civicrm/custom/'; + $civicrm_setting['Directory Preferences']['imageUploadDir'] = '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/files/private/civicrm/persist/contribute/'; + $civicrm_setting['Directory Preferences']['extensionsDir'] = '/srv/bindings/' . $pantheon_conf['pantheon_binding'] . '/code/sites/all/extensions/'; + $civicrm_setting['URL Preferences']['extensionsURL'] = $base_url . '/sites/all/extensions'; + + } +} else { + /** * Content Management System (CMS) Datasource: * @@ -59,6 +113,10 @@ * Datasource (DSN) format: * define( 'CIVICRM_UF_DSN', 'mysql://cms_db_username:cms_db_password@db_server/cms_database?new_link=true'); */ + +// PANTHEON USERS - These settings are overridden above when running on Pantheon. +// These settings are ONLY included here to remain compatible with other hosts. + define( 'CIVICRM_UF_DSN' , 'mysql://%%CMSdbUser%%:%%CMSdbPass%%@%%CMSdbHost%%/%%CMSdbName%%?new_link=true' ); /** @@ -80,6 +138,10 @@ * define( 'CIVICRM_DSN' , 'mysql://civicrm:YOUR_PASSWORD@localhost/civicrm?new_link=true' ); * */ + +// PANTHEON USERS - These settings are overridden above when running on Pantheon. +// These settings are ONLY included here to remain compatible with other hosts. + define( 'CIVICRM_DSN' , 'mysql://%%dbUser%%:%%dbPass%%@%%dbHost%%/%%dbName%%?new_link=true' ); /** @@ -238,6 +300,8 @@ * 'server2_' for the second server. */ define( 'CIVICRM_MEMCACHE_PREFIX', '' ); + +} // end Pantheon check /** * If you have multilingual site and you are using the "inherit CMS language"