Merge pull request #11962 from compucorp/55-hide-adding-option-value-for-locked-groups
[civicrm-core.git] / CRM / Contact / Form / DedupeFind.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
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
8c9251b3 31 * @copyright CiviCRM LLC (c) 2004-2018
6a488035
TO
32 */
33
34/**
c037736a 35 * This class generates form components for DedupeRules.
6a488035
TO
36 */
37class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form {
38
b7f92e74 39 /**
40 * Indicate if this form should warn users of unsaved changes
41 */
42 protected $unsavedChangesWarn = FALSE;
43
6a488035 44 /**
fe482240 45 * Pre processing.
6a488035 46 */
00be9182 47 public function preProcess() {
6a488035
TO
48 $this->rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
49 }
50
51 /**
fe482240 52 * Build the form object.
6a488035
TO
53 */
54 public function buildQuickForm() {
55
24431f7b 56 $groupList = array('' => ts('- All Contacts -')) + CRM_Core_PseudoConstant::nestedGroup();
6a488035 57
7310566a 58 $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, array('class' => 'crm-select2 huge'));
30fcf833 59 if (Civi::settings()->get('dedupe_default_limit')) {
60 $this->add('text', 'limit', ts('No of contacts to find matches for '));
61 }
6a488035
TO
62 $this->addButtons(array(
63 array(
64 'type' => 'next',
65 'name' => ts('Continue'),
66 'isDefault' => TRUE,
67 ),
68 //hack to support cancel button functionality
69 array(
70 'type' => 'submit',
aeb97cc1 71 'class' => 'cancel',
0291a521 72 'icon' => 'fa-times',
6a488035
TO
73 'name' => ts('Cancel'),
74 ),
75 )
76 );
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}