Skip to content

Instantly share code, notes, and snippets.

@herbdool
Last active August 29, 2015 14:16
Show Gist options
  • Save herbdool/1658b00a9291f24fa7df to your computer and use it in GitHub Desktop.
Save herbdool/1658b00a9291f24fa7df to your computer and use it in GitHub Desktop.
pantheon-settings-civicrm-4-5.patch
--- /templates/CRM/common/civicrm.settings.php.template
+++ /templates/CRM/common/civicrm.settings.php.template
@@ -54,6 +54,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/private/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:
*
@@ -61,6 +115,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.
+
if (!defined('CIVICRM_UF_DSN')) {
define( 'CIVICRM_UF_DSN' , 'mysql://%%CMSdbUser%%:%%CMSdbPass%%@%%CMSdbHost%%/%%CMSdbName%%?new_link=true' );
}
@@ -84,6 +142,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.
+
if (!defined('CIVICRM_DSN')) {
define( 'CIVICRM_DSN' , 'mysql://%%dbUser%%:%%dbPass%%@%%dbHost%%/%%dbName%%?new_link=true' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment