Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
c037736a | 35 | * This class generates form components for DedupeRules. |
6a488035 TO |
36 | */ |
37 | class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form { | |
38 | ||
b7f92e74 | 39 | /** |
40 | * Indicate if this form should warn users of unsaved changes | |
69078420 | 41 | * @var bool |
b7f92e74 | 42 | */ |
43 | protected $unsavedChangesWarn = FALSE; | |
44 | ||
6a488035 | 45 | /** |
fe482240 | 46 | * Pre processing. |
6a488035 | 47 | */ |
00be9182 | 48 | public function preProcess() { |
6a488035 TO |
49 | $this->rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0); |
50 | } | |
51 | ||
52 | /** | |
fe482240 | 53 | * Build the form object. |
6a488035 TO |
54 | */ |
55 | public function buildQuickForm() { | |
56 | ||
be2fb01f | 57 | $groupList = ['' => ts('- All Contacts -')] + CRM_Core_PseudoConstant::nestedGroup(); |
6a488035 | 58 | |
be2fb01f | 59 | $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, ['class' => 'crm-select2 huge']); |
30fcf833 | 60 | if (Civi::settings()->get('dedupe_default_limit')) { |
61 | $this->add('text', 'limit', ts('No of contacts to find matches for ')); | |
62 | } | |
be2fb01f | 63 | $this->addButtons([ |
69078420 SL |
64 | [ |
65 | 'type' => 'next', | |
66 | 'name' => ts('Continue'), | |
67 | 'isDefault' => TRUE, | |
68 | ], | |
69 | //hack to support cancel button functionality | |
70 | [ | |
71 | 'type' => 'submit', | |
72 | 'class' => 'cancel', | |
73 | 'icon' => 'fa-times', | |
74 | 'name' => ts('Cancel'), | |
75 | ], | |
76 | ]); | |
6a488035 TO |
77 | } |
78 | ||
f2ac86d1 | 79 | /** |
80 | * Set the default values for the form. | |
81 | * | |
82 | * @return array | |
83 | */ | |
00be9182 | 84 | public function setDefaultValues() { |
30fcf833 | 85 | $this->_defaults['limit'] = Civi::settings()->get('dedupe_default_limit'); |
6a488035 TO |
86 | return $this->_defaults; |
87 | } | |
88 | ||
89 | /** | |
fe482240 | 90 | * Process the form submission. |
6a488035 TO |
91 | */ |
92 | public function postProcess() { | |
93 | $values = $this->exportValues(); | |
a7488080 | 94 | if (!empty($_POST['_qf_DedupeFind_submit'])) { |
6a488035 TO |
95 | //used for cancel button |
96 | CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/deduperules', 'reset=1')); | |
97 | return; | |
98 | } | |
4c8b4719 | 99 | $url = CRM_Utils_System::url('civicrm/contact/dedupefind', "reset=1&action=update&rgid={$this->rgid}"); |
6a488035 | 100 | if ($values['group_id']) { |
4c8b4719 | 101 | $url .= "&gid={$values['group_id']}"; |
6a488035 | 102 | } |
4c8b4719 | 103 | |
30fcf833 | 104 | if (!empty($values['limit'])) { |
4c8b4719 | 105 | $url .= '&limit=' . $values['limit']; |
6a488035 TO |
106 | } |
107 | ||
108 | CRM_Utils_System::redirect($url); | |
109 | } | |
96025800 | 110 | |
6a488035 | 111 | } |