}
/**
+ * 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;
}
/**
'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,
+ ),
);