CRM-17323 - Store site id in settings
authorColeman Watts <coleman@civicrm.org>
Sat, 3 Oct 2015 17:53:22 +0000 (13:53 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 3 Oct 2015 17:53:22 +0000 (13:53 -0400)
CRM/Utils/System.php
settings/Core.setting.php

index 726d0aeaee28c6a9a82414e8bc02806d818cfede..e78b144882fb2bdc785101965a297c19c0294bed 100644 (file)
@@ -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;
   }
 
   /**
index d6b85edf8a23ba6e89e61a9205659c2911b1fe86..1484bc778a512fb9426643d9102a787c5656b64c 100644 (file)
@@ -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,
+  ),
 );