From: eileen Date: Sat, 25 Jun 2016 02:19:53 +0000 (+1200) Subject: CRM-18958 add setting to control addion of limit to the dedupe screen. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=30fcf833a17dd6427bd1d9c7a7cffcb1a78b905b;p=civicrm-core.git CRM-18958 add setting to control addion of limit to the dedupe screen. We have struggled to find a compromise between the needs of larger sites not to crash when deduping & the UI experience of a 'batch' not being a batch - ie. finding duplicates for the first 1000 contacts could result in 67 or 6700. In discussion it was clear that even if we agreed on a UI to make this work the default for a large site (e.g 1000 to prevent crashes) was different to what would work for a small site - so I concluded we would need a setting. Given that it seemed to make sense to focus on adding the setting, which would provide the immediate protection needed for larger sites without compromising UI on small sites, and to put the time into that rather than solving the now less important batchin issue. Note I did some tidy up on the settings form code too... --- diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index 3f1e648ec0..7a6b91b36f 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -95,6 +95,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { ) ); + $descriptions = array(); foreach ($this->_settings as $setting => $group) { $settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting)); $props = $settingMetaData['values'][$setting]; @@ -135,6 +136,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { else { $this->$add($setting, ts($props['title'])); } + // Migrate to using an array as easier in smart... + $descriptions[$setting] = ts($props['description']); $this->assign("{$setting}_description", ts($props['description'])); if ($setting == 'max_attachments') { //temp hack @todo fix to get from metadata @@ -147,6 +150,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { } } + $this->assign('setting_descriptions', $descriptions); } /** diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index e481b724a7..68f68d15a2 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -52,6 +52,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'wkhtmltopdfPath' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'recentItemsMaxCount' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'recentItemsProviders' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'dedupe_default_limit' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ); public $_uploadMaxSize; @@ -60,10 +61,20 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { * Basic setup. */ public function preProcess() { - $config = CRM_Core_Config::singleton(); $this->_uploadMaxSize = (int) ini_get('upload_max_filesize'); // check for post max size CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE); + // This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but + // we haven't worked through NOT doing that. These settings have been un-hardcoded. + $this->assign('pure_config_settings', array( + 'empoweredBy', + 'max_attachments', + 'maxFileSize', + 'secondDegRelPermissions', + 'recentItemsMaxCount', + 'recentItemsProviders', + 'dedupe_default_limit', + )); } /** diff --git a/CRM/Contact/Form/DedupeFind.php b/CRM/Contact/Form/DedupeFind.php index a6717bc305..966ce55714 100644 --- a/CRM/Contact/Form/DedupeFind.php +++ b/CRM/Contact/Form/DedupeFind.php @@ -51,7 +51,9 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form { $groupList = array('' => ts('- All Contacts -')) + CRM_Core_PseudoConstant::nestedGroup(); $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, array('class' => 'crm-select2 huge')); - $this->add('text', 'limit', ts('No of contacts to find matches for ')); + if (Civi::settings()->get('dedupe_default_limit')) { + $this->add('text', 'limit', ts('No of contacts to find matches for ')); + } $this->addButtons(array( array( 'type' => 'next', @@ -70,7 +72,7 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form { } public function setDefaultValues() { - $this->_defaults['limit'] = 1000; + $this->_defaults['limit'] = Civi::settings()->get('dedupe_default_limit'); return $this->_defaults; } @@ -89,7 +91,7 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form { $url .= "&gid={$values['group_id']}"; } - if ($values['limit']) { + if (!empty($values['limit'])) { $url .= '&limit=' . $values['limit']; } diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 73a444dcdc..f8fa1904bf 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -597,6 +597,8 @@ return array( 'group' => 'core', 'name' => 'resCacheCode', 'type' => 'String', + 'quick_form_type' => 'Element', + 'html_type' => 'text', 'default' => NULL, 'add' => '4.3', 'title' => 'resCacheCode', @@ -819,6 +821,8 @@ return array( 'group' => 'core', 'name' => 'site_id', 'type' => 'String', + 'quick_form_type' => 'Element', + 'html_type' => 'text', 'default' => '', 'add' => '4.6', 'title' => 'Unique Site ID', @@ -832,6 +836,8 @@ return array( 'group' => 'core', 'name' => 'systemStatusCheckResult', 'type' => 'Integer', + 'quick_form_type' => 'Element', + 'html_type' => 'text', 'default' => 0, 'add' => '4.7', 'title' => 'systemStatusCheckResult', @@ -881,4 +887,19 @@ return array( 'callback' => 'CRM_Utils_Recent::getProviders', ), ), + 'dedupe_default_limit' => array( + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'dedupe_default_limit', + 'type' => 'Integer', + 'default' => 0, + 'quick_form_type' => 'Element', + 'html_type' => 'text', + 'add' => '4.7', + 'title' => 'Default limit for dedupe screen', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => ts('Default to only loading matches against this number of contacts'), + 'help_text' => ts('Deduping larger databases can crash the server. By configuring a limit other than 0 here the dedupe query will only search for matches against a limited number of contacts.'), + ), ); diff --git a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl index 04db77c290..5d5c187049 100644 --- a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl +++ b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl @@ -72,37 +72,14 @@

{ts 1="http://wkhtmltopdf.org/"}wkhtmltopdf is an alternative utility for generating PDF's which may provide better performance especially if you are generating a large number of PDF letters or receipts. Your system administrator will need to download and install this utility, and enter the executable path here.{/ts}

- - {$form.empoweredBy.label} - {$form.empoweredBy.html}
-

{ts}When enabled, "empowered by CiviCRM" is displayed at the bottom of public forms.{/ts}

- - - {$form.max_attachments.label} - {$form.max_attachments.html}
- {ts}Maximum number of files (documents, images, etc.) which can attached to emails or activities.{/ts} - - - {$form.maxFileSize.label} - {$form.maxFileSize.html}
- {$maxFileSize_description} - - - {$form.secondDegRelPermissions.label} - {$form.secondDegRelPermissions.html}
-

{ts}If enabled, contacts with the permission to edit a related contact will inherit that contact's permission to edit other related contacts.{/ts}

+ {foreach from=$pure_config_settings item=setting_name} + + {$form.$setting_name.label} + {$form.$setting_name.html}
+ {$setting_descriptions.$setting_name} - - - {$form.recentItemsMaxCount.label} - {$form.recentItemsMaxCount.html}
- {$recentItemsMaxCount_description} - - - {$form.recentItemsProviders.label} - {$form.recentItemsProviders.html}
- {$recentItemsProviders_description} - + + {/foreach}

{ts}reCAPTCHA Keys{/ts}