From: Tim Otten Date: Sat, 21 May 2016 00:40:56 +0000 (-0700) Subject: CRM-16642 - Simplify list of smart-group options X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a8eb1fe683527cb806a6544e99fc3aa514a97d89;p=civicrm-core.git CRM-16642 - Simplify list of smart-group options Using an option-group takes a lot of work. Also, it wasn't handling consistently labels+descriptions (upgrade-vs-new install), and it isn't really supported in the metadata for Setting API. And fundamentally this list is not really editable by users. --- diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index af97a8b58f..cdb781dcbf 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -34,6 +34,21 @@ class CRM_Contact_BAO_GroupContactCache extends CRM_Contact_DAO_GroupContactCach static $_alreadyLoaded = array(); + /** + * Get a list of caching modes. + * + * @return array + */ + public static function getModes() { + return array( + // Flush expired caches in response to user actions. + 'opportunistic' => ts('Opportunistic Flush'), + + // Flush expired caches via background cron jobs. + 'deterministic' => ts('Cron Flush'), + ); + } + /** * Check to see if we have cache entries for this group. * diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 0da96b8ed3..6a33eceda4 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -208,7 +208,6 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base public function upgrade_4_7_8($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); $this->addTask('Upgrade mailing foreign key constraints', 'upgradeMailingFKs'); - $this->addTask('Add Smartgroup refresh options', 'addSmartGroupRefreshOptions'); } /* @@ -691,39 +690,4 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return TRUE; } - /** - * CRM-16642 Add option for smart group refreshing. - * - * @param \CRM_Queue_TaskContext $ctx - * - * @return bool - */ - public function addSmartGroupRefreshOptions(CRM_Queue_TaskContext $ctx) { - $optionGroupID = CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(array( - 'name' => 'smart_group_cache_refresh_mode', - 'title' => ts('Mode for refreshing smart group cache'), - 'description' => ts('This provides the option for the smart group cache setting'), - 'is_reserved' => 1, - )); - CRM_Core_BAO_OptionValue::ensureOptionValueExists(array( - 'option_group_id' => $optionGroupID, - 'name' => 'opportunistic', - 'label' => ts('Opportunistic'), - 'description' => ts('Purge the cache in response to user actions'), - 'is_active' => TRUE, - 'filter' => 1, - 'is_reserved' => 1, - )); - CRM_Core_BAO_OptionValue::ensureOptionValueExists(array( - 'option_group_id' => $optionGroupID, - 'name' => 'deterministic', - 'label' => ts('Deterministic'), - 'description' => ts('Only purge the cache on system jobs'), - 'is_active' => TRUE, - 'filter' => 1, - 'is_reserved' => 1, - )); - return TRUE; - } - } diff --git a/settings/Core.setting.php b/settings/Core.setting.php index daadbe0e67..531050eb36 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -306,10 +306,10 @@ return array( 'is_domain' => 1, 'is_contact' => 0, 'pseudoconstant' => array( - 'optionGroupName' => 'smart_group_cache_refresh_mode', + 'callback' => 'CRM_Contact_BAO_GroupContactCache::getModes', ), 'description' => 'Should the smart groups be by cron jobs or user actions', - 'help_text' => 'If you are not in a position to configure the cron you should leave this at the default. If you are then clearing caches via cron will improve the user experience.', + 'help_text' => 'In "Opportunistic Flush" mode, caches are flushed in response to user actions; this mode is broadly compatible but may add latency during form-submissions. In "Cron Flush" mode, you should schedule a cron job to flush caches; this can improve latency on form-submissions but requires more setup.', ), 'installed' => array( 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 1987c1f669..eff7f199e9 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -209,8 +209,7 @@ VALUES ('communication_style' , '{ts escape="sql"}Communication Style{/ts}' , 1, 1, 0), ('msg_mode' , '{ts escape="sql"}Message Mode{/ts}' , 1, 1, 0), ('contact_date_reminder_options' , '{ts escape="sql"}Contact Date Reminder Options{/ts}' , 1, 1, 1), - ('relative_date_filters' , '{ts escape="sql"}Relative Date Filters{/ts}' , 1, 1, 0), - ('smart_group_cache_refresh_mode', '{ts escape="sql"}Smart Group Cache Management Mode{/ts}' , 1, 1, 1); + ('relative_date_filters' , '{ts escape="sql"}Relative Date Filters{/ts}' , 1, 1, 0); SELECT @option_group_id_pcm := max(id) from civicrm_option_group where name = 'preferred_communication_method'; SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type'; @@ -289,7 +288,6 @@ SELECT @option_group_id_communication_style := max(id) from civicrm_option_group SELECT @option_group_id_msg_mode := max(id) from civicrm_option_group where name = 'msg_mode'; SELECT @option_group_id_contactDateMode := max(id) from civicrm_option_group where name = 'contact_date_reminder_options'; SELECT @option_group_id_date_filter := max(id) from civicrm_option_group where name = 'relative_date_filters'; -SELECT @option_group_smart_group_cache_refresh_mode := max(id) from civicrm_option_group where name = 'smart_group_cache_refresh_mode'; SELECT @contributeCompId := max(id) FROM civicrm_component where name = 'CiviContribute'; SELECT @eventCompId := max(id) FROM civicrm_component where name = 'CiviEvent'; @@ -1020,9 +1018,7 @@ VALUES (@option_group_id_date_filter, '{ts escape="sql"}From end of previous week{/ts}', 'greater_previous.week', 'greater_previous.week', NULL, NULL, NULL,59, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_date_filter, '{ts escape="sql"}From end of previous calendar month{/ts}', 'greater_previous.month', 'greater_previous.month', NULL, NULL, NULL,60, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_date_filter, '{ts escape="sql"}From end of previous quarter{/ts}', 'greater_previous.quarter', 'greater_previous.quarter', NULL, NULL, NULL,61, NULL, 0, 0, 1, NULL, NULL), - (@option_group_id_date_filter, '{ts escape="sql"}From end of previous calendar year{/ts}', 'greater_previous.year', 'greater_previous.year', NULL, NULL, NULL,62, NULL, 0, 0, 1, NULL, NULL), - (@option_group_smart_group_cache_refresh_mode, '{ts escape="sql"}Opportunistic{/ts}', 'opportunistic','opportunistic', NULL, NULL, 1, 1, NULL, 0, 0, 1, NULL, NULL), - (@option_group_smart_group_cache_refresh_mode, '{ts escape="sql"}Deterministic{/ts}', 'deterministic','deterministic', NULL, NULL, 0, 2, NULL, 0, 0, 1, NULL, NULL); + (@option_group_id_date_filter, '{ts escape="sql"}From end of previous calendar year{/ts}', 'greater_previous.year', 'greater_previous.year', NULL, NULL, NULL,62, NULL, 0, 0, 1, NULL, NULL); -- financial accounts SELECT @opval := value FROM civicrm_option_value WHERE name = 'Revenue' and option_group_id = @option_group_id_fat;