Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
c037736a | 19 | * This class generates form components for DedupeRules. |
6a488035 TO |
20 | */ |
21 | class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form { | |
22 | ||
b7f92e74 | 23 | /** |
24 | * Indicate if this form should warn users of unsaved changes | |
69078420 | 25 | * @var bool |
b7f92e74 | 26 | */ |
27 | protected $unsavedChangesWarn = FALSE; | |
28 | ||
6a488035 | 29 | /** |
fe482240 | 30 | * Pre processing. |
6a488035 | 31 | */ |
00be9182 | 32 | public function preProcess() { |
6a488035 TO |
33 | $this->rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0); |
34 | } | |
35 | ||
36 | /** | |
fe482240 | 37 | * Build the form object. |
6a488035 TO |
38 | */ |
39 | public function buildQuickForm() { | |
40 | ||
be2fb01f | 41 | $groupList = ['' => ts('- All Contacts -')] + CRM_Core_PseudoConstant::nestedGroup(); |
6a488035 | 42 | |
be2fb01f | 43 | $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, ['class' => 'crm-select2 huge']); |
30fcf833 | 44 | if (Civi::settings()->get('dedupe_default_limit')) { |
45 | $this->add('text', 'limit', ts('No of contacts to find matches for ')); | |
46 | } | |
be2fb01f | 47 | $this->addButtons([ |
69078420 SL |
48 | [ |
49 | 'type' => 'next', | |
50 | 'name' => ts('Continue'), | |
51 | 'isDefault' => TRUE, | |
52 | ], | |
53 | //hack to support cancel button functionality | |
54 | [ | |
55 | 'type' => 'submit', | |
56 | 'class' => 'cancel', | |
57 | 'icon' => 'fa-times', | |
58 | 'name' => ts('Cancel'), | |
59 | ], | |
60 | ]); | |
6a488035 TO |
61 | } |
62 | ||
f2ac86d1 | 63 | /** |
64 | * Set the default values for the form. | |
65 | * | |
66 | * @return array | |
67 | */ | |
00be9182 | 68 | public function setDefaultValues() { |
30fcf833 | 69 | $this->_defaults['limit'] = Civi::settings()->get('dedupe_default_limit'); |
6a488035 TO |
70 | return $this->_defaults; |
71 | } | |
72 | ||
73 | /** | |
fe482240 | 74 | * Process the form submission. |
6a488035 TO |
75 | */ |
76 | public function postProcess() { | |
77 | $values = $this->exportValues(); | |
a7488080 | 78 | if (!empty($_POST['_qf_DedupeFind_submit'])) { |
6a488035 TO |
79 | //used for cancel button |
80 | CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/deduperules', 'reset=1')); | |
81 | return; | |
82 | } | |
4c8b4719 | 83 | $url = CRM_Utils_System::url('civicrm/contact/dedupefind', "reset=1&action=update&rgid={$this->rgid}"); |
6a488035 | 84 | if ($values['group_id']) { |
4c8b4719 | 85 | $url .= "&gid={$values['group_id']}"; |
6a488035 | 86 | } |
4c8b4719 | 87 | |
30fcf833 | 88 | if (!empty($values['limit'])) { |
4c8b4719 | 89 | $url .= '&limit=' . $values['limit']; |
6a488035 TO |
90 | } |
91 | ||
92 | CRM_Utils_System::redirect($url); | |
93 | } | |
96025800 | 94 | |
6a488035 | 95 | } |