From 1ab26c95660906966bcb2b90867ae2bd0b4ab2df Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 3 Oct 2015 13:53:22 -0400 Subject: [PATCH] CRM-17323 - Store site id in settings --- CRM/Utils/System.php | 13 +++++++++++-- settings/Core.setting.php | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 726d0aeaee..e78b144882 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -1797,11 +1797,20 @@ class CRM_Utils_System { } /** + * Returns the unique identifier for this site, as used by community messages. + * + * SiteID will be generated if it is not already stored in the settings table. + * * @return string */ public static function getSiteID() { - $config = CRM_Core_Config::singleton(); - return md5('sid_' . (defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : '') . '_' . $config->userFrameworkBaseURL); + $sid = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'site_id'); + if (!$sid) { + $config = CRM_Core_Config::singleton(); + $sid = md5('sid_' . (defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : '') . '_' . $config->userFrameworkBaseURL); + civicrm_api3('Setting', 'create', array('domain_id' => 'all', 'site_id' => $sid)); + } + return $sid; } /** diff --git a/settings/Core.setting.php b/settings/Core.setting.php index d6b85edf8a..1484bc778a 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -765,4 +765,17 @@ return array( 'description' => 'CiviCRM will use this setting as path to bootstrap WP.', 'help_text' => NULL, ), + 'site_id' => array( + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'site_id', + 'type' => 'String', + 'default' => '', + 'add' => '4.6', + 'title' => 'Unique Site ID', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => NULL, + 'help_text' => NULL, + ), ); -- 2.25.1